Go to the documentation of this file.
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 <<
")";
Ogre::Radian angleBetween(const Ogre::Vector2 &other) const
Gets the angle between 2 vectors.
void swap(Vector2 &other)
Exchange the contents of this vector with another.
Vector2(const Real afCoordinate[2])
Vector2 midPoint(const Vector2 &vec) const
Returns a vector at a point half way between this and the passed in vector.
Real squaredLength() const
Returns the square of the length(magnitude) of the vector.
static Real RangeRandom(Real fLow, Real fHigh)
Generate a random number within the range provided.
static Radian ACos(Real fValue)
Arc cosine function.
const Real * ptr() const
Pointer accessor for direct copying.
Real distance(const Vector2 &rhs) const
Returns the distance to another vector.
Vector2(const Real scaler)
Vector2(const int afCoordinate[2])
static Real Cos(const Radian &fValue, bool useTables=false)
Cosine function.
static T Clamp(T val, T minval, T maxval)
Clamp a value within an inclusive range.
Radian operator*(Real a, const Radian &b)
bool isNaN() const
Check whether this vector contains valid values.
Real * ptr()
Pointer accessor for direct copying.
static const Vector2 UNIT_Y
Real dotProduct(const Vector2 &vec) const
Calculates the dot (scalar) product of this vector with another.
Radian operator/(Real a, const Radian &b)
Vector2 perpendicular(void) const
Generates a vector perpendicular to this vector (eg an 'up' vector).
static Real Sin(const Radian &fValue, bool useTables=false)
Sine function.
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator,...
Real normalise()
Normalises the vector.
static Real Sqrt(Real fValue)
Square root function.
static const Vector2 ZERO
static const Vector2 NEGATIVE_UNIT_X
static const Vector2 UNIT_SCALE
Real squaredDistance(const Vector2 &rhs) const
Returns the square of the distance to another vector.
Wrapper class which indicates a given angle value is in Radians.
Vector2 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy.
static bool isNaN(Real f)
Vector2 reflect(const Vector2 &normal) const
Calculates a reflection vector to the plane with the given normal .
bool isZeroLength(void) const
Returns true if this vector is zero length.
static const Vector2 NEGATIVE_UNIT_Y
void makeCeil(const Vector2 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector.
void makeFloor(const Vector2 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector.
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Standard 2-dimensional vector.
Vector2 randomDeviant(Radian angle) const
Generates a new random vector which deviates from this vector by a given angle in a random direction.
float Real
Software floating point type.
Vector2()
Default constructor.
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator,...
static const Vector2 UNIT_X
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
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.
Vector2(const Real fX, const Real fY)
Real crossProduct(const Vector2 &rkVector) const
Calculates the 2 dimensional cross-product of 2 vectors, which results in a single floating point val...
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15