Top |
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.
NcmTriVec *
ncm_trivec_new_full (const gdouble c[3]
);
Creates a new NcmTriVec with the given components.
[constructor]
NcmTriVec * ncm_trivec_new_full_c (const gdouble x
,const gdouble y
,const gdouble z
);
Creates a new NcmTriVec with the given components.
[constructor]
void ncm_trivec_memcpy (NcmTriVec *dest
,const NcmTriVec *orig
);
Copies a NcmTriVec.
gdouble ncm_trivec_dot (const NcmTriVec *v1
,const NcmTriVec *v2
);
Calculates the dot product of two NcmTriVec.
gdouble
ncm_trivec_get_phi (NcmTriVec *v
);
Gets the azimuthal angle of a NcmTriVec.
void ncm_trivec_set_spherical_coord (NcmTriVec *v
,gdouble r
,gdouble theta
,gdouble phi
);
Sets the spherical coordinates of a NcmTriVec.
void ncm_trivec_get_spherical_coord (NcmTriVec *v
,gdouble *theta
,gdouble *phi
);
Computes the spherical coordinates of a NcmTriVec.
NcmQuaternion *
ncm_quaternion_new (void
);
Creates a new empty NcmQuaternion.
[constructor]
NcmQuaternion *
ncm_quaternion_new_from_vector (NcmTriVec *v
);
Creates a new NcmQuaternion from a NcmTriVec.
[constructor]
NcmQuaternion * ncm_quaternion_new_from_data (gdouble x
,gdouble y
,gdouble z
,gdouble theta
);
Creates a new NcmQuaternion from the given components.
See ncm_quaternion_set_from_data()
for details.
[constructor]
NcmQuaternion *
ncm_quaternion_dup (NcmQuaternion *q
);
Duplicates a NcmQuaternion.
void ncm_quaternion_memcpy (NcmQuaternion *dest
,const NcmQuaternion *orig
);
Copies a NcmQuaternion.
void ncm_quaternion_set_from_data (NcmQuaternion *q
,gdouble x
,gdouble y
,gdouble z
,gdouble theta
);
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}.$$
void ncm_quaternion_set_random (NcmQuaternion *q
,NcmRNG *rng
);
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].
It represents a random rotation in three-dimensional space.
void
ncm_quaternion_set_I (NcmQuaternion *q
);
Sets a NcmQuaternion to the identity.
gdouble
ncm_quaternion_norm (NcmQuaternion *q
);
Calculates the norm of a NcmQuaternion.
void
ncm_quaternion_normalize (NcmQuaternion *q
);
Normalize a NcmQuaternion.
void
ncm_quaternion_conjugate (NcmQuaternion *q
);
Conjugate a NcmQuaternion. That is, the vector part is negated.
void ncm_quaternion_mul (NcmQuaternion *q
,NcmQuaternion *u
,NcmQuaternion *res
);
Computes the product of two NcmQuaternion and stores the result in res
.
void ncm_quaternion_lmul (NcmQuaternion *q
,NcmQuaternion *u
);
Computes the product of two NcmQuaternion and stores the result in q
.
That is, q
= u
* q
.
void ncm_quaternion_rmul (NcmQuaternion *q
,NcmQuaternion *u
);
Computes the product of two NcmQuaternion and stores the result in q
.
That is, q
= q
* u
.
void ncm_quaternion_conjugate_u_mul (NcmQuaternion *q
,NcmQuaternion *u
,NcmQuaternion *res
);
Computes the product of two NcmQuaternion and stores the result in res
.
The second NcmQuaternion is conjugated before the multiplication.
void ncm_quaternion_conjugate_q_mul (NcmQuaternion *q
,NcmQuaternion *u
,NcmQuaternion *res
);
Computes the product of two NcmQuaternion and stores the result in res
.
The first NcmQuaternion is conjugated before the multiplication.
void ncm_quaternion_rotate (NcmQuaternion *q
,NcmTriVec *v
);
Computes the rotation of a NcmTriVec by a NcmQuaternion.
void ncm_quaternion_inv_rotate (NcmQuaternion *q
,NcmTriVec *v
);
Computes the inverse rotation of a NcmTriVec by a NcmQuaternion.