67 : x( scaler), y( scaler )
72 : x( afCoordinate[0] ),
77 inline explicit Vector2(
const int afCoordinate[2] )
79 x = (
Real)afCoordinate[0];
80 y = (
Real)afCoordinate[1];
84 : x( r[0] ), y( r[1] )
92 std::swap(x, other.
x);
93 std::swap(y, other.
y);
96 inline Real operator [] (
const size_t i )
const
103 inline Real& operator [] (
const size_t i )
143 return ( x == rkVector.
x && y == rkVector.
y );
148 return ( x != rkVector.
x || y != rkVector.
y );
182 assert( fScalar != 0.0 );
184 Real fInv = 1.0f / fScalar;
212 fScalar * rkVector.
x,
213 fScalar * rkVector.
y);
219 fScalar / rkVector.
x,
220 fScalar / rkVector.
y);
301 assert( fScalar != 0.0 );
303 Real fInv = 1.0f / fScalar;
343 return x * x + y * y;
354 return (*
this - rhs).length();
369 return (*
this - rhs).squaredLength();
388 return x * vec.
x + y * vec.
y;
405 if ( fLength > 1e-08 )
407 Real fInvLength = 1.0f / fLength;
423 ( x + vec.
x ) * 0.5f,
424 ( y + vec.
y ) * 0.5f );
432 if( x < rhs.
x && y < rhs.
y )
440 inline bool operator > (
const Vector2& rhs )
const
442 if( x > rhs.
x && y > rhs.
y )
456 if( cmp.
x < x ) x = cmp.
x;
457 if( cmp.
y < y ) y = cmp.
y;
469 if( cmp.
x > x ) x = cmp.
x;
470 if( cmp.
y > y ) y = cmp.
y;
489 return x * rkVector.
y - y * rkVector.
x;
515 Real cosa = cos(angle);
516 Real sina = sin(angle);
517 return Vector2(cosa * x - sina * y,
518 sina * x + cosa * y);
524 Real sqlen = (x * x) + (y * y);
525 return (sqlen < (1e-06 * 1e-06));
543 return Vector2( *
this - ( 2 * this->dotProduct(normal) * normal ) );
561 inline _OgreExport friend std::ostream&
operator <<
564 o <<
"Vector2(" << v.x <<
", " << v.y <<
")";
Real squaredDistance(const Vector2 &rhs) const
Returns the square of the distance to another vector.
Real length() const
Returns the length (magnitude) of the vector.
Real dotProduct(const Vector2 &vec) const
Calculates the dot (scalar) product of this vector with another.
float Real
Software floating point type.
static const Vector2 UNIT_Y
Vector2(const Real fX, const Real fY)
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
void swap(Vector2 &other)
Exchange the contents of this vector with another.
static const Vector2 NEGATIVE_UNIT_X
static const Vector2 UNIT_X
Vector2(const Real afCoordinate[2])
Real crossProduct(const Vector2 &rkVector) const
Calculates the 2 dimensional cross-product of 2 vectors, which results in a single floating point val...
Vector2 reflect(const Vector2 &normal) const
Calculates a reflection vector to the plane with the given normal .
Radian operator*(Real a, const Radian &b)
Radian operator/(Real a, const Radian &b)
Vector2(const Real scaler)
Vector2 midPoint(const Vector2 &vec) const
Returns a vector at a point half way between this and the passed in vector.
Vector2 randomDeviant(Real angle) const
Generates a new random vector which deviates from this vector by a given angle in a random direction...
static const Vector2 ZERO
bool isNaN() const
Check whether this vector contains valid values.
static Real Sqrt(Real fValue)
Real distance(const Vector2 &rhs) const
Returns the distance to another vector.
Standard 2-dimensional vector.
static const Vector2 UNIT_SCALE
Real normalise()
Normalises the vector.
static const Vector2 NEGATIVE_UNIT_Y
void makeFloor(const Vector2 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector...
Vector2(const int afCoordinate[2])
bool isZeroLength(void) const
Returns true if this vector is zero length.
const Real * ptr() const
Pointer accessor for direct copying.
Vector2 perpendicular(void) const
Generates a vector perpendicular to this vector (eg an 'up' vector).
static bool isNaN(Real f)
void makeCeil(const Vector2 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
Real squaredLength() const
Returns the square of the length(magnitude) of the vector.
Real * ptr()
Pointer accessor for direct copying.
Vector2 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy...
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)