66 : x( fX ), y( fY ), z( fZ )
71 : x( afCoordinate[0] ),
77 inline explicit Vector3(
const int afCoordinate[3] )
79 x = (
Real)afCoordinate[0];
80 y = (
Real)afCoordinate[1];
81 z = (
Real)afCoordinate[2];
85 : x( r[0] ), y( r[1] ), z( r[2] )
106 inline Real operator [] (
const size_t i )
const
113 inline Real& operator [] (
const size_t i )
154 return ( x == rkVector.
x && y == rkVector.
y && z == rkVector.
z );
159 return ( x != rkVector.
x || y != rkVector.
y || z != rkVector.
z );
197 assert( fScalar != 0.0 );
199 Real fInv = 1.0f / fScalar;
229 fScalar * rkVector.
x,
230 fScalar * rkVector.
y,
231 fScalar * rkVector.
z);
237 fScalar / rkVector.
x,
238 fScalar / rkVector.
y,
239 fScalar / rkVector.
z);
328 assert( fScalar != 0.0 );
330 Real fInv = 1.0f / fScalar;
373 return x * x + y * y + z * z;
385 return (*
this - rhs).length();
400 return (*
this - rhs).squaredLength();
419 return x * vec.
x + y * vec.
y + z * vec.
z;
453 if ( fLength >
Real(0.0f) )
455 Real fInvLength = 1.0f / fLength;
495 y * rkVector.
z - z * rkVector.
y,
496 z * rkVector.
x - x * rkVector.
z,
497 x * rkVector.
y - y * rkVector.
x);
506 ( x + vec.
x ) * 0.5f,
507 ( y + vec.
y ) * 0.5f,
508 ( z + vec.
z ) * 0.5f );
516 if( x < rhs.
x && y < rhs.
y && z < rhs.
z )
524 inline bool operator > (
const Vector3& rhs )
const
526 if( x > rhs.
x && y > rhs.
y && z > rhs.
z )
540 if( cmp.
x < x ) x = cmp.
x;
541 if( cmp.
y < y ) y = cmp.
y;
542 if( cmp.
z < z ) z = cmp.
z;
554 if( cmp.
x > x ) x = cmp.
x;
555 if( cmp.
y > y ) y = cmp.
y;
556 if( cmp.
z > z ) z = cmp.
z;
568 static const Real fSquareZero = (
Real)(1e-06 * 1e-06);
612 newUp = this->perpendicular();
638 if(lenProduct < 1e-6f)
641 Real f = dotProduct(dest) / lenProduct;
672 if (d < (1e-6f - 1.0f))
708 Real sqlen = (x * x) + (y * y) + (z * z);
709 return (sqlen < (1e-06 * 1e-06));
727 return Vector3( *
this - ( 2 * this->dotProduct(normal) * normal ) );
752 return squaredDistance(rhs) <=
764 const Radian& tolerance)
const
766 Real dot = dotProduct(rhs);
811 inline _OgreExport friend std::ostream&
operator <<
814 o <<
"Vector3(" << v.x <<
", " << v.y <<
", " << v.z <<
")";
bool isNaN() const
Check whether this vector contains valid values.
static const Vector3 NEGATIVE_UNIT_Y
static const Vector3 NEGATIVE_UNIT_X
static const Vector3 UNIT_Z
static Real UnitRandom()
Generate a random number of unit length.
const Real * ptr() const
Pointer accessor for direct copying.
Vector3 randomDeviant(const Radian &angle, const Vector3 &up=Vector3::ZERO) 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.
Vector3 perpendicular(void) const
Generates a vector perpendicular to this vector (eg an 'up' vector).
static T Clamp(T val, T minval, T maxval)
Clamp a value within an inclusive range.
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
Real squaredDistance(const Vector3 &rhs) const
Returns the square of the distance to another vector.
bool positionEquals(const Vector3 &rhs, Real tolerance=1e-03) const
Returns whether this vector is within a positional tolerance of another vector.
static const Vector3 ZERO
Quaternion getRotationTo(const Vector3 &dest, const Vector3 &fallbackAxis=Vector3::ZERO) const
Gets the shortest arc quaternion to rotate this vector to the destination vector. ...
Real length() const
Returns the length (magnitude) of the vector.
void makeFloor(const Vector3 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector...
Vector3(const Real scaler)
Real dotProduct(const Vector3 &vec) const
Calculates the dot (scalar) product of this vector with another.
Vector3()
Default constructor.
static Radian ACos(Real fValue)
Arc cosine function.
Real * ptr()
Pointer accessor for direct copying.
Radian operator*(Real a, const Radian &b)
static bool RealEqual(Real a, Real b, Real tolerance=std::numeric_limits< Real >::epsilon())
Compare 2 reals, using tolerance for inaccuracies.
Radian operator/(Real a, const Radian &b)
Implementation of a Quaternion, i.e.
bool isZeroLength(void) const
Returns true if this vector is zero length.
Vector3(const Real afCoordinate[3])
static const Quaternion IDENTITY
static const Vector3 NEGATIVE_UNIT_Z
static Real Abs(Real fValue)
Absolute value function.
bool directionEquals(const Vector3 &rhs, const Radian &tolerance) const
Returns whether this vector is within a directional tolerance of another vector.
bool positionCloses(const Vector3 &rhs, Real tolerance=1e-03f) const
Returns whether this vector is within a positional tolerance of another vector, also take scale of th...
Radian angleBetween(const Vector3 &dest) const
Gets the angle between 2 vectors.
static Real Sqrt(Real fValue)
Square root function.
void FromAngleAxis(const Radian &rfAngle, const Vector3 &rkAxis)
Setups the quaternion using the supplied vector, and "roll" around that vector by the specified radia...
Real absDotProduct(const Vector3 &vec) const
Calculates the absolute dot (scalar) product of this vector with another.
Real valueRadians() const
Real squaredLength() const
Returns the square of the length(magnitude) of the vector.
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Standard 3-dimensional vector.
Vector3 primaryAxis() const
Extract the primary (dominant) axis from this direction vector.
Wrapper class which indicates a given angle value is in Radians.
static const Vector3 UNIT_X
Real distance(const Vector3 &rhs) const
Returns the distance to another vector.
void makeCeil(const Vector3 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
Real normalise()
Normalises the vector.
static const Vector3 UNIT_Y
Vector3 reflect(const Vector3 &normal) const
Calculates a reflection vector to the plane with the given normal .
static bool isNaN(Real f)
Vector3(const Real fX, const Real fY, const Real fZ)
Vector3 crossProduct(const Vector3 &rkVector) const
Calculates the cross-product of 2 vectors, i.e.
void swap(Vector3 &other)
Exchange the contents of this vector with another.
Vector3(const int afCoordinate[3])
Real normalise(void)
Normalises this quaternion, and returns the previous length.
static const Vector3 UNIT_SCALE
Vector3 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy...
Vector3 midPoint(const Vector3 &vec) const
Returns a vector at a point half way between this and the passed in vector.
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++)