Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Quaternion

Quaternion types and operations. More...

Classes

struct  Crux::Quat< T >
 Templated quaternion representation. More...

Functions

template<typename T>
constexpr T Crux::QuatDot (const Quat< T > &quatA, const Quat< T > &quatB) noexcept
 Compute the dot product of two quaternions.
template<typename T>
constexpr T Crux::QuatLengthSq (const Quat< T > &quat) noexcept
 Compute squared length (norm) of a quaternion.
template<typename T>
Crux::QuatLength (const Quat< T > &quat) noexcept
 Compute Euclidean length (norm) of a quaternion.
template<typename T>
constexpr T Crux::QuatLengthCT (const Quat< T > &quat) noexcept
 Compute Euclidean length (norm) of a quaternion (compile-time version).
template<typename T>
constexpr Quat< T > Crux::QuatConjugate (const Quat< T > &quat) noexcept
 Compute the conjugate of a quaternion.
template<typename T>
constexpr Quat< T > Crux::QuatInverse (const Quat< T > &quat) noexcept
 Compute the multiplicative inverse of a quaternion.
template<typename T>
Crux::QuatNormalizeInplace (Quat< T > &quat) noexcept
 Normalize quaternion in-place.
template<typename T>
Quat< T > Crux::QuatNormalize (Quat< T > quat) noexcept
 Return normalized copy of quaternion.
template<typename T>
constexpr Quat< T > Crux::QuatMul (const Quat< T > &quatA, const Quat< T > &quatB) noexcept
 Hamilton product of two quaternions (composition of rotations).
template<typename T>
constexpr Vector< T, 3 > Crux::QuatRotate (const Quat< T > &quat, const Vector< T, 3 > &vec) noexcept
 Rotate a 3D vector by a quaternion (optimized form).
template<typename T>
Quat< T > Crux::QuatFromAxisAngle (const Vector< T, 3 > &axis, T angleRadians) noexcept
 Construct quaternion from axis-angle representation.
template<typename T>
void Crux::QuatToAxisAngle (const Quat< T > &quat, Vector< T, 3 > &outAxis, T &outAngle) noexcept
 Decompose quaternion into axis-angle representation.
template<typename T>
Quat< T > Crux::QuatFromEuler (T roll, T pitch, T yaw) noexcept
 Construct quaternion from Euler angles (roll, pitch, yaw).
template<typename T>
void Crux::QuatToEuler (const Quat< T > &quat, T &outRoll, T &outPitch, T &outYaw) noexcept
 Convert quaternion to Euler angles (roll, pitch, yaw).
template<typename T>
Quat< T > Crux::QuatLerp (const Quat< T > &quatA, const Quat< T > &quatB, T t) noexcept
 Linear interpolation (LERP) between two quaternions.
template<typename T>
Quat< T > Crux::QuatNlerp (const Quat< T > &quatA, const Quat< T > &quatB, T t) noexcept
 Normalized linear interpolation (NLERP) between two quaternions.
template<typename T>
Quat< T > Crux::QuatSlerp (const Quat< T > &quatA, const Quat< T > &quatB, T t) noexcept
 Spherical linear interpolation (SLERP) between two quaternions.
template<typename T>
Matrix< T, 3, 3 > Crux::QuatToMat3 (const Quat< T > &quatIn) noexcept
 Convert quaternion to 3x3 rotation matrix (row-major).
template<typename T>
Matrix< T, 4, 4 > Crux::ToMat4 (const Quat< T > &quat) noexcept
 Convert quaternion to 4x4 rotation matrix.
template<typename T>
Quat< T > Crux::QuatFromMat3 (const Matrix< T, 3, 3 > &mat) noexcept
 Convert a 3x3 rotation matrix to a quaternion.
template<typename T>
Quat< T > Crux::operator* (const Quat< T > &a, const Quat< T > &b) noexcept
 Quaternion multiplication operator (Hamilton product).
template<typename T>
Quat< T > Crux::operator* (T s, const Quat< T > &q) noexcept
 Scalar * quaternion multiplication (commutative for scalar).

Detailed Description

Quaternion types and operations.

Contains quaternion definitions, transformations, and related algorithms.

Function Documentation

◆ operator*() [1/2]

template<typename T>
Quat< T > Crux::operator* ( const Quat< T > & a,
const Quat< T > & b )
inlinenoexcept

Quaternion multiplication operator (Hamilton product).

Template Parameters
TScalar type.
Parameters
aLeft quaternion operand.
bRight quaternion operand.
Returns
Quat<T> Product quaternion.

Equivalent to QuatMul(a, b). See QuatMul for detailed documentation.

◆ operator*() [2/2]

template<typename T>
Quat< T > Crux::operator* ( T s,
const Quat< T > & q )
inlinenoexcept

Scalar * quaternion multiplication (commutative for scalar).

Template Parameters
TScalar type.
Parameters
sScalar value.
qQuaternion.
Returns
Quat<T> Scaled quaternion.

Scales all components of the quaternion by the scalar:

\[s \cdot q = (sx, sy, sz, sw) \]

This operation is commutative: \(s \cdot q = q \cdot s\).

◆ QuatConjugate()

template<typename T>
Quat< T > Crux::QuatConjugate ( const Quat< T > & quat)
constexprnoexcept

Compute the conjugate of a quaternion.

Template Parameters
TScalar type.
Parameters
quatInput quaternion.
Returns
Quat<T> Conjugate quaternion.

For quaternion \(q = (x, y, z, w)\) with vector part \(\vec{v} = (x, y, z)\) and scalar part \(w\), the conjugate is defined as:

\[q^* = (-\vec{v}, w) = (-x, -y, -z, w) \]

The conjugate represents the inverse rotation of a unit quaternion: \(q \otimes q^* = q^* \otimes q = (0, 0, 0, 1)\) for unit quaternions.

Note
For unit quaternions, the conjugate equals the inverse: \(q^{-1} = q^*\).

◆ QuatDot()

template<typename T>
T Crux::QuatDot ( const Quat< T > & quatA,
const Quat< T > & quatB )
constexprnoexcept

Compute the dot product of two quaternions.

Template Parameters
TScalar type.
Parameters
quatAFirst quaternion.
quatBSecond quaternion.
Returns
T The scalar dot product.

For quaternions \(a = (x_a, y_a, z_a, w_a)\) and \(b = (x_b, y_b, z_b, w_b)\), the dot product is defined as:

\[a \cdot b = x_a x_b + y_a y_b + z_a z_b + w_a w_b \]

This operation is commutative and is used to measure the angular similarity between two quaternions.

◆ QuatFromAxisAngle()

template<typename T>
Quat< T > Crux::QuatFromAxisAngle ( const Vector< T, 3 > & axis,
T angleRadians )
inlinenoexcept

Construct quaternion from axis-angle representation.

Template Parameters
TScalar type.
Parameters
axisRotation axis (should be normalized).
angleRadiansRotation angle in radians.
Returns
Quat<T> Quaternion representing rotation of angleRadians about axis.

Constructs a quaternion from axis-angle form using:

\[q = \left(\vec{a} \sin\frac{\theta}{2}, \cos\frac{\theta}{2}\right) \]

where \(\vec{a}\) is the rotation axis and \(\theta\) is the rotation angle.

This representation is unique up to sign (both \(q\) and \(-q\) represent the same rotation).

Precondition
axis should be normalized. If axis is not normalized, the result will represent a rotation scaled by the axis magnitude. It is recommended to pass a normalized axis (Crux::Normalized(axis)).

◆ QuatFromEuler()

template<typename T>
Quat< T > Crux::QuatFromEuler ( T roll,
T pitch,
T yaw )
inlinenoexcept

Construct quaternion from Euler angles (roll, pitch, yaw).

Template Parameters
TScalar type.
Parameters
rollRotation about X-axis in radians.
pitchRotation about Y-axis in radians.
yawRotation about Z-axis in radians.
Returns
Quat<T> Quaternion representing yaw * pitch * roll composition.

Constructs a quaternion from Euler angles using the ZYX convention:

\[q = q_z(\text{yaw}) \otimes q_y(\text{pitch}) \otimes q_x(\text{roll}) \]

where individual axis quaternions are:

\[\begin{align*} q_x(\alpha) &= \left(\sin\frac{\alpha}{2}, 0, 0, \cos\frac{\alpha}{2}\right) \\ q_y(\beta) &= \left(0, \sin\frac{\beta}{2}, 0, \cos\frac{\beta}{2}\right) \\ q_z(\gamma) &= \left(0, 0, \sin\frac{\gamma}{2}, \cos\frac{\gamma}{2}\right) \end{align*} \]

The implementation uses the expanded half-angle formula:

\[\begin{align*} w &= c_r c_p c_y + s_r s_p s_y \\ x &= s_r c_p c_y - c_r s_p s_y \\ y &= c_r s_p c_y + s_r c_p s_y \\ z &= c_r c_p s_y - s_r s_p c_y \end{align*} \]

where \(s_r = \sin(\text{roll}/2)\), \(c_r = \cos(\text{roll}/2)\), etc.

Note
This convention applies rotations in the order: roll (X), then pitch (Y), then yaw (Z). Different applications may use different Euler angle conventions.

◆ QuatFromMat3()

template<typename T>
Quat< T > Crux::QuatFromMat3 ( const Matrix< T, 3, 3 > & mat)
inlinenoexcept

Convert a 3x3 rotation matrix to a quaternion.

Template Parameters
TScalar type.
Parameters
matInput 3x3 rotation matrix (row-major).
Returns
Quat<T> Quaternion representing the same rotation.

Converts an orthonormal rotation matrix to a quaternion using a numerically stable algorithm that avoids division by small numbers:

Given a rotation matrix:

\[R = \begin{pmatrix} m_{00} & m_{01} & m_{02} \\ m_{10} & m_{11} & m_{12} \\ m_{20} & m_{21} & m_{22} \end{pmatrix} \]

The algorithm selects the largest diagonal element to maximize numerical stability:

  • If \(w\) is largest: \(w = \sqrt{1 + m_{00} + m_{11} + m_{22}} / 2\)
  • If \(x\) is largest: \(x = \sqrt{1 + m_{00} - m_{11} - m_{22}} / 2\)
  • If \(y\) is largest: \(y = \sqrt{1 + m_{11} - m_{00} - m_{22}} / 2\)
  • If \(z\) is largest: \(z = \sqrt{1 + m_{22} - m_{00} - m_{11}} / 2\)

The remaining components are computed using matrix relationships:

\[\begin{align*} x &= \frac{m_{21} - m_{12}}{4w} \quad \text{(when w is largest)} \\ y &= \frac{m_{02} - m_{20}}{4w} \\ z &= \frac{m_{10} - m_{01}}{4w} \end{align*} \]

Precondition
The input matrix should be orthonormal (i.e., a valid rotation matrix). Non-orthonormal matrices may produce unexpected results.

◆ QuatInverse()

template<typename T>
Quat< T > Crux::QuatInverse ( const Quat< T > & quat)
constexprnoexcept

Compute the multiplicative inverse of a quaternion.

Template Parameters
TScalar type.
Parameters
quatInput quaternion.
Returns
Quat<T> Inverse quaternion.

For quaternion \(q\), the multiplicative inverse is defined as:

\[q^{-1} = \frac{q^*}{\|q\|^2} \]

where \(q^*\) is the conjugate and \(\|q\|^2\) is the squared length.

The inverse satisfies: \(q \otimes q^{-1} = q^{-1} \otimes q = (0, 0, 0, 1)\).

Note
If the input quaternion has zero length, the function returns the identity quaternion \((0, 0, 0, 1)\) to avoid division-by-zero. For unit quaternions, prefer QuatConjugate for better performance.

◆ QuatLength()

template<typename T>
T Crux::QuatLength ( const Quat< T > & quat)
inlinenoexcept

Compute Euclidean length (norm) of a quaternion.

Template Parameters
TScalar type.
Parameters
quatQuaternion to measure.
Returns
T Euclidean norm.

For quaternion \(q = (x, y, z, w)\), the length is defined as:

\[\|q\| = \sqrt{x^2 + y^2 + z^2 + w^2} = \sqrt{q \cdot q} \]

Note
Uses Crux::Sqrt. For compile-time evaluation use QuatLengthCT.

◆ QuatLengthCT()

template<typename T>
T Crux::QuatLengthCT ( const Quat< T > & quat)
constexprnoexcept

Compute Euclidean length (norm) of a quaternion (compile-time version).

Template Parameters
TScalar type.
Parameters
quatQuaternion to measure.
Returns
T Euclidean norm.

For quaternion \(q = (x, y, z, w)\), the length is defined as:

\[\|q\| = \sqrt{x^2 + y^2 + z^2 + w^2} = \sqrt{q \cdot q} \]

Note
Uses Crux::CTSqrt for compile-time evaluation.

◆ QuatLengthSq()

template<typename T>
T Crux::QuatLengthSq ( const Quat< T > & quat)
constexprnoexcept

Compute squared length (norm) of a quaternion.

Template Parameters
TScalar type.
Parameters
quatQuaternion to measure.
Returns
T Squared length.

For quaternion \(q = (x, y, z, w)\), the squared length is defined as:

\[\|q\|^2 = q \cdot q = x^2 + y^2 + z^2 + w^2 \]

This operation is more efficient than computing the actual length since it avoids the square root computation.

◆ QuatLerp()

template<typename T>
Quat< T > Crux::QuatLerp ( const Quat< T > & quatA,
const Quat< T > & quatB,
T t )
inlinenoexcept

Linear interpolation (LERP) between two quaternions.

Template Parameters
TScalar type.
Parameters
quatAStart quaternion.
quatBEnd quaternion.
tInterpolation parameter in [0,1].
Returns
Quat<T> Component-wise linear interpolation.

Performs component-wise linear interpolation:

\[q(t) = (1-t)a + tb = a + t(b - a) \]

Component-wise this yields:

\[\begin{align*} x(t) &= x_a + t(x_b - x_a) \\ y(t) &= y_a + t(y_b - y_a) \\ z(t) &= z_a + t(z_b - z_a) \\ w(t) &= w_a + t(w_b - w_a) \end{align*} \]

Note
The result is not necessarily normalized. For rotation interpolation, normalize the result (NLERP): \(\hat{q}(t) = \frac{q(t)}{\|q(t)\|}\). NLERP provides faster but non-constant-velocity interpolation compared to SLERP.

◆ QuatMul()

template<typename T>
Quat< T > Crux::QuatMul ( const Quat< T > & quatA,
const Quat< T > & quatB )
constexprnoexcept

Hamilton product of two quaternions (composition of rotations).

Template Parameters
TScalar type.
Parameters
quatALeft quaternion operand.
quatBRight quaternion operand.
Returns
Quat<T> Product quaternion representing rotation quatB followed by quatA.

For scalar-last quaternions \(q = (x, y, z, w)\) with vector part \(\vec{v}=(x, y, z)\) and scalar \(w\), the Hamilton product is defined as:

\[q = a \otimes b = \Bigl( \vec{v}_a \times \vec{v}_b + w_a \vec{v}_b + w_b \vec{v}_a,\; w_a w_b - \vec{v}_a \cdot \vec{v}_b \Bigr) \]

where:

  • \(\vec{v}_a, \vec{v}_b\) are the vector parts of quatA and quatB.
  • \(w_a, w_b\) are the scalar parts of quatA and quatB.

This operation is non-commutative: the order of operands affects the resulting rotation.

Note
Prefer unit quaternions for rotation composition to avoid scaling artifacts.

◆ QuatNlerp()

template<typename T>
Quat< T > Crux::QuatNlerp ( const Quat< T > & quatA,
const Quat< T > & quatB,
T t )
inlinenoexcept

Normalized linear interpolation (NLERP) between two quaternions.

Template Parameters
TScalar type.
Parameters
quatAStart quaternion.
quatBEnd quaternion.
tInterpolation parameter in [0,1].
Returns
Quat<T> Normalized interpolated quaternion (unit-length).

NLERP performs linear interpolation followed by normalization:

\[\text{nlerp}(a, b, t) = \frac{(1-t)a + tb}{\|(1-t)a + tb\|} = \frac{a + t(b - a)}{\|a + t(b - a)\|} \]

This provides a faster alternative to SLERP with the following trade-offs:

  • Pros: Significantly faster than SLERP (no trigonometric functions)
  • Cons: Non-constant angular velocity (speeds up in the middle)

The implementation automatically handles the sign ambiguity by choosing the shorter arc: if \(a \cdot b < 0\), it negates \(b\) to ensure the interpolation takes the shorter path on the quaternion hypersphere.

For small rotation angles, NLERP is nearly indistinguishable from SLERP but much more efficient. The velocity variation becomes noticeable only for large rotation angles (> 90 degrees).

Note
The result is always normalized to unit length, making it suitable for rotation interpolation. For applications requiring constant angular velocity, use QuatSlerp instead.

◆ QuatNormalize()

template<typename T>
Quat< T > Crux::QuatNormalize ( Quat< T > quat)
inlinenoexcept

Return normalized copy of quaternion.

Template Parameters
TScalar type.
Parameters
quatQuaternion to normalize (copied).
Returns
Quat<T> Normalized quaternion (unit-length).

Returns a unit-length quaternion:

\[\hat{q} = \frac{q}{\|q\|} \]

Note
This function creates a copy and normalizes it, leaving the input unchanged. If the quaternion has zero length, returns the identity quaternion \((0, 0, 0, 1)\).

◆ QuatNormalizeInplace()

template<typename T>
T Crux::QuatNormalizeInplace ( Quat< T > & quat)
inlinenoexcept

Normalize quaternion in-place.

Template Parameters
TScalar type.
Parameters
quatQuaternion to normalize (modified in-place).
Returns
T The previous length of the quaternion before normalization.

Normalizes the quaternion to unit length:

\[\hat{q} = \frac{q}{\|q\|} = \frac{(x, y, z, w)}{\sqrt{x^2 + y^2 + z^2 + w^2}} \]

A unit quaternion satisfies \(\|\hat{q}\| = 1\) and represents a pure rotation without scaling.

Note
If the quaternion has zero length, it is reset to the identity quaternion \((0, 0, 0, 1)\) and zero is returned. This design choice avoids NaNs in subsequent operations.

◆ QuatRotate()

template<typename T>
Vector< T, 3 > Crux::QuatRotate ( const Quat< T > & quat,
const Vector< T, 3 > & vec )
constexprnoexcept

Rotate a 3D vector by a quaternion (optimized form).

Template Parameters
TScalar type.
Parameters
quatQuaternion describing rotation. Ideally quat is unit-length.
vecVector to be rotated.
Returns
Vector<T,3> Rotated vector.

Applies quaternion rotation to a 3D vector using the optimized formula:

\[\vec{v}' = \vec{v} + 2w(\vec{q} \times \vec{v}) + 2(\vec{q} \times (\vec{q} \times \vec{v})) \]

where \(\vec{q} = (x, y, z)\) is the vector part and \(w\) is the scalar part.

This is mathematically equivalent to the sandwich product \(q \otimes (0, \vec{v}) \otimes q^{-1}\) but more efficient as it avoids constructing temporary quaternions.

Implementation uses the rearranged form:

\[\begin{align*} \vec{t} &= 2(\vec{q} \times \vec{v}) \\ \vec{v}' &= \vec{v} + w\vec{t} + \vec{q} \times \vec{t} \end{align*} \]

Precondition
Prefer normalized quat for semantic correctness and numerical stability. Non-unit quaternions will scale the result.

◆ QuatSlerp()

template<typename T>
Quat< T > Crux::QuatSlerp ( const Quat< T > & quatA,
const Quat< T > & quatB,
T t )
inlinenoexcept

Spherical linear interpolation (SLERP) between two quaternions.

Template Parameters
TScalar type.
Parameters
quatAStart quaternion.
quatBEnd quaternion.
tInterpolation parameter in [0,1].
Returns
Quat<T> Interpolated quaternion (unit-length when inputs are unit-length).

SLERP provides constant-angular-velocity interpolation along the shortest great-circle arc on the 4D unit hypersphere:

\[\text{slerp}(a, b, t) = \frac{\sin((1-t)\theta)}{\sin\theta}a + \frac{\sin(t\theta)}{\sin\theta}b \]

where \(\theta = \arccos(a \cdot b)\) is the angle between quaternions.

The implementation handles several special cases:

  • If \(a \cdot b < 0\), negates \(b\) to take the shorter arc
  • If \(\cos\theta \approx 1\) (quaternions are nearly parallel), falls back to normalized LERP to avoid numerical instability

The interpolated quaternion is:

\[q(t) = \frac{w_a \cdot a + w_b \cdot b}{\|w_a \cdot a + w_b \cdot b\|} \]

where:

\[\begin{align*} w_a &= \frac{\sin((1-t)\theta)}{\sin\theta} \\ w_b &= \frac{\sin(t\theta)}{\sin\theta} \end{align*} \]

Note
SLERP produces smooth, constant-velocity rotation but is more expensive than NLERP. For small angles, NLERP is often sufficient and faster.

◆ QuatToAxisAngle()

template<typename T>
void Crux::QuatToAxisAngle ( const Quat< T > & quat,
Vector< T, 3 > & outAxis,
T & outAngle )
inlinenoexcept

Decompose quaternion into axis-angle representation.

Template Parameters
TScalar type.
Parameters
quatInput quaternion (not necessarily normalized).
outAxisOutput axis (normalized when angle != 0).
outAngleOutput angle in radians.

Extracts the axis-angle representation from a quaternion:

\[\begin{align*} \theta &= 2\arccos(w) \\ \vec{a} &= \frac{(x, y, z)}{\sin(\theta/2)} = \frac{(x, y, z)}{\sqrt{1 - w^2}} \end{align*} \]

If the rotation angle is approximately zero (identity rotation), the axis is set to \((1, 0, 0)\) arbitrarily since all axes represent the same identity rotation.

Note
The function normalizes the input quaternion internally before decomposition. The output angle is in the range \([0, 2\pi]\).

◆ QuatToEuler()

template<typename T>
void Crux::QuatToEuler ( const Quat< T > & quat,
T & outRoll,
T & outPitch,
T & outYaw )
inlinenoexcept

Convert quaternion to Euler angles (roll, pitch, yaw).

Template Parameters
TScalar type.
Parameters
quatInput quaternion.
outRollOutput roll angle (X axis) in radians.
outPitchOutput pitch angle (Y axis) in radians.
outYawOutput yaw angle (Z axis) in radians.

Extracts Euler angles from a quaternion using the ZYX convention:

\[\begin{align*} \text{roll} &= \arctan2(2(wx + yz), 1 - 2(x^2 + y^2)) \\ \text{pitch} &= \arcsin(2(wy - zx)) \\ \text{yaw} &= \arctan2(2(wz + xy), 1 - 2(y^2 + z^2)) \end{align*} \]

The conversion handles gimbal lock by clamping the pitch sine value:

  • If \(\sin(\text{pitch}) \geq 1\), pitch is set to \(\pi/2\)
  • If \(\sin(\text{pitch}) \leq -1\), pitch is set to \(-\pi/2\)
Note
The conversion assumes the quaternion was created with the same (roll, pitch, yaw) convention used by QuatFromEuler (i.e., yaw * pitch * roll). Results are in the principal ranges of the respective trigonometric inverse functions:
  • Roll: \((-\pi, \pi]\)
  • Pitch: \([-\pi/2, \pi/2]\)
  • Yaw: \((-\pi, \pi]\)
Precondition
The input quaternion should be normalized for accurate results.

◆ QuatToMat3()

template<typename T>
Matrix< T, 3, 3 > Crux::QuatToMat3 ( const Quat< T > & quatIn)
inlinenoexcept

Convert quaternion to 3x3 rotation matrix (row-major).

Template Parameters
TScalar type.
Parameters
quatInInput quaternion.
Returns
Matrix<T,3,3> 3x3 rotation matrix corresponding to the quaternion rotation.

Converts a unit quaternion \(q = (x, y, z, w)\) to a 3×3 rotation matrix:

\[R = \begin{pmatrix} 1 - 2(y^2 + z^2) & 2(xy - wz) & 2(xz + wy) \\ 2(xy + wz) & 1 - 2(x^2 + z^2) & 2(yz - wx) \\ 2(xz - wy) & 2(yz + wx) & 1 - 2(x^2 + y^2) \end{pmatrix} \]

This matrix represents the same rotation as the quaternion and can be used to transform vectors: \(\vec{v}' = R\vec{v}\).

The conversion is derived from the quaternion rotation formula and produces an orthonormal matrix (i.e., \(R^T R = I\) and \(\det(R) = 1\)) when the input quaternion is normalized.

Note
If quatIn is not normalized, the function normalizes a copy internally to produce a valid orthonormal rotation matrix. For optimal performance, ensure the input is already normalized.

◆ ToMat4()

template<typename T>
Matrix< T, 4, 4 > Crux::ToMat4 ( const Quat< T > & quat)
inlinenoexcept

Convert quaternion to 4x4 rotation matrix.

Template Parameters
TScalar type.
Parameters
quatInput quaternion.
Returns
Matrix<T,4,4> 4x4 rotation matrix.

Expands the 3x3 quaternion rotation matrix into homogeneous coordinates suitable for transform composition.