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) {}
92 RotMatrix(
const RotMatrix& m) =
default;
94 friend std::ostream& operator<< <dim>(std::ostream& os,
const RotMatrix& m);
95 friend std::istream&
operator>> <dim>(std::istream& is, RotMatrix& m);
97 RotMatrix& operator=(
const RotMatrix& m) =
default;
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();}
281 #endif // WFMATH_ROTMATRIX_H RotMatrix & rotation(int i, int j, CoordType theta)
set the matrix to a rotation by the angle theta in the (i, j) plane
Generic library namespace.
void normalize()
normalize to remove accumulated round-off error
static FloatType epsilon()
This is the attempted precision of the library.
unsigned age() const
current round-off age
RotMatrix & mirrorX()
set a RotMatrix to a mirror perpendicular to the x axis
RotMatrix< dim > InvProdInv(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1^-1 * m2^-1
RotMatrix & rotationX(CoordType theta)
3D only: set a RotMatrix to a rotation about the x axis by angle theta
Vector< dim > column(int i) const
Get a copy of the i'th column as a Vector.
A dim dimensional rotation matrix. Technically, a member of the group O(dim).
double CoordType
Basic floating point type.
RotMatrix & rotation(CoordType theta)
2D only: Construct a RotMatrix from an angle theta
RotMatrix< dim > InvProd(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1^-1 * m2
RotMatrix & rotate(const RotMatrix &m)
rotate the matrix using another matrix
RotMatrix & mirrorY()
set a RotMatrix to a mirror perpendicular to the y axis
A dim dimensional 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
bool setVals(const CoordType vals[dim][dim], CoordType precision=numeric_constants< CoordType >::epsilon())
Set the values of the elements of the matrix.
RotMatrix & fromQuaternion(const Quaternion &q, bool not_flip=true)
3D only: set a RotMatrix from a Quaternion
CoordType determinant() const
Get the determinant of the matrix.
Vector< dim > row(int i) const
Get a copy of the i'th row as a Vector.
RotMatrix & mirror()
set the matrix to mirror all axes
RotMatrix & identity()
set the matrix to the identity matrix
bool parity() const
Get the parity of the matrix.
friend RotMatrix Prod(const RotMatrix &m1, const RotMatrix &m2)
returns m1 * m2
RotMatrix< dim > operator*(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2
RotMatrix & mirrorZ()
set a RotMatrix to a mirror perpendicular to the z axis
RotMatrix< dim > ProdInv(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2^-1
RotMatrix< dim > Prod(const RotMatrix< dim > &m1, const RotMatrix< dim > &m2)
returns m1 * m2
CoordType elem(const int i, const int j) const
get the (i, j) element of the matrix
CoordType trace() const
Get the trace of the matrix.
RotMatrix inverse() const
Get the inverse of the matrix.