3 #include "ParaQuaternion.h" 26 inline Vector3(
const float fX,
const float fY,
const float fZ )
27 : x( fX ), y( fY ), z( fZ )
31 inline explicit Vector3(
const float afCoordinate[3] )
32 : x( afCoordinate[0] ),
38 inline explicit Vector3(
const int afCoordinate[3] )
40 x = (float)afCoordinate[0];
41 y = (float)afCoordinate[1];
42 z = (float)afCoordinate[2];
45 inline explicit Vector3(
float*
const r )
46 : x( r[0] ), y( r[1] ), z( r[2] )
50 inline explicit Vector3(
const float scaler )
58 inline float operator [] (
const size_t i )
const 65 inline float& operator [] (
const size_t i )
77 inline const float*
ptr()
const 99 operator D3DXVECTOR3& ();
100 operator const D3DXVECTOR3& ()
const;
103 : x(v.x), y(v.y), z(v.z)
116 inline Vector3&
operator = (
const float fScaler )
125 inline bool operator == (
const Vector3& rkVector )
const 127 return ( x == rkVector.x && y == rkVector.y && z == rkVector.z );
130 inline bool operator != (
const Vector3& rkVector )
const 132 return ( x != rkVector.x || y != rkVector.y || z != rkVector.z );
136 inline Vector3 operator + (
const Vector3& rkVector )
const 144 inline Vector3 operator - (
const Vector3& rkVector )
const 152 inline Vector3 operator * (
const float fScalar )
const 166 inline Vector3 operator * (
const Vector3& rhs)
const 174 inline Vector3 operator / (
const float fScalar )
const 176 assert( fScalar != 0.0f );
178 float fInv = 1.0f / fScalar;
186 inline Vector3 operator / (
const Vector3& rhs)
const 194 inline const Vector3& operator + ()
const 199 inline Vector3 operator - ()
const 201 return Vector3(-x, -y, -z);
205 inline friend Vector3 operator * (
const float fScalar,
const Vector3& rkVector )
208 fScalar * rkVector.x,
209 fScalar * rkVector.y,
210 fScalar * rkVector.z);
213 inline friend Vector3 operator / (
const float fScalar,
const Vector3& rkVector )
216 fScalar / rkVector.x,
217 fScalar / rkVector.y,
218 fScalar / rkVector.z);
221 inline friend Vector3 operator + (
const Vector3& lhs,
const float rhs)
229 inline friend Vector3 operator + (
const float lhs,
const Vector3& rhs)
237 inline friend Vector3 operator - (
const Vector3& lhs,
const float rhs)
245 inline friend Vector3 operator - (
const float lhs,
const Vector3& rhs)
254 inline Vector3& operator += (
const Vector3& rkVector )
263 inline Vector3& operator += (
const float fScalar )
271 inline Vector3& operator -= (
const Vector3& rkVector )
280 inline Vector3& operator -= (
const float fScalar )
288 inline Vector3& operator *= (
const float fScalar )
296 inline Vector3& operator *= (
const Vector3& rkVector )
306 inline Vector3 operator * (
const Matrix4& mat)
const;
308 inline Vector3& operator /= (
const float fScalar )
310 assert( fScalar != 0.0f );
312 float fInv = 1.0f / fScalar;
321 inline Vector3& operator /= (
const Vector3& rkVector )
342 return Math::Sqrt( x * x + y * y + z * z );
357 return x * x + y * y + z * z;
369 return (*
this - rhs).length();
384 return (*
this - rhs).squaredLength();
403 return x * vec.x + y * vec.y + z * vec.z;
418 return Math::Abs(x * vec.x) + Math::Abs(y * vec.y) + Math::Abs(z * vec.z);
432 float fLength = Math::Sqrt( x * x + y * y + z * z );
435 if ( fLength > 1e-08 )
437 float fInvLength = 1.0f / fLength;
446 inline Vector3 InvertYCopy()
const 448 return Vector3(x, -y, z);
451 inline Vector3& InvertY()
488 y * rkVector.z - z * rkVector.y,
489 z * rkVector.x - x * rkVector.z,
490 x * rkVector.y - y * rkVector.x);
496 inline Vector3
midPoint(
const Vector3& vec )
const 499 ( x + vec.x ) * 0.5f,
500 ( y + vec.y ) * 0.5f,
501 ( z + vec.z ) * 0.5f );
518 if( x < rhs.x && y < rhs.y && z < rhs.z )
528 if( x > rhs.x && y > rhs.y && z > rhs.z )
542 if( cmp.x < x ) x = cmp.x;
543 if( cmp.y < y ) y = cmp.y;
544 if( cmp.z < z ) z = cmp.z;
556 if( cmp.x > x ) x = cmp.x;
557 if( cmp.y > y ) y = cmp.y;
558 if( cmp.z > z ) z = cmp.z;
590 const Vector3& up = Vector3::ZERO )
const;
606 const Vector3& fallbackAxis = Vector3::ZERO)
const;
611 float sqlen = (x * x) + (y * y) + (z * z);
612 return (sqlen < (1e-06 * 1e-06));
628 inline Vector3
reflect(
const Vector3& normal)
const 630 return Vector3( *
this - ( 2 * this->
dotProduct(normal) * normal ) );
667 const Radian& tolerance)
const 670 Radian angle = Math::ACos(dot);
672 return Math::Abs(angle.valueRadians()) <= tolerance.valueRadians();
677 static const Vector3 ZERO;
678 static const Vector3 UNIT_X;
679 static const Vector3 UNIT_Y;
680 static const Vector3 UNIT_Z;
681 static const Vector3 NEGATIVE_UNIT_X;
682 static const Vector3 NEGATIVE_UNIT_Y;
683 static const Vector3 NEGATIVE_UNIT_Z;
684 static const Vector3 UNIT_SCALE;
688 inline friend std::ostream&
operator <<
689 ( std::ostream& o,
const Vector3& v )
691 o <<
"Vector3(" << v.x <<
", " << v.y <<
", " << v.z <<
")";
bool directionEquals(const Vector3 &rhs, const Radian &tolerance) const
Returns whether this vector is within a directional tolerance of another vector.
Definition: ParaVector3.h:666
Wrapper class which indicates a given angle value is in Radians.
Definition: ParaAngle.h:10
const float * ptr() const
Pointer accessor for direct copying.
Definition: ParaVector3.h:77
bool positionEquals(const Vector3 &rhs, float tolerance=1e-03) const
Returns whether this vector is within a positional tolerance of another vector.
Definition: ParaVector3.h:639
bool operator<(const Vector3 &rhs) const
Returns true if the vector's scalar components are all greater that the ones of the vector it is comp...
Definition: ParaVector3.h:516
void makeCeil(const Vector3 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
Definition: ParaVector3.h:554
float absDotProduct(const Vector3 &vec) const
Calculates the absolute dot (scalar) product of this vector with another.
Definition: ParaVector3.h:416
float squaredDistance(const Vector3 &rhs) const
Returns the square of the distance to another vector.
Definition: ParaVector3.h:382
different physics engine has different winding order.
Definition: EventBinding.h:32
bool operator>(const Vector3 &rhs) const
Returns true if the vector's scalar components are all smaller that the ones of the vector it is comp...
Definition: ParaVector3.h:526
Vector3 TransformCoord(const Matrix4 &m) const
only use this function.
static bool RealEqual(float a, float b, float tolerance=std::numeric_limits< float >::epsilon())
Compare 2 reals, using tolerance for inaccuracies.
Definition: ParaMath.cpp:307
Implementation of a Quaternion, i.e.
Definition: ParaQuaternion.h:10
Vector3 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy...
Definition: ParaVector3.h:618
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
bool positionCloses(const Vector3 &rhs, float tolerance=1e-03f) const
Returns whether this vector is within a positional tolerance of another vector, also take scale of th...
Definition: ParaVector3.h:653
float distance(const Vector3 &rhs) const
Returns the distance to another vector.
Definition: ParaVector3.h:367
bool isZeroLength(void) const
Returns true if this vector is zero length.
Definition: ParaVector3.h:609
Vector3 midPoint(const Vector3 &vec) const
Returns a vector at a point half way between this and the passed in vector.
Definition: ParaVector3.h:496
Vector3 & operator=(const Vector3 &rkVector)
Assigns the value of the other vector.
Definition: ParaVector3.h:88
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...
Definition: ParaVector3.cpp:112
Vector3 TransformNormal(const Matrix4 &m) const
ignored translation(row 3).
Definition: ParaVector3.cpp:40
float normalise()
Normalises the vector.
Definition: ParaVector3.h:430
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Quaternion getRotationTo(const Vector3 &dest, const Vector3 &fallbackAxis=Vector3::ZERO) const
Gets the shortest arc quaternion to rotate this vector to the destination vector. ...
Definition: ParaVector3.cpp:49
Vector3 operator%(const Vector3 &rhs) const
special cross product
Definition: ParaVector3.h:161
float length() const
Returns the length (magnitude) of the vector.
Definition: ParaVector3.h:340
Vector3 crossProduct(const Vector3 &rkVector) const
Calculates the cross-product of 2 vectors, i.e.
Definition: ParaVector3.h:485
Vector3 reflect(const Vector3 &normal) const
Calculates a reflection vector to the plane with the given normal .
Definition: ParaVector3.h:628
float * ptr()
Pointer accessor for direct copying.
Definition: ParaVector3.h:72
Definition: PEtypes.h:298
float squaredLength() const
Returns the square of the length(magnitude) of the vector.
Definition: ParaVector3.h:355
float dotProduct(const Vector3 &vec) const
Calculates the dot (scalar) product of this vector with another.
Definition: ParaVector3.h:401
Radian angleBetween(const Vector3 &dest)
Gets the angle between 2 vectors.
Definition: ParaVector3.cpp:98
void makeFloor(const Vector3 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector...
Definition: ParaVector3.h:540
Vector3 perpendicular(void) const
Generates a vector perpendicular to this vector (eg an 'up' vector).
Definition: ParaVector3.cpp:136
int dominantAxis() const
Returns the axis along which this vector is dominant.
Definition: ParaVector3.cpp:155