Struct
NumCosmoMathQuaternion
Description [src]
struct NcmQuaternion {
/* No available fields */
}
Quaternions algebra, three-vectors and mapping to matrix.
A quaternion is a four-dimensional vector that can be used to represent rotations in three-dimensional space. The three-dimensional space is represented by the three-dimensional subspace of the quaternions that have zero real part.
This object also implements three-dimensional vectors and the mapping of quaternions to rotation matrices.
The conjugate of a quaternion is the quaternion with the same real part and the imaginary part negated, that is, if $q = s + \vec{v}$, then the conjugate of $q$ is $q^\dagger = s - \vec{v}$.
The norm of a quaternion is the square root of the sum of the squares of its components. The norm of a quaternion is always a positive real number.
Constructors
ncm_quaternion_new_from_data
Creates a new NcmQuaternion from the given components.
See ncm_quaternion_set_from_data() for details.
Instance methods
ncm_quaternion_conjugate_q_mul
Computes the product of two NcmQuaternion and stores the result in res.
The first NcmQuaternion is conjugated before the multiplication.
That is, $r = q^\dagger u$ where $q$ and $u$ are q and u, respectively, and $r$ is res.
ncm_quaternion_conjugate_u_mul
Computes the product of two NcmQuaternion and stores the result in res.
The second NcmQuaternion is conjugated before the multiplication.
The result is $r = q u^\dagger$, where $q$ and $u$ are q and u, respectively,
and $r$ is res. The conjugation is done by negating the vector part of u.
ncm_quaternion_lmul
Computes the product of two NcmQuaternion and stores the result in q.
That is, q = u * q, where u and q are u and q, respectively.
ncm_quaternion_mul
Computes the product of two NcmQuaternion $r=qu$ where $q$ and $u$ are
q and u, respectively, and $r$ is res.
ncm_quaternion_rmul
Computes the product of two NcmQuaternion and stores the result in q.
That is, q = q * u, where q and u are q and u, respectively.
ncm_quaternion_rotate
Computes the rotation of a NcmTriVec by a NcmQuaternion.
The rotation is done by the formula $v’ = q v q^\dagger$.
ncm_quaternion_set_from_data
Sets the components of a NcmQuaternion.
The components are the components of a three-dimensional vector and the angle
of rotation, the three-dimensional vector is normalized. The final
form of the quaternion is:
$$q = \cos(\theta/2) + \sin(\theta/2) \hat{v}.$$.
ncm_quaternion_set_random
Sets a NcmQuaternion to a random value, using the given NcmRNG.
The components of the three-dimensional vector are uniformly distributed
in the interval [-1, 1] and the angle is uniformly distributed in the
interval [0, 2*pi].
ncm_quaternion_set_to_rotate_to_x
Sets q to the rotation that rotates the given NcmTriVec to the x-axis. It finds
first the quaternion that rotates the given vector to the xz-plane and then the
quaternion that rotates the vector to the x-axis. Finally, it multiplies the two
quaternions and stores the result in q.
ncm_quaternion_set_to_rotate_to_z
Sets q to the rotation that rotates the given NcmTriVec to the z-axis. It finds
first the quaternion that rotates the given vector to the xz-plane and then the
quaternion that rotates the vector to the z-axis. Finally, it multiplies the two
quaternions and stores the result in q.