rotlib 1.0.0
Loading...
Searching...
No Matches
Quaternion

Functions

void quat_rand (double q[4])
 Creates a unit quarternion with random orientation.
void quat_identity (double q[4])
 Creates an identity quarternion.
void quat_conjugated (double q[4])
 Performs in-place conjugation of a quaternion.
void quat_inverted (double q[4])
 Performs in-place inversion of a quaternion.
void quat_normalized (double q[4])
 Performs in-place normalization of a quaternion.
bool quat_is_normalized (const double q[4])
 Returns true if a quaternion is normalized, i.e. if it is a unit quaternion.
void quat_prod (const double p[4], const double q[4], double pq[4], bool normalize)
 Calculates the product of two unit quaternions.
double quat_angle_between (const double p[4], const double q[4])
 Returns the angle between two unit quaternions.
void quat_interpolate (const double q1[4], const double q2[4], const double t, double q[4])
 Interpolates between two unit quaternions.
void quat_deriv_to_angvel_mat (const double q[4], double *mat)
 Returns the matrix mapping the derivative of a unit quaternion to angular velocity.
void quat_deriv_to_angvel (const double q[4], const double qdot[4], double angvel[3])
 Calculates the angular velocity from a unit quaternion and its time derivative.
void quat_deriv_from_angvel_mat (const double q[4], double *mat)
 Returns the matrix mapping the angular velocity to the time derivative of a unit quaternion.
void quat_deriv_from_angvel (const double q[4], const double angvel[3], double qdot[4])
 Calculates the time derivative of a unit quaternion from angular velocity.
void quat_rotmat (const double q[4], double *rotmat)
 Calculates the rotation matrix corresponding to a unit quaternion.
void quat_shiftmat (const double q[4], const bool forward, double *shiftmat)
 Calculates the shifter matrix corresponding to a unit quaternion.
void quat_rotate_vectors (const int n, const double *v, const double q[4], double *vrot)
 Rotates vectors by a unit quaternion.
void quat_shift_vectors (const int n, const double *v, const double q[4], const bool forward, double *vshift)
 Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts vectors from A to B or B to A.
void quat_shift_tensor2 (const double *A, const double q[4], const bool forward, double *Ashift)
 Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts second-order tensors from A to B or B to A.
void quat_shift_tensor3 (const double *A, const double q[4], const bool forward, double *Ashift)
 Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts third-order tensors from A to B or B to A.
void quat_to_aa (const double q[4], double axis[3], double *angle)
 Converts a unit quaternion to an axis-angle representation.
void quat_to_dcm (const double q[4], double *dcm)
 Converts a unit quaternion to a direction cosine matrix.
void quat_to_euler (const double q[4], enum EulangSeq seq, const bool world, double euler[3])
 Converts a unit quaternion to an Euler angle sequence.

Detailed Description

Function Documentation

◆ quat_angle_between()

double quat_angle_between ( const double p[4],
const double q[4] )

Returns the angle between two unit quaternions.

Parameters
[in]pA quaternion.
[in]qAnother quaternion.
Returns
Angle in radian.

◆ quat_conjugated()

void quat_conjugated ( double q[4])

Performs in-place conjugation of a quaternion.

Parameters
[in,out]qin: A quaternion.
out: The quaternion q conjugated.

◆ quat_deriv_from_angvel()

void quat_deriv_from_angvel ( const double q[4],
const double angvel[3],
double qdot[4] )

Calculates the time derivative of a unit quaternion from angular velocity.

Parameters
[in]qA unit quaternion.
[in]angvelAngular velocity.
[out]qdotTime derivative of q.

◆ quat_deriv_from_angvel_mat()

void quat_deriv_from_angvel_mat ( const double q[4],
double * mat )

Returns the matrix mapping the angular velocity to the time derivative of a unit quaternion.

Parameters
[in]qA unit quaternion.
[out]matThe 4 x 3 quaternion derivative matrix.

◆ quat_deriv_to_angvel()

void quat_deriv_to_angvel ( const double q[4],
const double qdot[4],
double angvel[3] )

Calculates the angular velocity from a unit quaternion and its time derivative.

Parameters
[in]qA unit quaternion.
[in]qdotTime derivative of q.
[out]angvelAngular velocity.

◆ quat_deriv_to_angvel_mat()

void quat_deriv_to_angvel_mat ( const double q[4],
double * mat )

Returns the matrix mapping the derivative of a unit quaternion to angular velocity.

Parameters
[in]qDerivative of a unit quaternion.
[out]matThe 3 x 4 angular velocity matrix.

◆ quat_identity()

void quat_identity ( double q[4])

Creates an identity quarternion.

Parameters
[out]qIdentity quaternion.

◆ quat_interpolate()

void quat_interpolate ( const double q1[4],
const double q2[4],
const double t,
double q[4] )

Interpolates between two unit quaternions.

Parameters
[in]q1A unit quaternion.
[in]q2Another unit quaternion.
[in]tInterpolation factor, 0 <= t <= 1.
[out]qInterpolated unit quaternion.

◆ quat_inverted()

void quat_inverted ( double q[4])

Performs in-place inversion of a quaternion.

Parameters
[in,out]qin: A quaternion.
out: The quaternion q inverted.

◆ quat_is_normalized()

bool quat_is_normalized ( const double q[4])

Returns true if a quaternion is normalized, i.e. if it is a unit quaternion.

Parameters
[in]qA quaternion.
Returns
true if q is normalized, false otherwise.

◆ quat_normalized()

void quat_normalized ( double q[4])

Performs in-place normalization of a quaternion.

Parameters
[in,out]qin: A quaternion.
out: The quaternion q normalized.

◆ quat_prod()

void quat_prod ( const double p[4],
const double q[4],
double pq[4],
bool normalize )

Calculates the product of two unit quaternions.

Parameters
[in]pA quaternion.
[in]qAnother quaternion.
[out]pqProduct of p and q.
[in]normalizeWhether to normalize the product.

◆ quat_rand()

void quat_rand ( double q[4])

Creates a unit quarternion with random orientation.

Parameters
[out]qThe unit quaternion.

◆ quat_rotate_vectors()

void quat_rotate_vectors ( const int n,
const double * v,
const double q[4],
double * vrot )

Rotates vectors by a unit quaternion.

Parameters
[in]nNumber of rows of v.
[in]vn x 3 array whose rows are the vectors to rotate.
[in]qA unit quaternion.
[out]vrotn x 3 array whose rows are the rotated vectors.

◆ quat_rotmat()

void quat_rotmat ( const double q[4],
double * rotmat )

Calculates the rotation matrix corresponding to a unit quaternion.

Parameters
[in]qA unit quaternion.
[out]rotmat3 x 3 rotation matrix.

◆ quat_shift_tensor2()

void quat_shift_tensor2 ( const double * A,
const double q[4],
const bool forward,
double * Ashift )

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts second-order tensors from A to B or B to A.

Parameters
[in]A3 x 3 second-order tensor.
[in]qA unit quaternion.
[in]forwardWhether to shift forward, i.e., along the orientation or shift reverse.
[out]Ashift3 x 3 shifted second-order tensor.

◆ quat_shift_tensor3()

void quat_shift_tensor3 ( const double * A,
const double q[4],
const bool forward,
double * Ashift )

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts third-order tensors from A to B or B to A.

Parameters
[in]A3 x 3 x 3 third-order tensor.
[in]qA unit quaternion.
[in]forwardWhether to shift forward, i.e., along the orientation or shift reverse.
[out]Ashift3 x 3 x 3 shifted third-order tensor.

◆ quat_shift_vectors()

void quat_shift_vectors ( const int n,
const double * v,
const double q[4],
const bool forward,
double * vshift )

Given two frames A and B such that the orientation of frame B with respect to frame A is given by a unit quaternion, shifts vectors from A to B or B to A.

Parameters
[in]nNumber of rows of v.
[in]vn x 3 array whose rows are the vectors to shift.
[in]qA unit quaternion.
[in]forwardWhether to shift forward, i.e., along the orientation or shift reverse.
[out]vshiftn x 3 array whose rows are the rotated vectors.

◆ quat_shiftmat()

void quat_shiftmat ( const double q[4],
const bool forward,
double * shiftmat )

Calculates the shifter matrix corresponding to a unit quaternion.

Parameters
[in]qA unit quaternion.
[in]forwardWhether to shift forward, i.e., along the orientation or shift reverse.
[out]shiftmat3 x 3 shifter matrix.

◆ quat_to_aa()

void quat_to_aa ( const double q[4],
double axis[3],
double * angle )

Converts a unit quaternion to an axis-angle representation.

Parameters
[in]qA unit quaternion.
[out]axisUnit vector along the axis of rotation.
[out]angleAngle in radian.

◆ quat_to_dcm()

void quat_to_dcm ( const double q[4],
double * dcm )

Converts a unit quaternion to a direction cosine matrix.

Parameters
[in]qA unit quaternion.
[out]dcm3 x 3 direction cosine matrix.

◆ quat_to_euler()

void quat_to_euler ( const double q[4],
enum EulangSeq seq,
const bool world,
double euler[3] )

Converts a unit quaternion to an Euler angle sequence.

Parameters
[in]qA unit quaternion.
[in]seqES_XYZ | ES_XZY | ES_YXZ | ES_YZX | ES_ZXY | ES_ZYX.
Euler angle sequence.
[in]worldWhether the Euler angles are with respect to the world frame or not.
[out]eulerEuler angles.