WFMath
1.0.1
|
A dim dimensional rotation matrix. Technically, a member of the group O(dim). More...
#include <rotmatrix.h>
Public Member Functions | |
RotMatrix & | identity () |
set the matrix to the identity matrix | |
CoordType | elem (const int i, const int j) const |
get the (i, j) element of the matrix | |
bool | setVals (const CoordType vals[dim][dim], CoordType precision=numeric_constants< CoordType >::epsilon()) |
Set the values of the elements of the matrix. | |
bool | setVals (const CoordType vals[dim *dim], CoordType precision=numeric_constants< CoordType >::epsilon()) |
Set the values of the elements of the matrix. | |
Vector< dim > | row (const int i) const |
Get a copy of the i'th row as a Vector. | |
Vector< dim > | column (const int i) const |
Get a copy of the i'th column as a Vector. | |
CoordType | trace () const |
Get the trace of the matrix. | |
CoordType | determinant () const |
Get the determinant of the matrix. | |
RotMatrix | inverse () const |
Get the inverse of the matrix. | |
bool | parity () const |
Get the parity of the matrix. | |
RotMatrix & | rotation (const int i, const int j, CoordType theta) |
set the matrix to a rotation by the angle theta in the (i, j) plane | |
RotMatrix & | rotation (const Vector< dim > &v1, const Vector< dim > &v2, CoordType theta) |
set the matrix to a rotation by the angle theta in the v1, v2 plane | |
RotMatrix & | rotation (const Vector< dim > &from, const Vector< dim > &to) |
set the matrix to a rotation which will move "from" to lie parallel to "to" | |
RotMatrix & | mirror (const int i) |
set the matrix to a mirror perpendicular to the i'th axis | |
RotMatrix & | mirror (const Vector< dim > &v) |
set the matrix to a mirror perpendicular to the Vector v | |
RotMatrix & | mirror () |
set the matrix to mirror all axes | |
RotMatrix & | rotate (const RotMatrix &m) |
rotate the matrix using another matrix | |
void | normalize () |
normalize to remove accumulated round-off error | |
unsigned | age () const |
current round-off age | |
RotMatrix (const Quaternion &q, const bool not_flip=true) | |
3D only: Construct a RotMatrix from a Quaternion | |
RotMatrix & | rotation (CoordType theta) |
2D only: Construct a RotMatrix from an angle theta | |
RotMatrix & | rotationX (CoordType theta) |
3D only: set a RotMatrix to a rotation about the x axis by angle theta | |
RotMatrix & | rotationY (CoordType theta) |
3D only: set a RotMatrix to a rotation about the y axis by angle theta | |
RotMatrix & | rotationZ (CoordType theta) |
3D only: set a RotMatrix to a rotation about the z axis by angle theta | |
RotMatrix & | rotation (const Vector< dim > &axis, CoordType theta) |
3D only: set a RotMatrix to a rotation about the axis given by the Vector | |
RotMatrix & | rotation (const Vector< dim > &axis) |
3D only: set a RotMatrix to a rotation about the axis given by the Vector | |
RotMatrix & | fromQuaternion (const Quaternion &q, const bool not_flip=true) |
3D only: set a RotMatrix from a Quaternion | |
RotMatrix & | rotate (const Quaternion &) |
rotate the matrix using the quaternion | |
RotMatrix & | mirrorX () |
set a RotMatrix to a mirror perpendicular to the x axis | |
RotMatrix & | mirrorY () |
set a RotMatrix to a mirror perpendicular to the y axis | |
RotMatrix & | mirrorZ () |
set a RotMatrix to a mirror perpendicular to the z axis |
Friends | |
RotMatrix | Prod (const RotMatrix &m1, const RotMatrix &m2) |
returns m1 * m2 | |
RotMatrix | ProdInv (const RotMatrix &m1, const RotMatrix &m2) |
returns m1 * m2^-1 | |
RotMatrix | InvProd (const RotMatrix &m1, const RotMatrix &m2) |
returns m1^-1 * m2 | |
RotMatrix | InvProdInv (const RotMatrix &m1, const RotMatrix &m2) |
returns m1^-1 * m2^-1 | |
Vector< dim > | Prod (const RotMatrix &m, const Vector< dim > &v) |
returns m * v | |
Vector< dim > | InvProd (const RotMatrix &m, const Vector< dim > &v) |
returns m^-1 * v |
A dim dimensional rotation matrix. Technically, a member of the group O(dim).
Elements of this class represent rotation matrices. The NxN dimensional rotation matrices form a group called O(N), the orthogonal matrices. They satisfy the following condition:
They are orthogonal. That is, their transpose is equal to their inverse. Hence, this class does not implement a transpose() method, only an inverse().
A general N dimensional matrix of this type has N(N-1)/2 degrees of freedom. This gives one rotation angle in 2D, the three Euler angles in 3D, etc.
This class implements the 'generic' subset of the interface in the fake class Shape.
WFMath::RotMatrix< dim >::RotMatrix | ( | const Quaternion & | q, |
const bool | not_flip = true |
||
) |
3D only: Construct a RotMatrix from a Quaternion
since Quaternions can only specify parity-even rotations, you can pass the return value of Quaternion::fromRotMatrix() as not_flip to recover the full RotMatrix
|
inline |
Get the determinant of the matrix.
Since the matrix is orthogonal, the determinant is always either 1 or -1.
RotMatrix& WFMath::RotMatrix< dim >::fromQuaternion | ( | const Quaternion & | q, |
const bool | not_flip = true |
||
) |
3D only: set a RotMatrix from a Quaternion
since Quaternions can only specify parity-even rotations, you can pass the return value of Quaternion::fromRotMatrix() as not_flip to recover the full RotMatrix
|
inline |
Get the inverse of the matrix.
Since the matrix is orthogonal, the inverse is equal to the transpose.
|
inline |
set the matrix to mirror all axes
This is a good parity operator if dim is odd.
Referenced by WFMath::RotMatrix< dim >::mirrorX(), and WFMath::RotMatrix< dim >::mirrorY().
|
inline |
Get the parity of the matrix.
Returns true for odd parity, false for even.
RotMatrix< dim > & WFMath::RotMatrix< dim >::rotation | ( | const Vector< dim > & | v1, |
const Vector< dim > & | v2, | ||
CoordType | theta | ||
) |
set the matrix to a rotation by the angle theta in the v1, v2 plane
Throws CollinearVectors if v1 and v2 are parallel
References WFMath::Vector< dim >::sqrMag().
RotMatrix< dim > & WFMath::RotMatrix< dim >::rotation | ( | const Vector< dim > & | from, |
const Vector< dim > & | to | ||
) |
set the matrix to a rotation which will move "from" to lie parallel to "to"
Throws CollinearVectors if v1 and v2 are antiparallel (parallel but pointing in opposite directions). If v1 and v2 point in the same direction, the matrix is set to the identity.
References WFMath::Vector< dim >::sqrMag().
RotMatrix& WFMath::RotMatrix< dim >::rotation | ( | const Vector< dim > & | axis | ) |
|
inline |
Set the values of the elements of the matrix.
Can't set one element at a time and keep it an O(N) matrix, but can try to set all values at once, and see if they match. This fails if the passed matrix is not orthogonal within the passed precision, and orthogonalizes the matrix to within precision WFMATH_EPSILON.
|
inline |
Set the values of the elements of the matrix.
Can't set one element at a time and keep it an O(N) matrix, but can try to set all values at once, and see if they match. This fails if the passed matrix is not orthogonal within the passed precision, and orthogonalizes the matrix to within precision WFMATH_EPSILON.