Quaternion
Inherited: None
Description
Quaternions consist of a 3D rotation axis specified by the x, y, and z coordinates, and a w representing the rotation angle.
Public Methods
Quaternion () |
|
Quaternion (const Matrix3 & matrix) |
|
Quaternion (const Vector3 & euler) |
|
Quaternion (const Vector3 & axis, areal angle) |
|
Quaternion (areal x, areal y, areal z, areal w) |
|
void |
axisAngle (Vector3 & axis, areal & angle) |
areal |
dot (const Quaternion & quaternion) const |
bool |
equal (const Quaternion & quaternion) const |
euler () const |
|
inverse () const |
|
areal |
length () const |
void |
mix (const Quaternion & q0, const Quaternion & q1, areal t) |
areal |
normalize () |
areal |
sqrLength () const |
toMatrix () const |
|
bool |
operator!= (const Quaternion & quaternion) const |
operator* (areal factor) const |
|
operator* (const Quaternion & quaternion) const |
|
operator* (const Vector3 & vector) const |
|
operator*= (areal factor) |
|
operator/ (areal divisor) const |
|
operator/= (areal divisor) |
|
bool |
operator== (const Quaternion & quaternion) const |
areal |
operator[] (int i) |
areal |
operator[] (int i) const |
Static Methods
lookRotation (const Vector3 & forward, const Vector3 & up) |
Methods Description
Quaternion::Quaternion ()
Constructs an identity quaternion.
Quaternion::Quaternion (Matrix3 & matrix)
Constructs a quaternion by rotation matrix represented by Matrix3 matrix.
Quaternion::Quaternion (Vector3 & euler)
Constructs a quaternion by Euler angles represented by Vector3(pitch, yaw, roll) euler in rotation degrees.
Quaternion::Quaternion (Vector3 & axis, areal angle)
Constructs a quaternion with rotation axis and angle in rotation degrees.
Quaternion::Quaternion (areal x, areal y, areal z, areal w)
Constructs a quaternion w*ith values (x, *y, z, w).
void Quaternion::axisAngle (Vector3 & axis, areal & angle)
Retrives a quaternion as rotation axis and angle in rotation degrees.
areal Quaternion::dot (Quaternion & quaternion) const
Returns the dot-product of this quaternion and given quaternion.
bool Quaternion::equal (Quaternion & quaternion) const
Returns true if quaternion approximately equal.
Vector3 Quaternion::euler () const
Returns the Euler angles represented by Vector3(pitch, yaw, roll) in rotation degrees.
Quaternion Quaternion::inverse () const
Returns the inverse of this quaternion.
areal Quaternion::length () const
Returns the length of this quaternion.
See also sqrLength().
Quaternion Quaternion::lookRotation (Vector3 & forward, Vector3 & up)
Creates a rotation with the specified forward and up directions.
void Quaternion::mix (Quaternion & q0, Quaternion & q1, areal t)
Linear inerpolation between q0 and q1 with t factor.
areal Quaternion::normalize ()
Normalizes the currect quaternion in place. Returns length of prenormalized quaternion.
See also length().
areal Quaternion::sqrLength () const
Returns the squared length of this quaternion.
See also length().
Matrix3 Quaternion::toMatrix () const
Returns the rotation matrix for this quaternion.
bool Quaternion::operator!= (Quaternion & quaternion) const
Returns true if this quaternion is NOT equal to given quaternion; otherwise returns false. This operator uses an exact floating-point comparison.
Quaternion Quaternion::operator* (areal factor) const
Returns a copy of this quaternion, multiplied by the given factor.
See also operator*=().
Quaternion Quaternion::operator* (Quaternion & quaternion) const
Multiplies this quaternion and quaternion using quaternion multiplication. The result corresponds to applying both of the rotations specified by this quaternion and quaternion.
Rotates a vector vec with this quaternion to produce a new vector in 3D space.
Quaternion & Quaternion::operator*= (areal factor)
Multiplies this quaternion’s coordinates by the given factor, and returns a reference to this quaternion.
See also operator/=().
Quaternion Quaternion::operator/ (areal divisor) const
Returns a copy of this quaternion, divided by the given divisor.
See also operator/=().
Quaternion & Quaternion::operator/= (areal divisor)
Divides this quaternion’s coordinates by the given divisor, and returns a reference to this quaternion.
See also operator*=().
bool Quaternion::operator== (Quaternion & quaternion) const
Returns true if this quaternion is equal to given quaternion; otherwise returns false. This operator uses an exact floating-point comparison.
areal Quaternion::operator[] (int i)
Returns the component of the quaternion at i*ndex position *i as a modifiable reference. i must be a valid i*ndex position *i*n the quaternion (i.e., 0 <= *i < 4).
areal Quaternion::operator[] (int i) const
Returns the component of the quaternion at i*ndex position. *i must be a valid i*ndex position *i*n the quaternion (i.e., 0 <= *i < 4).