62 : x( fX ), y( fY ), z( fZ )
67 : x( afCoordinate[0] ),
73 inline explicit Vector3(
const int afCoordinate[3] )
75 x = (
Real)afCoordinate[0];
76 y = (
Real)afCoordinate[1];
77 z = (
Real)afCoordinate[2];
81 : x( r[0] ), y( r[1] ), z( r[2] )
97 std::swap(x, other.
x);
98 std::swap(y, other.
y);
99 std::swap(z, other.
z);
102 inline Real operator [] (
const size_t i )
const
109 inline Real& operator [] (
const size_t i )
150 return ( x == rkVector.
x && y == rkVector.
y && z == rkVector.
z );
155 return ( x != rkVector.
x || y != rkVector.
y || z != rkVector.
z );
193 assert( fScalar != 0.0 );
195 Real fInv = 1.0f / fScalar;
225 fScalar * rkVector.
x,
226 fScalar * rkVector.
y,
227 fScalar * rkVector.
z);
233 fScalar / rkVector.
x,
234 fScalar / rkVector.
y,
235 fScalar / rkVector.
z);
324 assert( fScalar != 0.0 );
326 Real fInv = 1.0f / fScalar;
369 return x * x + y * y + z * z;
381 return (*
this - rhs).length();
396 return (*
this - rhs).squaredLength();
415 return x * vec.
x + y * vec.
y + z * vec.
z;
447 if ( fLength > 1e-08 )
449 Real fInvLength = 1.0f / fLength;
489 y * rkVector.
z - z * rkVector.
y,
490 z * rkVector.
x - x * rkVector.
z,
491 x * rkVector.
y - y * rkVector.
x);
500 ( x + vec.
x ) * 0.5f,
501 ( y + vec.
y ) * 0.5f,
502 ( z + vec.
z ) * 0.5f );
510 if( x < rhs.
x && y < rhs.
y && z < rhs.
z )
518 inline bool operator > (
const Vector3& rhs )
const
520 if( x > rhs.
x && y > rhs.
y && z > rhs.
z )
534 if( cmp.
x < x ) x = cmp.
x;
535 if( cmp.
y < y ) y = cmp.
y;
536 if( cmp.
z < z ) z = cmp.
z;
548 if( cmp.
x > x ) x = cmp.
x;
549 if( cmp.
y > y ) y = cmp.
y;
550 if( cmp.
z > z ) z = cmp.
z;
562 static const Real fSquareZero = (
Real)(1e-06 * 1e-06);
606 newUp = this->perpendicular();
632 if(lenProduct < 1e-6f)
635 Real f = dotProduct(dest) / lenProduct;
666 if (d < (1e-6f - 1.0f))
702 Real sqlen = (x * x) + (y * y) + (z * z);
703 return (sqlen < (1e-06 * 1e-06));
721 return Vector3( *
this - ( 2 * this->dotProduct(normal) * normal ) );
746 return squaredDistance(rhs) <=
758 const Radian& tolerance)
const
760 Real dot = dotProduct(rhs);
785 inline _OgreExport friend std::ostream&
operator <<
788 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
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.
Radian angleBetween(const Vector3 &dest)
Gets the angle between 2 vectors.
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.
static Radian ACos(Real fValue)
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)
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...
static Real Sqrt(Real fValue)
void FromAngleAxis(const Radian &rfAngle, const Vector3 &rkAxis)
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.
Standard 3-dimensional 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++)