3 #include "ParaQuaternion.h" 4 #include "ParaVector3.h" 27 inline DVector3(
const double fX,
const double fY,
const double fZ)
28 : x( fX ), y( fY ), z( fZ )
32 inline explicit DVector3(
const double afCoordinate[3])
33 : x( afCoordinate[0] ), y( afCoordinate[1] ), z( afCoordinate[2] )
37 inline explicit DVector3(
const int afCoordinate[3] )
39 x = (double)afCoordinate[0];
40 y = (double)afCoordinate[1];
41 z = (double)afCoordinate[2];
44 inline explicit DVector3(
double*
const r )
45 : x( r[0] ), y( r[1] ), z( r[2] )
49 inline explicit DVector3(
const double scaler )
50 : x( scaler ), y( scaler ) , z( scaler )
55 : x(vFrom.x), y(vFrom.y), z(vFrom.z)
59 inline double operator [] (
const size_t i )
const 66 inline double& operator [] (
const size_t i )
78 inline const double*
ptr()
const 85 return Vector3((
float)x, (
float)y, (
float)z);
121 inline bool operator == (
const DVector3& rkVector )
const 123 return ( x == rkVector.x && y == rkVector.y && z == rkVector.z );
126 inline bool operator != (
const DVector3& rkVector )
const 128 return ( x != rkVector.x || y != rkVector.y || z != rkVector.z );
163 inline DVector3 operator * (
const double fScalar )
const 185 inline DVector3 operator / (
const double fScalar )
const 187 assert( fScalar != 0.0f );
189 double fInv = 1.0f / fScalar;
205 inline const DVector3& operator + ()
const 216 inline friend DVector3 operator * (
const double fScalar,
const DVector3& rkVector )
219 fScalar * rkVector.x,
220 fScalar * rkVector.y,
221 fScalar * rkVector.z);
224 inline friend DVector3 operator / (
const double fScalar,
const DVector3& rkVector )
227 fScalar / rkVector.x,
228 fScalar / rkVector.y,
229 fScalar / rkVector.z);
282 inline DVector3& operator += (
const double fScalar )
308 inline DVector3& operator -= (
const double fScalar )
316 inline DVector3& operator *= (
const double fScalar )
333 inline DVector3& operator /= (
const double fScalar )
335 assert( fScalar != 0.0f );
337 double fInv = 1.0f / fScalar;
365 return Math::Sqrt( x * x + y * y + z * z );
380 return x * x + y * y + z * z;
392 return (*
this - rhs).length();
407 return (*
this - rhs).squaredLength();
426 return x * vec.x + y * vec.y + z * vec.z;
441 return Math::Abs(x * vec.x) + Math::Abs(y * vec.y) + Math::Abs(z * vec.z);
455 double fLength = Math::Sqrt( x * x + y * y + z * z );
458 if ( fLength > 1e-08 )
460 double fInvLength = 1.0f / fLength;
500 y * rkVector.z - z * rkVector.y,
501 z * rkVector.x - x * rkVector.z,
502 x * rkVector.y - y * rkVector.x);
511 ( x + vec.x ) * 0.5f,
512 ( y + vec.y ) * 0.5f,
513 ( z + vec.z ) * 0.5f );
521 if( x < rhs.x && y < rhs.y && z < rhs.z )
531 if( x > rhs.x && y > rhs.y && z > rhs.z )
545 if( cmp.x < x ) x = cmp.x;
546 if( cmp.y < y ) y = cmp.y;
547 if( cmp.z < z ) z = cmp.z;
559 if( cmp.x > x ) x = cmp.x;
560 if( cmp.y > y ) y = cmp.y;
561 if( cmp.z > z ) z = cmp.z;
567 double sqlen = (x * x) + (y * y) + (z * z);
568 return (sqlen < (1e-06 * 1e-06));
622 const Radian& tolerance)
const 625 Radian angle = Math::ACos((
float)dot);
627 return Math::Abs(angle.valueRadians()) <= tolerance.valueRadians();
632 inline friend std::ostream&
operator <<
635 o <<
"DVector3(" << v.x <<
", " << v.y <<
", " << v.z <<
")";
double normalise()
Normalises the vector.
Definition: ParaDVector3.h:453
Wrapper class which indicates a given angle value is in Radians.
Definition: ParaAngle.h:10
DVector3 operator%(const DVector3 &rhs) const
special cross product
Definition: ParaDVector3.h:172
void makeCeil(const DVector3 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
Definition: ParaDVector3.h:557
3-dimensional vector with double precision.
Definition: ParaDVector3.h:17
bool positionEquals(const Vector3 &rhs, float tolerance=1e-03) const
Returns whether this vector is within a positional tolerance of another floating precision vector...
Definition: ParaDVector3.h:595
double squaredDistance(const DVector3 &rhs) const
Returns the square of the distance to another vector.
Definition: ParaDVector3.h:405
double length() const
Returns the length (magnitude) of the vector.
Definition: ParaDVector3.h:363
bool isZeroLength(void) const
Returns true if this vector is zero length.
Definition: ParaDVector3.h:565
different physics engine has different winding order.
Definition: EventBinding.h:32
double * ptr()
Pointer accessor for direct copying.
Definition: ParaDVector3.h:73
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
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
bool operator<(const DVector3 &rhs) const
Returns true if the vector's scalar components are all greater that the ones of the vector it is comp...
Definition: ParaDVector3.h:519
DVector3 & operator=(const DVector3 &rkVector)
Assigns the value of the other vector.
Definition: ParaDVector3.h:95
const double * ptr() const
Pointer accessor for direct copying.
Definition: ParaDVector3.h:78
bool positionCloses(const DVector3 &rhs, float tolerance=1e-03f) const
Returns whether this vector is within a positional tolerance of another vector, also take scale of th...
Definition: ParaDVector3.h:608
double distance(const DVector3 &rhs) const
Returns the distance to another vector.
Definition: ParaDVector3.h:390
double dotProduct(const DVector3 &vec) const
Calculates the dot (scalar) product of this vector with another.
Definition: ParaDVector3.h:424
void makeFloor(const DVector3 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector...
Definition: ParaDVector3.h:543
DVector3 midPoint(const DVector3 &vec) const
Returns a vector at a point half way between this and the passed in vector.
Definition: ParaDVector3.h:508
bool directionEquals(const DVector3 &rhs, const Radian &tolerance) const
Returns whether this vector is within a directional tolerance of another vector.
Definition: ParaDVector3.h:621
DVector3 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalized vector is returned as a copy...
Definition: ParaDVector3.h:574
DVector3 reflect(const DVector3 &normal) const
Calculates a reflection vector to the plane with the given normal .
Definition: ParaDVector3.h:584
bool operator>(const DVector3 &rhs) const
Returns true if the vector's scalar components are all smaller that the ones of the vector it is comp...
Definition: ParaDVector3.h:529
DVector3 crossProduct(const DVector3 &rkVector) const
Calculates the cross-product of 2 vectors, i.e.
Definition: ParaDVector3.h:497
double squaredLength() const
Returns the square of the length(magnitude) of the vector.
Definition: ParaDVector3.h:378
double absDotProduct(const DVector3 &vec) const
Calculates the absolute dot (scalar) product of this vector with another.
Definition: ParaDVector3.h:439