112 return Vector2(powf(x, p), powf(y, p));
126 inline float sum()
const {
134 return (*
this) + (v - *
this) * alpha;
185 return Vector2(fabs(x), fabs(y));
200 return Vector2(::fabsf(x) > ::fabsf(v.
x) ? x : v.
x, ::fabsf(y) > ::fabsf(v.
y) ? y : v.
y);
209 return Vector2(::fabsf(x) < ::fabsf(v.
x) ? x : v.
x, ::fabsf(y) < ::fabsf(v.
y) ? y : v.
y);
298 x = (float)afCoordinate[0];
299 y = (float)afCoordinate[1];
315 return ((
float*)
this)[i];
320 return ((
float*)
this)[i];
332 return ( x == rkVector.
x && y == rkVector.
y);
337 return ( x != rkVector.
x || y != rkVector.
y);
342 return Vector2(x + rkVector.
x, y + rkVector.
y);
347 return Vector2(x - rkVector.
x, y - rkVector.
y);
352 return Vector2(fScalar*x, fScalar*y);
404 return Vector2(x * rkVector.
x, y * rkVector.
y);
410 return Vector2(x / rkVector.
x, y / rkVector.
y);
420 return sqrtf(x*x + y*y);
425 float lenSquared = x * x + y *
y;
427 if (lenSquared != 1.0f) {
428 return *
this / sqrtf(lenSquared);
436 if (mag < 0.0000001f) {
438 }
else if (mag < 1.00001f && mag > 0.99999f) {
441 return *
this * (1.0f / mag);
447 return x*rkVector.
x + y*rkVector.
y;
Vector3 yxx() const
Definition: Vector2.cpp:189
Vector4 yxyx() const
Definition: Vector2.cpp:204
Vector2 clamp(float low, float high) const
Definition: Vector2.h:143
Vector2 yx() const
Definition: Vector2.cpp:182
Vector2 operator*(float s) const
Definition: Vector2.h:351
Vector4 xxxy() const
Definition: Vector2.cpp:207
Vector2 abs() const
Definition: Vector2.h:184
Vector4 yxxy() const
Definition: Vector2.cpp:208
Vector3 xyy() const
Definition: Vector2.cpp:194
Vector2 xy() const
Definition: Vector2.cpp:183
bool isFinite() const
Definition: Vector2.h:476
bool operator!=(const Vector2 &other) const
Definition: Vector2.h:336
Vector2 & operator+=(const Vector2 &)
Definition: Vector2.h:363
Vector4 xyyy() const
Definition: Vector2.cpp:213
Vector4 yyxy() const
Definition: Vector2.cpp:210
Vector4 xxyx() const
Definition: Vector2.cpp:203
Vector2 clamp(const Vector2 &low, const Vector2 &high) const
Definition: Vector2.h:137
Vector3 yyy() const
Definition: Vector2.cpp:195
Vector2 min(const Vector2 &v) const
Definition: Vector2.h:452
float length() const
Definition: Vector2.h:419
bool operator==(const Vector2 &other) const
Definition: Vector2.h:331
void deserialize(class BinaryInput &b)
Definition: Vector2.cpp:119
Definition: HashTrait.h:105
bool operator<=(const Vector2 &) const
Vector4 xxxx() const
Definition: Vector2.cpp:199
bool any(float x)
Definition: g3dmath.h:424
bool isNaN(double x)
Definition: g3dmath.cpp:56
Vector2 yy() const
Definition: Vector2.cpp:184
Vector3 yyx() const
Definition: Vector2.cpp:191
Vector3 yxy() const
Definition: Vector2.cpp:193
bool isZero() const
Definition: Vector2.h:482
void deserialize(std::string &s, BinaryInput &b)
Definition: serialize.h:16
Vector2 lerp(const Vector2 &v, float alpha) const
Definition: Vector2.h:133
Vector4 xyxy() const
Definition: Vector2.cpp:209
bool fuzzyNe(double a, double b)
Definition: g3dmath.h:861
bool fuzzyEq(const Vector2 &other) const
Definition: Vector2.h:464
double clamp(double val, double low, double hi)
Definition: g3dmath.h:571
bool isUnit() const
Definition: Vector2.h:488
Vector4 xxyy() const
Definition: Vector2.cpp:211
static size_t hashCode(const G3D::Vector2 &key)
Definition: Vector2.h:500
Vector3 xxx() const
Definition: Vector2.cpp:188
Vector2 operator-() const
Definition: Vector2.h:357
bool operator<(const Vector2 &) const
Vector2 & operator=(const Any &a)
Definition: Vector2.cpp:49
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Vector4 yyxx() const
Definition: Vector2.cpp:202
Vector2 Point2
Definition: Vector2.h:492
Vector3 xxy() const
Definition: Vector2.cpp:192
Vector2 directionOrZero() const
Definition: Vector2.h:434
float y
Definition: Vector2.h:50
static const Vector2 & one()
Definition: Vector2.cpp:62
static Vector2 random(Random &r=Random::common())
Definition: Vector2.cpp:150
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Easy loading and saving of human-readable configuration files.
Definition: Any.h:184
Vector2 & operator-=(const Vector2 &)
Definition: Vector2.h:371
void serialize(const std::string &s, BinaryOutput &b)
Definition: serialize.h:12
Vector2()
Definition: Vector2.h:282
float & operator[](int i)
Definition: Vector2.h:314
Vector4 xyyx() const
Definition: Vector2.cpp:205
bool operator>(const Vector2 &) const
Vector2 minAbs(const Vector2 &v) const
Definition: Vector2.h:208
Definition: Vector2unorm16.h:23
Any toAny() const
Definition: Vector2.cpp:55
A simple tokenizer for parsing text files.
Definition: TextInput.h:223
static const Vector2 & unitX()
Definition: Vector2.cpp:72
Vector2 operator+(const Vector2 &v) const
Definition: Vector2.h:341
Vector2 & operator/=(float)
Definition: Vector2.cpp:166
float x
Definition: Vector2.h:49
Vector2 pow(float p) const
Definition: Vector2.h:111
float squaredLength() const
Definition: Vector2.h:414
Vector2 fastDirection() const
Definition: Vector2.h:176
void serialize(class BinaryOutput &b) const
Definition: Vector2.cpp:125
Definition: TextOutput.h:60
Vector2 direction() const
Definition: Vector2.h:424
float sum() const
Definition: Vector2.h:126
static const Vector2 & minFinite()
Definition: Vector2.cpp:94
Definition: BinaryOutput.h:52
static const Vector2 & unitY()
Definition: Vector2.cpp:77
bool operator>=(const Vector2 &) const
static const Vector2 & nan()
Definition: Vector2.cpp:88
Vector2 maxAbs(const Vector2 &v) const
Definition: Vector2.h:199
Vector4 xyxx() const
Definition: Vector2.cpp:201
bool fuzzyNe(const Vector2 &other) const
Definition: Vector2.h:470
bool isNaN() const
Definition: Vector2.h:95
Vector2 & operator*=(float)
Definition: Vector2.h:379
Vector2 operator/(const Vector2 &v) const
Definition: Vector2.h:409
static const Vector2 & zero()
Definition: Vector2.cpp:67
static const Vector2 & maxFinite()
Definition: Vector2.cpp:100
G3D::Vector2 operator*(double s, const G3D::Vector2 &v)
Definition: Vector2.h:507
Vector2 max(const Vector2 &v) const
Definition: Vector2.h:458
std::string toString() const
Definition: Vector2.cpp:175
Vector4 yxyy() const
Definition: Vector2.cpp:212
Vector4 yyyx() const
Definition: Vector2.cpp:206
Vector3 xyx() const
Definition: Vector2.cpp:190
size_t hashCode() const
Definition: Vector2.cpp:106
Definition: Vector2int16.h:22
static Random & common()
Definition: Random.cpp:16
bool fuzzyEq(double a, double b)
Definition: g3dmath.h:857
G3D::Color3 operator*(float s, const G3D::Color3 &c)
Definition: Color3.h:275
float dot(const Vector2 &s) const
Definition: Vector2.h:446
Vector2 xx() const
Definition: Vector2.cpp:181
bool isFinite(double x)
Definition: g3dmath.h:525
Vector4 yyyy() const
Definition: Vector2.cpp:214
Vector4 yxxx() const
Definition: Vector2.cpp:200
static const Vector2 & inf()
Definition: Vector2.cpp:82