26 #ifndef WFMATH_ROTMATRIX_H
27 #define WFMATH_ROTMATRIX_H
29 #include <wfmath/const.h>
37 RotMatrix<dim>
Prod(
const RotMatrix<dim>& m1,
const RotMatrix<dim>& m2);
40 RotMatrix<dim>
ProdInv(
const RotMatrix<dim>& m1,
const RotMatrix<dim>& m2);
43 RotMatrix<dim>
InvProd(
const RotMatrix<dim>& m1,
const RotMatrix<dim>& m2);
46 RotMatrix<dim>
InvProdInv(
const RotMatrix<dim>& m1,
const RotMatrix<dim>& m2);
49 Vector<dim>
Prod(
const RotMatrix<dim>& m,
const Vector<dim>& v);
51 Vector<dim>
InvProd(
const RotMatrix<dim>& m,
const Vector<dim>& v);
53 Vector<dim>
Prod(
const Vector<dim>& v,
const RotMatrix<dim>& m);
55 Vector<dim>
ProdInv(
const Vector<dim>& v,
const RotMatrix<dim>& m);
59 RotMatrix<dim>
operator*(
const RotMatrix<dim>& m1,
const RotMatrix<dim>& m2);
61 Vector<dim>
operator*(
const RotMatrix<dim>& m,
const Vector<dim>& v);
63 Vector<dim>
operator*(
const Vector<dim>& v,
const RotMatrix<dim>& m);
66 std::ostream& operator<<(std::ostream& os,
const RotMatrix<dim>& m);
68 std::istream& operator>>(std::istream& is, RotMatrix<dim>& m);
90 RotMatrix() : m_elem{}, m_flip(
false), m_valid(
false), m_age(0) {}
94 friend std::ostream& operator<< <dim>(std::ostream& os,
const RotMatrix& m);
95 friend std::istream&
operator>> <dim>(std::istream& is,
RotMatrix& m);
103 bool operator==(
const RotMatrix& m)
const {
return isEqualTo(m);}
104 bool operator!=(
const RotMatrix& m)
const {
return !isEqualTo(m);}
106 bool isValid()
const {
return m_valid;}
201 unsigned age()
const {
return m_age;}
259 void checkNormalization() {
if(m_age >= WFMATH_MAX_NORM_AGE && m_valid)
normalize();}
A dim dimensional rotation matrix. Technically, a member of the group O(dim).
RotMatrix & rotation(int i, int j, CoordType theta)
set the matrix to a rotation by the angle theta in the (i, j) plane
RotMatrix & rotate(const Quaternion &)
rotate the matrix using the quaternion
friend RotMatrix Prod(const RotMatrix &m1, const RotMatrix &m2)
returns m1 * m2
RotMatrix & rotationX(CoordType theta)
3D only: set a RotMatrix to a rotation about the x axis by angle theta
Vector< dim > row(int i) const
Get a copy of the i'th row as a Vector.
Vector< dim > column(int i) const
Get a copy of the i'th column as a Vector.
RotMatrix & rotationZ(CoordType theta)
3D only: set a RotMatrix to a rotation about the z axis by angle theta
RotMatrix & rotationY(CoordType theta)
3D only: set a RotMatrix to a rotation about the y 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 & rotate(const RotMatrix &m)
rotate the matrix using another matrix
RotMatrix & identity()
set the matrix to the identity matrix
bool parity() const
Get the parity of the matrix.
CoordType trace() const
Get the trace of the matrix.
CoordType elem(const int i, const int j) const
get the (i, j) element of the matrix
RotMatrix & mirrorZ()
set a RotMatrix to a mirror perpendicular to the z axis
RotMatrix & rotation(CoordType theta)
2D only: Construct a RotMatrix from an angle theta
RotMatrix & fromQuaternion(const Quaternion &q, bool not_flip=true)
3D only: set a RotMatrix from a Quaternion
void normalize()
normalize to remove accumulated round-off error
RotMatrix & mirror()
set the matrix to mirror all axes
RotMatrix & mirrorY()
set a RotMatrix to a mirror perpendicular to the y axis
RotMatrix(const Quaternion &q, bool not_flip=true)
3D only: Construct a RotMatrix from a Quaternion
RotMatrix & rotation(const Vector< dim > &axis)
3D only: set a RotMatrix to a rotation about the axis given by the Vector
RotMatrix & mirror(int i)
set the matrix to a mirror perpendicular to the i'th axis
RotMatrix inverse() const
Get the inverse of the matrix.
unsigned age() const
current round-off age
RotMatrix & mirrorX()
set a RotMatrix to a mirror perpendicular to the x axis
bool setVals(const CoordType vals[dim][dim], CoordType precision=numeric_constants< CoordType >::epsilon())
Set the values of the elements of the matrix.
CoordType determinant() const
Get the determinant of the matrix.
Generic library namespace.
double CoordType
Basic floating point type.
RotMatrix< dim > InvProd(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1^-1 * m2
RotMatrix< dim > Prod(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2
RotMatrix< dim > InvProdInv(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1^-1 * m2^-1
RotMatrix< dim > ProdInv(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2^-1
RotMatrix< dim > operator*(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2