66 : x(
fX ), y(
fY ), z(
fZ )
85 : x( r[0] ), y( r[1] ), z( r[2] )
358 return Math::Sqrt( x * x + y * y + z * z );
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;
434 return Math::Abs(x *
vec.x) + Math::Abs(y *
vec.y) + Math::Abs(z *
vec.z);
448 Real fLength = Math::Sqrt( x * x + y * y + z * z );
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 )
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;
570 Vector3 perp = this->crossProduct( Vector3::UNIT_X );
578 perp = this->crossProduct( Vector3::UNIT_Y );
605 const Vector3&
up = Vector3::ZERO )
const
609 if (
up == Vector3::ZERO)
612 newUp = this->perpendicular();
621 q.FromAngleAxis(
Radian(Math::UnitRandom() * Math::TWO_PI), *
this );
644 return Math::ACos(
f);
666 Real d =
v0.dotProduct(v1);
670 return Quaternion::IDENTITY;
672 if (d < (1e-6f - 1.0f))
682 Vector3 axis = Vector3::UNIT_X.crossProduct(*
this);
683 if (
axis.isZeroLength())
684 axis = Vector3::UNIT_Y.crossProduct(*
this);
691 Real s = Math::Sqrt( (1+d)*2 );
708 Real sqlen = (x * x) + (y * y) + (z * z);
709 return (
sqlen < (1
e-06 * 1
e-06));
727 return Vector3( *
this - ( 2 * this->dotProduct(normal) * normal ) );
752 return squaredDistance(
rhs) <=
769 return Math::Abs(
angle.valueRadians()) <=
tolerance.valueRadians();
776 return Math::isNaN(x) || Math::isNaN(y) || Math::isNaN(z);
787 return x > 0 ? Vector3::UNIT_X : Vector3::NEGATIVE_UNIT_X;
789 return z > 0 ? Vector3::UNIT_Z : Vector3::NEGATIVE_UNIT_Z;
792 return y > 0 ? Vector3::UNIT_Y : Vector3::NEGATIVE_UNIT_Y;
794 return z > 0 ? Vector3::UNIT_Z : Vector3::NEGATIVE_UNIT_Z;
812 ( std::ostream&
o,
const Vector3& v )
814 o <<
"Vector3(" << v.x <<
", " << v.y <<
", " << v.z <<
")";
Implementation of a Quaternion, i.e.
Wrapper class which indicates a given angle value is in Radians.
Reference-counted shared pointer, used for objects where implicit destruction is required.
Standard 3-dimensional vector.
bool isNaN() const
Check whether this vector contains valid values.
static const Vector3 UNIT_X
bool directionEquals(const Vector3 &rhs, const Radian &tolerance) const
Returns whether this vector is within a directional tolerance of 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 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 midPoint(const Vector3 &vec) const
Returns a vector at a point half way between this and the passed in vector.
Real squaredLength() const
Returns the square of the length(magnitude) of the vector.
Vector3 primaryAxis() const
Extract the primary (dominant) axis from this direction vector.
Vector3 normalisedCopy(void) const
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy.
static const Vector3 NEGATIVE_UNIT_X
Real distance(const Vector3 &rhs) const
Returns the distance to another vector.
Real absDotProduct(const Vector3 &vec) const
Calculates the absolute dot (scalar) product of this vector with another.
static const Vector3 ZERO
Vector3 perpendicular(void) const
Generates a vector perpendicular to this vector (eg an 'up' 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.
Vector3(const Real fX, const Real fY, const Real fZ)
static const Vector3 UNIT_SCALE
static const Vector3 NEGATIVE_UNIT_Y
bool isZeroLength(void) const
Returns true if this vector is zero length.
void makeFloor(const Vector3 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector.
Real length() const
Returns the length (magnitude) of the vector.
Vector3(const Real scaler)
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 const Vector3 UNIT_Y
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 normalise()
Normalises the vector.
Radian angleBetween(const Vector3 &dest) const
Gets the angle between 2 vectors.
const Real * ptr() const
Pointer accessor for direct copying.
Vector3 reflect(const Vector3 &normal) const
Calculates a reflection vector to the plane with the given normal .
Vector3()
Default constructor.
static const Vector3 NEGATIVE_UNIT_Z
Vector3(const int afCoordinate[3])
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...
Real * ptr()
Pointer accessor for direct copying.
static const Vector3 UNIT_Z
Real dotProduct(const Vector3 &vec) const
Calculates the dot (scalar) product of this vector with another.
Real squaredDistance(const Vector3 &rhs) const
Returns the square of the distance to another vector.
Vector3(const Real afCoordinate[3])
float Real
Software floating point type.
void swap(Ogre::SmallVectorImpl< T > &LHS, Ogre::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.