Template Class Quaternion¶
Defined in File Quaternion.hh
Class Documentation¶
-
template<typename
T
>
classQuaternion
¶
-
Quaternion class.
A quaternion is a quadruplet (A,B,C,D) of real numbers, which may be written as /c Q = A + Bi + Cj + Dk.
Public Functions
-
inline
Quaternion
()¶
-
build null quaternion
-
inline
Quaternion
(real_type A, real_type B, real_type C, real_type D)¶
-
build quaternion \( A + B \mathbf{i} + C \mathbf{j} + D \mathbf{k} \)
-
inline void
conj
()¶
-
Conjugates a quaternion \( Q = A + Bi + Cj + Dk \). The conjugate of \( Q \) is \( \overline{Q} = A - Bi - Cj - Dk \).
-
inline void
invert
()¶
-
Invert a quaternion \( Q = A + Bi + Cj + Dk \). The inverse of of \( Q \) is \( Q^{-1} = \frac{A - Bi - Cj - Dk}{A^2+B^2+C^2+D^2} \).
-
inline real_type
norm
() const¶
-
Computes the norm of a quaternion. The norm of \( Q \) is \( \sqrt{A^2+B^2+C^2+D^2} \).
-
inline void
rotate
(real_type const v[3], real_type w[3]) const¶
-
applies a quaternion rotation to a vector in 3D.
If \( Q \) is a unit quaternion that encodes a rotation of ANGLE radians about the vector AXIS, then for an arbitrary real vector \( V \) , the result \( W \) of the rotation on \( V \) can be written as:
\( W = Q * V * Conj(Q) \)
-
inline real_type
toAxis
(real_type axis[3]) const¶
-
Converts a rotation from quaternion to axis format in 3D.
A rotation quaternion Q has the form:
Q = A + Bi + Cj + Dk
where A, B, C and D are real numbers, and i, j, and k are to be regarded as symbolic constant basis vectors, similar to the role of the “i” in the representation of imaginary numbers.
A is the cosine of half of the angle of rotation. (B,C,D) is a vector pointing in the direction of the axis of rotation. Rotation multiplication and inversion can be carried out using this format and the usual rules for quaternion multiplication and inversion.
-
inline