#include <rotmatrix3.h>
Public Member Functions | |||||||
void | identity () | ||||||
set up the identity matrix | |||||||
RotMatrix3 () | |||||||
default constructor, generates a 3x3 identity matrix | |||||||
RotMatrix3 (const RotMatrix3 &M) | |||||||
copy constructor | |||||||
RotMatrix3 & | operator= (const RotMatrix3 &M) | ||||||
copy assignment operator | |||||||
T & | operator() (int i, int j) | ||||||
subscript operator using zero-based indexing | |||||||
const T & | operator() (int i, int j) const | ||||||
subscript operator using zero-based indexing | |||||||
void | set (char axis, T a) | ||||||
Construct the orthogonal matrix from rotation around a single axis. | |||||||
void | transpose () | ||||||
transpose matrix 'this' | |||||||
void | inverse () | ||||||
invert matrix 'this'. | |||||||
T | det () const | ||||||
returns the value of the determinate of 'this' matrix. | |||||||
bool | is_equal (RotMatrix3 &A, T eps=0) const | ||||||
test if all elements in matrix 'this' and the matrix 'A' are equal. | |||||||
Parametrisation using direction cosines. | |||||||
In fact the direction cosines are the matrix elements itself.
The predefined matrix elements are copied from or into an array. The function requires the values of the direction cosines in row-oriented order, e.g. a11 = v(0), a12 = v(1), ... a33 = v(9). | |||||||
void | set_matrix (const T *v) | ||||||
copy matrix elements from arry | |||||||
void | get_matrix (T *v) const | ||||||
copy matrix elements into array | |||||||
Parametrisation using 3 rotation angles. | |||||||
Sequence of rotations : R(o,p,k) = Rz(k) * Ry(p) * Rx(o) Coordinate axes : fixed Direction of rotation : clockwise
References: [MoP 80] p. 51, Gl. 2.23 [Konecny/Lehmann 84] S. 101 Matrix A inpho Stuttgart, Rotation matrix in PATB ? [FM-I] Gl. 4.08a, (alte Luftfahrtnorm LN 9300), counter-clockwise! See also personal notes! | |||||||
void | set_angles_opk_fix (T omega, T phi, T kappa) | ||||||
set matrix using rotation angles | |||||||
void | get_angles_opk_fix (T &omega, T &phi, T &kappa) const | ||||||
get rotation angles from matrix | |||||||
Parametrisation using 3 rotation angles. | |||||||
Sequence of rotations : R(o,p,k) = Rz(k) * Ry(p) * Rx(o) Coordinate axes : fixed Direction of rotation : counter-clockwise
References: [Schwidefsky/Ackermann 76] Tab. 27.1, Spalte 2 [Albertz/Kreiling 75] S. 217, Drehung um feste Achsen | |||||||
void | set_angles_opk_fix_ccw (T omega, T phi, T kappa) | ||||||
set matrix using rotation angles | |||||||
void | get_angles_opk_fix_ccw (T &omega, T &phi, T &kappa) const | ||||||
get rotation angles from matrix | |||||||
Parametrisation using 3 rotation angles. | |||||||
Sequence of rotations : R(p,o,k) = Rz(k) * Rx(o) * Ry(p) Coordinate axis : fixed Direction of rotation : counter-clockwise References: [Finsterwalder/Hofmann 68] S. 32, Gl. 1.21
| |||||||
void | set_angles_pok_fix (T phi, T omega, T kappa) | ||||||
set matrix using rotation angles | |||||||
void | get_angles_pok_fix (T &phi, T &omega, T &kappa) const | ||||||
get rotation angles from matrix | |||||||
Parametrisation using 3 rotation angles. | |||||||
Sequence of rotation : R(o,p,k) = Rx(o) * Ry(p) * Rz(k) Coordinate axes : rotated Direction of rotation : counter-clockwise
References: [Kraus 94] Gl. 2.2-4 oder 2.1-1-6 [Schwidefsky/Ackermann 76] Gl. 1.7c (1.6e?) [Finsterwalder/Hofmann 68] S. 33, Gl. 1.25 | |||||||
void | set_angles_opk_rot (T omega, T phi, T kappa) | ||||||
set matrix using rotation angles | |||||||
void | get_angles_opk_rot (T &omega, T &phi, T &kappa) const | ||||||
get rotation angles from matrix | |||||||
Parametrisation using 3 rotation angles. | |||||||
Sequence of rotations : R(p,o,k) = Ry(p) * Rx(o) * Rz(k) Coordinate axis : rotated Direction of rotation : counter-clockwise
References: [Kraus 94] S. 380, Gl. 2.2-1-7 [Schwidefsky/Ackermann 76] Tab. 27.1, Spalte 1 [Finsterwalder/Hofmann 68] S. 32, Gl. 1.23 [Konecny/Lehmann 84] S. 101 Matrix B [Rueger 78] S. 21, (2.16a) | |||||||
void | set_angles_pok_rot (T phi, T omega, T kappa) | ||||||
set matrix using rotation angles | |||||||
void | get_angles_pok_rot (T &phi, T &omega, T &kappa) const | ||||||
get rotation angles from matrix | |||||||
Parametrisation using 3 rotation angles. | |||||||
Sequence of rotations : R(a,e,r) = Rz(r) * Rx(e) * Rz(a) Coordinate axis : fixed Direction of rotation : ? This is a special parametrisation implemented in Australis!?! References:
| |||||||
void | set_angles_australis (T az, T elev, T roll) | ||||||
set matrix using rotation angles | |||||||
void | get_angles_australis (T &az, T &elev, T &roll) const | ||||||
get rotation angles from matrix | |||||||
Parametrisation using small rotation angles. | |||||||
The small angles eps_x, eps_y, eps_z are about the respective coordinate axes in clockwise direction. "Small" means a few angular seconds. The sequence of rotations can be in any order (small rotations are commutative!).
References: [Thompson 69] | |||||||
void | set_angles_small (T eps_x, T eps_y, T eps_z) | ||||||
set matrix using small rotations | |||||||
void | get_angles_small (T &eps_x, T &eps_y, T &eps_z) const | ||||||
get small rotations from matrix | |||||||
Parametrisation using three upper-diagonal matrix elements. | |||||||
Applying the theorems of orthogonal matrices six matrix elements (a11, a21, a22, a31, a32, a33) can be constructed from three off-diagonal elements (a12, a13, a23).
References: [Shut 58] | |||||||
void | set_upper_elem (T a12, T a13, T a23) | ||||||
set matrix using three upper-diagonal matrix elements | |||||||
void | get_upper_elem (T &a12, T &a13, T &a23) const | ||||||
get upper-diagonal matrix elements from matrix | |||||||
Parametrisation by Rodrigues. | |||||||
Rodrigues construct the orthogonal matrix from Cayley's formular R = (I - S)(I + S)^(-1) using the skew-symmetric matrix ( 0 -c b ) S = 1/2 ( c 0 -a ). ( -b a 0 )
References: [Thompson 69] | |||||||
void | set_rodrigues_matrix (T a, T b, T c) | ||||||
set matrix Rodrigues parameters | |||||||
void | get_rodrigues_matrix (T &a, T &b, T &c) const | ||||||
get Rodrigues parameters from matrix | |||||||
(Hamiltonian) unit quaternion representation. | |||||||
The transformation can be also expressed by means of quaternion algebra r' = q r q^(-1) where q = (q0, q1, q2, q3) is a unit quaternion and q^(-1) is the recipropcal of q. By applying quaternion multiplication the rotation matrix can be derived.
References: [Shut 58] [Sanso 73] [Mikhail 01] p. 452, (E-39) [Craig 86] p. 55, (2.91) - (2.92) ??? | |||||||
void | set_quaternion (T q0, T q1, T q2, T q3) | ||||||
set matrix from unit quaternion | |||||||
void | set_quaternion (const vector< T > &q) | ||||||
set matrix from unit quaternion (STL vector) | |||||||
void | get_quaternion (T &q0, T &q1, T &q2, T &q3) const | ||||||
get unit quaternion from matrix | |||||||
void | get_quaternion (vector< T > &q) const | ||||||
get unit quaternion (STL vector) from matrix | |||||||
Parametrisation by one rotation about a line. | |||||||
The rotation is defined by a line in space and an angle t about this line. The line is defined by the direction cosines a, b and c. Also called "equivalent angle-axis representation" (Craig 86).
References: [Mikhail 01] p. 373, (A-68) [Rinner 57] S. 28, (4b) [Rueger 78] S. 19, (2.7a) - (2.7c) [Craig 86] p. 52, (2.80) - (2.82) | |||||||
void | set_about_line (T a, T b, T c, T t) | ||||||
set matrix by parameters | |||||||
void | get_about_line (T &a, T &b, T &c, T &t) const | ||||||
get parameters from matrix | |||||||
set/get rotation matrix using different representations. | |||||||
| |||||||
void | set (const T *v, ERotMatrix3::ecode type) | ||||||
set matrix from parameters | |||||||
void | get (T *v, ERotMatrix3::ecode type) const | ||||||
get parameters from matrix | |||||||
set/get rotation matrix using different representations. | |||||||
| |||||||
void | set (const vector< T > &v, ERotMatrix3::ecode type) | ||||||
set matrix from parameters | |||||||
void | get (vector< T > &v, ERotMatrix3::ecode type) const | ||||||
get parameters from matrix | |||||||
Private Attributes | |||||||
T | _a [3][3] | ||||||
matrix elements | |||||||
Friends | |||||||
istream & | operator>> FRIEND_FUNC_TEMPLATE (istream &is, RotMatrix3< T > &M) | ||||||
ostream & | operator<< FRIEND_FUNC_TEMPLATE (ostream &os, const RotMatrix3< T > &M) | ||||||
RotMatrix3< T > | operator*FRIEND_FUNC_TEMPLATE (const RotMatrix3< T > &A, const RotMatrix3< T > &B) |
Template class to rotate a 3D coordinate system.
The lineare transformation formular can be written by means of matrix/vector algebra:
r' = A r
where r coordinate vector of point P r' coordinate vector of point P' A the orthogonal rotation matrix.
The rotation matrix is represented by a 3x3 orthogonal matrix. The matrix elements are the cosines of the space angles between corresponding axes of the two coordinate systems, also called 'direction cosines'.
Two general remarks: (a) transformation direction transformation direction of the rotation matrix, when matrix A transform from coordinate system K into K' the transposed matrix A^t transform system K' into K.
(b) active/passive transformation In general we have to distinguish between the active (b) and the passive (a) rotation (transformation). The active rotation will rotate vector r into r' while the coordinate system K will be unchanged. Or in other words the original vector r and the resulted vector r' refere to the same coordinate system K. The passive rotation correspond to a rotation of the coordinate system K into K' while the point P is fixed.
The rotation matrix can be specified by just three independent parameters. For more than three parameters constraints exist between the parameters. There are six constraints on the nine matrix elements:
The parametrisation using three Euler angles (a) rotation about fixed (static or non-moving frame) or rotated (moving frame) axis and
R() = Rz(k) Ry(p) Rx(o)
R = R'x() R'y() R'z() (b) the sequence of principle axis.
about all 3 axis or by repyted rotation about the 1st axis.
For the rotation about fixed axies 6 combinations exist: xyz, zxy, yzx, xzy, yxz, zyx. Also 6 combinations exist for rotated axies 12 combinations can be constructed. And for the sequences of coordinates axes 12 possible sequences exist:
xyz, xyx, yzx, yzy, zxy, zxz, xzy, xzx, yxz, yxy, zyx and zyz. So in total 24 possibilities exist. Due to the fact that the resulted rotation matrix is the same for rotations about fixed axis and rotated axis in the opposite order
Rxyz(c,b,a) == Rx'y'z'(a,b,c)
the number of can be reduced to 12 combinations. For the 24 angle set conventions see [Craig 86] Appendix B. [Shoemake 94] show source code to convert any of this combinations of Euler angles to and from matrices and quaternions.
Some notes are missing:
Clear naming conventions for rotation angle sets are missing!
ATTENTION: For angular representation:
active/ccw == passive/cw active/cw == passive/ccw
Function calls: The set-functions will compose the rotation matrix from the given parameters while the get-functions will decompose/derive the parameters from the given rotation matrix.
References:
void GenLib2::RotMatrix3< T >::set | ( | char | axis, | |
T | a | |||
) | [inline] |
Construct the orthogonal matrix from rotation around a single axis.
The resulted matrix A will carry a point/vector r(x,y,z) into r'(x',y',z') by the operation r' = A r. Matrix A represents rotations about the fixed axes x, y and z respectively.
References: [Thompson 69]
axis | rotation around the x-axis ('x'), y-axis ('y') or z-axis ('z'). | |
a | rotation angle in radian. Positive angles (a > 0) means counter-clockwise rotation while negative angles (a < 0) means clockwise rotation. |
References GenLib2::RotMatrix3< T >::_a, and GenLib2::RotMatrix3< T >::identity().
void GenLib2::RotMatrix3< T >::inverse | ( | ) | [inline] |
invert matrix 'this'.
Simply a synonym for transpose.
T GenLib2::RotMatrix3< T >::det | ( | ) | const [inline] |
returns the value of the determinate of 'this' matrix.
Using Regel von Sarrus. The determinate of a orthogonal matrix det(A) = +/-1! The determinate is positive for a pure rotation and negative for a rotation combined with a reflection. Useful for testing if the matrix is orthogonal: A'A = AA' = I.
bool GenLib2::RotMatrix3< T >::is_equal | ( | RotMatrix3< T > & | A, | |
T | eps = 0 | |||
) | const [inline] |
test if all elements in matrix 'this' and the matrix 'A' are equal.
A | second matrix | |
eps | test limit |
References GenLib2::RotMatrix3< T >::_a.