Defined in include/foundation/Px.h

template<class Type>
class PxQuatT

This is a quaternion class.

For more information on quaternion mathematics consult a mathematics source on complex numbers.

Public Functions

inline PxQuatT()

Default constructor, does not do any initialization.

inline PxQuatT(PxIDENTITY)

identity constructor

inline explicit PxQuatT(Type r)

Constructor from a scalar: sets the real part w to the scalar value, and the imaginary parts (x,y,z) to zero.

inline PxQuatT(Type nx, Type ny, Type nz, Type nw)


Take note of the order of the elements!

inline PxQuatT(Type angleRadians, const PxVec3T<Type> &unitAxis)

Creates from angle-axis representation.

Axis must be normalized!

Angle is in radians!

Unit: Radians

inline PxQuatT(const PxQuatT &v)

Copy ctor.

inline explicit PxQuatT(const PxMat33T<Type> &m)

Creates from orientation matrix.


m[in] Rotation matrix to extract quaternion from.

inline bool isIdentity() const

returns true if quat is identity

inline bool isFinite() const

returns true if all elements are finite (not NAN or INF, etc.)

inline bool isUnit() const

returns true if finite and magnitude is close to unit

inline bool isSane() const

returns true if finite and magnitude is reasonably close to unit to allow for some accumulation of error vs isValid

inline bool operator==(const PxQuatT &q) const

returns true if the two quaternions are exactly equal

inline void toRadiansAndUnitAxis(Type &angle, PxVec3T<Type> &axis) const

converts this quaternion to angle-axis representation

inline Type getAngle() const

Gets the angle between this quat and the identity quaternion.

Unit: Radians

inline Type getAngle(const PxQuatT &q) const

Gets the angle between this quat and the argument.

Unit: Radians

inline Type magnitudeSquared() const

This is the squared 4D vector length, should be 1 for unit quaternions.

inline Type dot(const PxQuatT &v) const

returns the scalar product of this and other.

inline PxQuatT getNormalized() const
inline Type magnitude() const
inline Type normalize()

maps to the closest unit quaternion.

inline PxQuatT getConjugate() const
inline PxVec3T<Type> getImaginaryPart() const
inline PxVec3T<Type> getBasisVector0() const

brief computes rotation of x-axis

inline PxVec3T<Type> getBasisVector1() const

brief computes rotation of y-axis

inline PxVec3T<Type> getBasisVector2() const

brief computes rotation of z-axis

inline const PxVec3T<Type> rotate(const PxVec3T<Type> &v) const

rotates passed vec by this (assumed unitary)

inline const PxVec3T<Type> rotateInv(const PxVec3T<Type> &v) const

inverse rotates passed vec by this (assumed unitary)

inline PxQuatT &operator=(const PxQuatT &p)

Assignment operator.

inline PxQuatT &operator*=(const PxQuatT &q)
inline PxQuatT &operator+=(const PxQuatT &q)
inline PxQuatT &operator-=(const PxQuatT &q)
inline PxQuatT &operator*=(const Type s)
inline PxQuatT operator*(const PxQuatT &q) const

quaternion multiplication

inline PxQuatT operator+(const PxQuatT &q) const

quaternion addition

inline PxQuatT operator-() const

quaternion subtraction

inline PxQuatT operator-(const PxQuatT &q) const
inline PxQuatT operator*(Type r) const

Public Members

Type x

the quaternion elements

Type y
Type z
Type w