rotlib 1.0.0
Loading...
Searching...
No Matches
rotlib.h
Go to the documentation of this file.
1
2#ifndef ROTLIB_H
3#define ROTLIB_H
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#include <stdbool.h>
10
27
32enum EulangSeq {ES_XYZ, ES_XZY, ES_YXZ, ES_YZX, ES_ZXY, ES_ZYX};
33
34/******************************************************************************/
35 /* UTILITY FUNCTIONS */
36/******************************************************************************/
37
42
61void align(const int n, const double* v, const int m, const double* old,
62 const double* new, double* valigned);
63
69bool mat_is_rotmat(const double* mat);
70
74
75/******************************************************************************/
76 /* QUATERNIONS */
77/******************************************************************************/
78
83
88void quat_rand(double q[4]);
89
94void quat_identity(double q[4]);
95
100void quat_conjugated(double q[4]);
101
106void quat_inverted(double q[4]);
107
112void quat_normalized(double q[4]);
113
120bool quat_is_normalized(const double q[4]);
121
128void quat_prod(const double p[4], const double q[4], double pq[4],
129 bool normalize);
130
136double quat_angle_between(const double p[4], const double q[4]);
137
144void quat_interpolate(const double q1[4], const double q2[4], const double t,
145 double q[4]);
146
152void quat_deriv_to_angvel_mat(const double q[4], double* mat);
153
160void quat_deriv_to_angvel(const double q[4], const double qdot[4],
161 double angvel[3]);
162
168void quat_deriv_from_angvel_mat(const double q[4], double* mat);
169
176void quat_deriv_from_angvel(const double q[4], const double angvel[3],
177 double qdot[4]);
178
183void quat_rotmat(const double q[4], double* rotmat);
184
191void quat_shiftmat(const double q[4], const bool forward,
192 double* shiftmat);
193
200void quat_rotate_vectors(const int n, const double* v, const double q[4],
201 double* vrot);
202
213void quat_shift_vectors(const int n, const double* v, const double q[4],
214 const bool forward, double* vshift);
215
225void quat_shift_tensor2(const double* A, const double q[4],
226 const bool forward, double* Ashift);
227
237void quat_shift_tensor3(const double* A, const double q[4],
238 const bool forward, double* Ashift);
239
245void quat_to_aa(const double q[4], double axis[3], double* angle);
246
251void quat_to_dcm(const double q[4], double* dcm);
252
261void quat_to_euler(const double q[4], enum EulangSeq seq, const bool world,
262 double euler[3]);
266
267/******************************************************************************/
268 /* AXIS ANGLE */
269/******************************************************************************/
270
275
283void aa_fix(double axis[3], double* angle, const bool normalize);
284
293void aa_rand(double axis[3], double* angle);
294
301void aa_rotmat(const double axis[3], const double angle,
302 double* rotmat);
303
309void aa_from_rotmat(const double* rotmat, double axis[3], double* angle);
310
318void aa_rotate_vectors(const int n, const double* v, const double axis[3],
319 const double angle, double* vrot);
320
329void aa_shiftmat(const double axis[3], const double angle,
330 const bool forward, double* shiftmat);
331
343void aa_shift_vectors(const int n, const double* v,
344 const double axis[3], const double angle, const bool forward,
345 double* vshift);
346
357void aa_shift_tensor2(const double* A, const double axis[3],
358 const double angle, const bool forward, double* Ashift);
359
370void aa_shift_tensor3(const double* A, const double axis[3],
371 const double angle, const bool forward, double* Ashift);
372
378void aa_to_quat(const double axis[3], const double angle, double q[4]);
379
386void aa_to_dcm(const double axis[3], const double angle, double* dcm);
387
397void aa_to_euler(const double axis[3], const double angle,
398 enum EulangSeq seq, const bool world, double euler[3]);
402
403/******************************************************************************/
404 /* DIRECTION COSINE MATRIX */
405/******************************************************************************/
406
411
416bool mat_is_dcm(const double* mat);
417
426void dcm_from_axes(const double* A, const double* B, double* dcm);
427
433void dcm_rotmat(const double* dcm, double* rotmat);
434
442void dcm_shiftmat(const double* dcm, const bool forward, double* shiftmat);
443
450void dcm_rotate_vectors(const int n, const double* v, const double* dcm,
451 double* vrot);
452
463void dcm_shift_vectors(const int n, const double* v, const double* dcm,
464 const bool forward, double* vshift);
465
475void dcm_shift_tensor2(const double* A, const double* dcm, const bool forward,
476 double* Ashift);
477
487void dcm_shift_tensor3(const double* A, const double* dcm, const bool forward,
488 double* Ashift);
489
494void dcm_to_quat(const double* dcm, double q[4]);
495
502void dcm_to_aa(const double* dcm, double axis[3], double* angle);
503
512void dcm_to_euler(const double* dcm, enum EulangSeq seq, const bool world,
513 double euler[3]);
517
518/******************************************************************************/
519 /* EULER ANGLES */
520/******************************************************************************/
521
526
535void euler_rotmat(const double euler[3], enum EulangSeq seq, const bool world,
536 double* rotmat);
537
548void euler_shiftmat(const double euler[3], enum EulangSeq seq, const bool world,
549 const bool forward, double* shiftmat);
550
561void euler_rotate_vectors(const int n, const double* v, const double euler[3],
562 enum EulangSeq seq, const bool world, double* vrot);
563
578void euler_shift_vectors(const int n, const double* v, const double euler[3],
579 enum EulangSeq seq, const bool world, const bool forward,
580 double* vshift);
581
595void euler_shift_tensor2(const double* A, const double euler[3],
596 enum EulangSeq seq, const bool world, const bool forward, double* Ashift);
597
611void euler_shift_tensor3(const double* A, const double euler[3],
612 enum EulangSeq seq, const bool world, const bool forward, double* Ashift);
613
622void euler_to_quat(const double euler[3], enum EulangSeq seq, const bool world,
623 double q[4]);
624
634void euler_to_aa(const double euler[3], enum EulangSeq seq, const bool world,
635 double axis[3], double* angle);
636
645void euler_to_dcm(const double euler[3], enum EulangSeq seq, const bool world,
646 double* dcm);
647
662void euler_to_euler(const double euler[3], enum EulangSeq seq, const bool world,
663 enum EulangSeq to_seq, const bool to_world, double to_euler[3]);
667
668#ifdef __cplusplus
669}
670#endif
671
672#endif /* ROTLIB_H */
void aa_shift_tensor2(const double *A, const double axis[3], const double angle, 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 axi...
Definition rotlib.c:1093
void aa_rand(double axis[3], double *angle)
Generates a random orientation in axis-angle representation.
Definition rotlib.c:934
void aa_to_dcm(const double axis[3], const double angle, double *dcm)
Converts an axis-angle representation to a direction cosine matrix.
Definition rotlib.c:1115
void aa_rotate_vectors(const int n, const double *v, const double axis[3], const double angle, double *vrot)
Rotates vectors about axis by angle.
Definition rotlib.c:1070
void aa_from_rotmat(const double *rotmat, double axis[3], double *angle)
Extracts axis and angle from a rotation matrix.
Definition rotlib.c:986
void aa_shift_vectors(const int n, const double *v, const double axis[3], const double angle, 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 an ...
Definition rotlib.c:1081
void aa_shift_tensor3(const double *A, const double axis[3], const double angle, 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 axi...
Definition rotlib.c:1104
void aa_rotmat(const double axis[3], const double angle, double *rotmat)
Calculates the rotation matrix corresponding to an axis-angle representation.
Definition rotlib.c:963
void aa_to_euler(const double axis[3], const double angle, enum EulangSeq seq, const bool world, double euler[3])
Converts an axis-angle representation to an Euler angle sequence.
Definition rotlib.c:1123
void aa_fix(double axis[3], double *angle, const bool normalize)
Modifies axis and angle to ensure a right handed rotation with angle .
Definition rotlib.c:903
void aa_to_quat(const double axis[3], const double angle, double q[4])
Converts an axis-angle representation to a unit quaternion.
Definition rotlib.c:1134
void aa_shiftmat(const double axis[3], const double angle, const bool forward, double *shiftmat)
Calculates the shifter matrix corresponding to an axis-angle representation.
Definition rotlib.c:1046
void dcm_from_axes(const double *A, const double *B, double *dcm)
Returns the direction cosine matrix of axes(i.e. frame) B with respect to axes(i.e....
Definition rotlib.c:1163
bool mat_is_dcm(const double *mat)
Checks is a 3 x 3 array is a direction cosine matrix.
Definition rotlib.c:1156
void dcm_rotmat(const double *dcm, double *rotmat)
Returns the rotation matrix corresponding to a direction cosine matrix.
Definition rotlib.c:1173
void dcm_shift_vectors(const int n, const double *v, const double *dcm, 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 d...
Definition rotlib.c:1203
void dcm_to_aa(const double *dcm, double axis[3], double *angle)
Converts a direction cosine matrix to an axis-angle representation.
Definition rotlib.c:1249
void dcm_to_euler(const double *dcm, enum EulangSeq seq, const bool world, double euler[3])
Converts a direction cosine matrix to Euler angles.
Definition rotlib.c:1259
void dcm_shift_tensor2(const double *A, const double *dcm, 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 d...
Definition rotlib.c:1214
void dcm_to_quat(const double *dcm, double q[4])
Converts a direction cosine matrix to a unit quaternion.
Definition rotlib.c:1236
void dcm_shift_tensor3(const double *A, const double *dcm, 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 d...
Definition rotlib.c:1225
void dcm_shiftmat(const double *dcm, const bool forward, double *shiftmat)
Returns the shifter matrix corresponding to a direction cosine matrix.
Definition rotlib.c:1180
void dcm_rotate_vectors(const int n, const double *v, const double *dcm, double *vrot)
Rotates vectors by a direction cosine matrix.
Definition rotlib.c:1192
void euler_shift_tensor3(const double *A, const double euler[3], enum EulangSeq seq, const bool world, 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 thr...
Definition rotlib.c:1332
void euler_to_quat(const double euler[3], enum EulangSeq seq, const bool world, double q[4])
Convert Euler angles to a unit quaternion.
Definition rotlib.c:1344
void euler_shift_tensor2(const double *A, const double euler[3], enum EulangSeq seq, const bool world, 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 thr...
Definition rotlib.c:1320
void euler_to_euler(const double euler[3], enum EulangSeq seq, const bool world, enum EulangSeq to_seq, const bool to_world, double to_euler[3])
Converts Convert one set of Euler angles to another.
Definition rotlib.c:1375
void euler_rotmat(const double euler[3], enum EulangSeq seq, const bool world, double *rotmat)
Calculates the rotation matrix for a set of Euler angles.
Definition rotlib.c:1272
void euler_to_dcm(const double euler[3], enum EulangSeq seq, const bool world, double *dcm)
Convert Euler angles to a direction cosine matrix.
Definition rotlib.c:1367
void euler_to_aa(const double euler[3], enum EulangSeq seq, const bool world, double axis[3], double *angle)
Convert Euler angles to an axis-angle representation.
Definition rotlib.c:1356
void euler_shiftmat(const double euler[3], enum EulangSeq seq, const bool world, const bool forward, double *shiftmat)
Calculates the shifter matrix for a set of Euler angles.
Definition rotlib.c:1280
void euler_rotate_vectors(const int n, const double *v, const double euler[3], enum EulangSeq seq, const bool world, double *vrot)
Rotates vectors with a set of Euler angles.
Definition rotlib.c:1297
void euler_shift_vectors(const int n, const double *v, const double euler[3], enum EulangSeq seq, const bool world, 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 thr...
Definition rotlib.c:1308
void quat_to_dcm(const double q[4], double *dcm)
Converts a unit quaternion to a direction cosine matrix.
Definition rotlib.c:882
void quat_shiftmat(const double q[4], const bool forward, double *shiftmat)
Calculates the shifter matrix corresponding to a unit quaternion.
Definition rotlib.c:795
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 u...
Definition rotlib.c:823
void quat_interpolate(const double q1[4], const double q2[4], const double t, double q[4])
Interpolates between two unit quaternions.
Definition rotlib.c:693
void quat_conjugated(double q[4])
Performs in-place conjugation of a quaternion.
Definition rotlib.c:629
void quat_rand(double q[4])
Creates a unit quarternion with random orientation.
Definition rotlib.c:610
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.
Definition rotlib.c:708
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 u...
Definition rotlib.c:834
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.
Definition rotlib.c:726
void quat_inverted(double q[4])
Performs in-place inversion of a quaternion.
Definition rotlib.c:637
void quat_identity(double q[4])
Creates an identity quarternion.
Definition rotlib.c:621
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.
Definition rotlib.c:737
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.
Definition rotlib.c:756
void quat_normalized(double q[4])
Performs in-place normalization of a quaternion.
Definition rotlib.c:646
bool quat_is_normalized(const double q[4])
Returns true if a quaternion is normalized, i.e. if it is a unit quaternion.
Definition rotlib.c:658
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 u...
Definition rotlib.c:845
void quat_prod(const double p[4], const double q[4], double pq[4], bool normalize)
Calculates the product of two unit quaternions.
Definition rotlib.c:673
double quat_angle_between(const double p[4], const double q[4])
Returns the angle between two unit quaternions.
Definition rotlib.c:686
void quat_rotmat(const double q[4], double *rotmat)
Calculates the rotation matrix corresponding to a unit quaternion.
Definition rotlib.c:767
void quat_rotate_vectors(const int n, const double *v, const double q[4], double *vrot)
Rotates vectors by a unit quaternion.
Definition rotlib.c:812
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.
Definition rotlib.c:889
void quat_to_aa(const double q[4], double axis[3], double *angle)
Converts a unit quaternion to an axis-angle representation.
Definition rotlib.c:856
bool mat_is_rotmat(const double *mat)
Checks whether a 2D array is a rotation matrix.
Definition rotlib.c:587
void align(const int n, const double *v, const int m, const double *old, const double *new, double *valigned)
Rotates vectors such that a set of mutually orthogonal unit vectors aligns with another set of mutual...
Definition rotlib.c:523
EulangSeq
Euler angle sequences. ES_ABC signifies first rotation about the A axis, second rotation about the B ...
Definition rotlib.h:32