26 inline Vector2(
const float fX,
const float fY )
31 inline explicit Vector2(
const float scaler )
32 : x( scaler), y( scaler )
36 inline explicit Vector2(
const float afCoordinate[2] )
37 : x( afCoordinate[0] ),
42 inline explicit Vector2(
const int afCoordinate[2] )
44 x = (float)afCoordinate[0];
45 y = (float)afCoordinate[1];
48 inline explicit Vector2(
float*
const r )
49 : x( r[0] ), y( r[1] )
53 inline float operator [] (
const size_t i )
const 60 inline float& operator [] (
const size_t i )
73 inline const float*
ptr()
const 98 inline bool operator == (
const Vector2& rkVector )
const 100 return ( x == rkVector.x && y == rkVector.y );
103 inline bool operator != (
const Vector2& rkVector )
const 105 return ( x != rkVector.x || y != rkVector.y );
123 inline Vector2 operator * (
const float fScalar )
const 139 inline Vector2 operator / (
const float fScalar )
const 141 assert( fScalar != 0.0f );
143 float fInv = 1.0f / fScalar;
157 inline const Vector2& operator + ()
const 162 inline Vector2 operator - ()
const 168 inline friend Vector2 operator * (
const float fScalar,
const Vector2& rkVector )
171 fScalar * rkVector.x,
172 fScalar * rkVector.y);
175 inline friend Vector2 operator / (
const float fScalar,
const Vector2& rkVector )
178 fScalar / rkVector.x,
179 fScalar / rkVector.y);
182 inline friend Vector2 operator + (
const Vector2& lhs,
const float rhs)
189 inline friend Vector2 operator + (
const float lhs,
const Vector2& rhs)
196 inline friend Vector2 operator - (
const Vector2& lhs,
const float rhs)
203 inline friend Vector2 operator - (
const float lhs,
const Vector2& rhs)
218 inline Vector2& operator += (
const float fScaler )
234 inline Vector2& operator -= (
const float fScaler )
242 inline Vector2& operator *= (
const float fScalar )
258 inline Vector2& operator /= (
const float fScalar )
260 assert( fScalar != 0.0f );
262 float fInv = 1.0f / fScalar;
287 return Math::Sqrt( x * x + y * y );
302 return x * x + y * y;
321 return x * vec.x + y * vec.y;
335 float fLength = Math::Sqrt( x * x + y * y);
338 if ( fLength > 1e-08 )
340 float fInvLength = 1.0f / fLength;
356 ( x + vec.x ) * 0.5f,
357 ( y + vec.y ) * 0.5f );
365 if( x < rhs.x && y < rhs.y )
375 if( x > rhs.x && y > rhs.y )
389 if( cmp.x < x ) x = cmp.x;
390 if( cmp.y < y ) y = cmp.y;
402 if( cmp.x > x ) x = cmp.x;
403 if( cmp.y > y ) y = cmp.y;
422 return x * rkVector.y - y * rkVector.x;
447 angle *= Math::UnitRandom() * Math::TWO_PI;
448 float cosa = cos(angle);
449 float sina = sin(angle);
450 return Vector2(cosa * x - sina * y,
451 sina * x + cosa * y);
457 float sqlen = (x * x) + (y * y);
458 return (sqlen < (1e-06 * 1e-06));
483 static const Vector2 NEGATIVE_UNIT_X;
484 static const Vector2 NEGATIVE_UNIT_Y;
485 static const Vector2 UNIT_SCALE;
489 inline friend std::ostream&
operator <<
492 o <<
"Vector2(" << v.x <<
", " << v.y <<
")";
float normalise()
Normalises the vector.
Definition: ParaVector2.h:333
float crossProduct(const Vector2 &rkVector) const
Calculates the 2 dimensional cross-product of 2 vectors, which results in a single floating point val...
Definition: ParaVector2.h:420
bool operator<(const Vector2 &rhs) const
Returns true if the vector's scalar components are all greater that the ones of the vector it is comp...
Definition: ParaVector2.h:363
different physics engine has different winding order.
Definition: EventBinding.h:32
Vector2 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy...
Definition: ParaVector2.h:464
bool operator>(const Vector2 &rhs) const
Returns true if the vector's scalar components are all smaller that the ones of the vector it is comp...
Definition: ParaVector2.h:373
float length() const
Returns the length (magnitude) of the vector.
Definition: ParaVector2.h:285
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
Vector2 perpendicular(void) const
Generates a vector perpendicular to this vector (eg an 'up' vector).
Definition: ParaVector2.h:413
bool isZeroLength(void) const
Returns true if this vector is zero length.
Definition: ParaVector2.h:455
void makeFloor(const Vector2 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector...
Definition: ParaVector2.h:387
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
const float * ptr() const
Pointer accessor for direct copying.
Definition: ParaVector2.h:73
float dotProduct(const Vector2 &vec) const
Calculates the dot (scalar) product of this vector with another.
Definition: ParaVector2.h:319
Vector2 midPoint(const Vector2 &vec) const
Returns a vector at a point half way between this and the passed in vector.
Definition: ParaVector2.h:353
Vector2 reflect(const Vector2 &normal) const
Calculates a reflection vector to the plane with the given normal .
Definition: ParaVector2.h:474
Vector2 randomDeviant(float angle) const
Generates a new random vector which deviates from this vector by a given angle in a random direction...
Definition: ParaVector2.h:443
Vector2 & operator=(const Vector2 &rkVector)
Assigns the value of the other vector.
Definition: ParaVector2.h:82
float * ptr()
Pointer accessor for direct copying.
Definition: ParaVector2.h:68
float squaredLength() const
Returns the square of the length(magnitude) of the vector.
Definition: ParaVector2.h:300
void makeCeil(const Vector2 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
Definition: ParaVector2.h:400