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 <<
")";
static const Vector3 NEGATIVE_UNIT_X
static Radian ACos(Real fValue)
Arc cosine function.
Real * ptr()
Pointer accessor for direct copying.
Real distance(const Vector3 &rhs) const
Returns the distance to another vector.
Vector3 primaryAxis() const
Extract the primary (dominant) axis from this direction vector.
Vector3(const Real fX, const Real fY, const Real fZ)
static const Vector3 NEGATIVE_UNIT_Z
Implementation of a Quaternion, i.e.
bool isNaN() const
Check whether this vector contains valid values.
bool directionEquals(const Vector3 &rhs, const Radian &tolerance) const
Returns whether this vector is within a directional tolerance of another vector.
static bool isNaN(Real f)
float Real
Software floating point type.
static const Vector3 UNIT_X
static const Vector3 NEGATIVE_UNIT_Y
bool isZeroLength(void) const
Returns true if this vector is zero length.
Real valueRadians() const
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.
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...
static Real Abs(Real fValue)
Absolute value 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...
Vector3 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy...
Standard 3-dimensional vector.
Real squaredLength() const
Returns the square of the length(magnitude) of the vector.
Real dotProduct(const Vector3 &vec) const
Calculates the dot (scalar) product of this vector with another.
const Real * ptr() const
Pointer accessor for direct copying.
Real normalise(void)
Normalises this quaternion, and returns the previous length.
Radian angleBetween(const Vector3 &dest) const
Gets the angle between 2 vectors.
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
void makeCeil(const Vector3 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
static Real Sqrt(Real fValue)
Square root function.
Vector3 midPoint(const Vector3 &vec) const
Returns a vector at a point half way between this and the passed in vector.
Vector3 reflect(const Vector3 &normal) const
Calculates a reflection vector to the plane with the given normal .
static const Vector3 UNIT_SCALE
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 perpendicular(void) const
Generates a vector perpendicular to this vector (eg an 'up' vector).
static const Vector3 UNIT_Y
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Real absDotProduct(const Vector3 &vec) const
Calculates the absolute dot (scalar) product of this vector with another.
static T Clamp(T val, T minval, T maxval)
Clamp a value within an inclusive range.
Vector3(const int afCoordinate[3])
Real length() const
Returns the length (magnitude) of the vector.
Real normalise()
Normalises the vector.
Vector3(const Real scaler)
Quaternion getRotationTo(const Vector3 &dest, const Vector3 &fallbackAxis=Vector3::ZERO) const
Gets the shortest arc quaternion to rotate this vector to the destination 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...
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
Radian operator/(Real a, const Radian &b)
static Real UnitRandom()
Generate a random number of unit length.
void swap(Vector3 &other)
Exchange the contents of this vector with another.
static const Quaternion IDENTITY
Radian operator*(Real a, const Radian &b)
Vector3 crossProduct(const Vector3 &rkVector) const
Calculates the cross-product of 2 vectors, i.e.
static bool RealEqual(Real a, Real b, Real tolerance=std::numeric_limits< Real >::epsilon())
Compare 2 reals, using tolerance for inaccuracies.
bool operator<(SharedPtr< T > const &a, SharedPtr< U > const &b)
static const Vector3 UNIT_Z
Vector3()
Default constructor.
Wrapper class which indicates a given angle value is in Radians.
Vector3(const Real afCoordinate[3])
static const Vector3 ZERO