71 : x( scaler), y( scaler )
76 : x( afCoordinate[0] ),
81 inline explicit Vector2(
const int afCoordinate[2] )
83 x = (
Real)afCoordinate[0];
84 y = (
Real)afCoordinate[1];
88 : x( r[0] ), y( r[1] )
100 inline Real operator [] (
const size_t i )
const
107 inline Real& operator [] (
const size_t i )
147 return ( x == rkVector.
x && y == rkVector.
y );
152 return ( x != rkVector.
x || y != rkVector.
y );
186 assert( fScalar != 0.0 );
188 Real fInv = 1.0f / fScalar;
216 fScalar * rkVector.
x,
217 fScalar * rkVector.
y);
223 fScalar / rkVector.
x,
224 fScalar / rkVector.
y);
306 assert( fScalar != 0.0 );
308 Real fInv = 1.0f / fScalar;
348 return x * x + y * y;
360 return (*
this - rhs).length();
375 return (*
this - rhs).squaredLength();
394 return x * vec.
x + y * vec.
y;
414 if ( fLength >
Real(0.0f) )
416 Real fInvLength = 1.0f / fLength;
430 ( x + vec.
x ) * 0.5f,
431 ( y + vec.
y ) * 0.5f );
439 if( x < rhs.
x && y < rhs.
y )
447 inline bool operator > (
const Vector2& rhs )
const
449 if( x > rhs.
x && y > rhs.
y )
463 if( cmp.
x < x ) x = cmp.
x;
464 if( cmp.
y < y ) y = cmp.
y;
476 if( cmp.
x > x ) x = cmp.
x;
477 if( cmp.
y > y ) y = cmp.
y;
497 return x * rkVector.
y - y * rkVector.
x;
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 ) );
560 if(lenProduct < 1e-6f)
563 Ogre::Real f = dotProduct(other) / lenProduct;
578 if (crossProduct(other)<0)
594 inline _OgreExport friend std::ostream&
operator <<
597 o <<
"Vector2(" << v.x <<
", " << v.y <<
")";
Real squaredDistance(const Vector2 &rhs) const
Returns the square of the distance to another vector.
Ogre::Radian angleTo(const Ogre::Vector2 &other) const
Gets the oriented angle between 2 vectors.
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
static T Clamp(T val, T minval, T maxval)
Clamp a value within an inclusive range.
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])
static Radian ACos(Real fValue)
Arc cosine function.
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 .
static Real Cos(const Radian &fValue, bool useTables=false)
Cosine function.
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.
static const Vector2 ZERO
bool isNaN() const
Check whether this vector contains valid values.
static Real Sin(const Radian &fValue, bool useTables=false)
Sine function.
static Real RangeRandom(Real fLow, Real fHigh)
Generate a random number within the range provided.
static Real Sqrt(Real fValue)
Square root function.
Real distance(const Vector2 &rhs) const
Returns the distance to another vector.
Vector2 randomDeviant(Radian angle) const
Generates a new random vector which deviates from this vector by a given angle in a random direction...
Standard 2-dimensional vector.
static const Vector2 UNIT_SCALE
Real normalise()
Normalises the vector.
static const Vector2 NEGATIVE_UNIT_Y
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
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.
Wrapper class which indicates a given angle value is in Radians.
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)
Vector2()
Default constructor.
void makeCeil(const Vector2 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
Ogre::Radian angleBetween(const Ogre::Vector2 &other) const
Gets the angle between 2 vectors.
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++)