A 3x3 matrix most often used for storing rotations. More...
#include <matvec3D.h>
Public Member Functions | |
double | determinant () const |
double & | element (int i, int j) |
const double & | element (int i, int j) const |
mat3 | inverse () const |
mat3 (const vec3 &v1, const vec3 &v2, const vec3 &v3) | |
mat3 (const Quaternion &q) | |
mat3 (const double M[9]) | |
mat3 () | |
mat3 const & | operator*= (mat3 const &m) |
mat3 const & | operator+= (mat3 const &v) |
double & | operator[] (int i) |
const double & | operator[] (int i) const |
vec3 | row (int i) const |
void | set (const vec3 &v1, const vec3 &v2, const vec3 &v3) |
void | set (const Quaternion &q) |
void | set (const double M[9]) |
void | setCrossProductMatrix (const vec3 &v) |
void | ToEulerAngles (double &roll, double &pitch, double &yaw) const |
mat3 | transpose () const |
Static Public Attributes | |
static const mat3 | IDENTITY |
A 3x3 identity matrix. | |
static const mat3 | ZERO |
A 3x3 zero matrix. | |
Private Attributes | |
double | mat [9] |
Storage for the matrix. | |
Friends | |
mat3 | operator* (double const &s, mat3 const &m) |
mat3 | operator* (mat3 const &m1, mat3 const &m2) |
vec3 | operator* (vec3 const &v, mat3 const &m) |
vec3 | operator* (mat3 const &m, vec3 const &v) |
std::ostream & | operator<< (std::ostream &os, const mat3 &m) |
std::istream & | operator>> (std::istream &is, mat3 &m) |
A 3x3 matrix most often used for storing rotations.
The matrix is stored as a column-major array.
Definition at line 265 of file matvec3D.h.
mat3::mat3 | ( | ) | [inline] |
Default constructor, matrix is uninitialized.
Definition at line 273 of file matvec3D.h.
mat3::mat3 | ( | const double | M[9] | ) | [inline] |
Copy constructor.
Definition at line 276 of file matvec3D.h.
mat3::mat3 | ( | const Quaternion & | q | ) | [inline] |
Initializes the rotation matrix using the quaternion q.
Definition at line 279 of file matvec3D.h.
Initializes the rotation matrix using the three column vectors v1, v2, v3.
Definition at line 283 of file matvec3D.h.
double mat3::determinant | ( | ) | const [inline] |
Returns the determinant of the matrix.
Definition at line 990 of file matvec3D.h.
double& mat3::element | ( | int | i, | |
int | j | |||
) | [inline] |
Return a reference to matrix element at row i, col j.
Definition at line 299 of file matvec3D.h.
const double& mat3::element | ( | int | i, | |
int | j | |||
) | const [inline] |
Return a constant reference to matrix element at row i, col j.
Definition at line 296 of file matvec3D.h.
mat3 mat3::inverse | ( | ) | const |
Inverts a 3x3 matrix (does not assume matrix is orthonormal)
Definition at line 107 of file matvec.cpp.
Returns this matrix post-multiplied with the matrix m.
Definition at line 130 of file matvec.cpp.
Adds matrix m to this matrix.
Definition at line 1038 of file matvec3D.h.
double& mat3::operator[] | ( | int | i | ) | [inline] |
Return a reference to the i-th element (in column major order) of the matrix.
Definition at line 306 of file matvec3D.h.
const double& mat3::operator[] | ( | int | i | ) | const [inline] |
Return a constant reference to the i-th element (in column major order) of the matrix.
Definition at line 303 of file matvec3D.h.
vec3 mat3::row | ( | int | i | ) | const [inline] |
Return a copy of the i-th row of the matrix as a vector.
Definition at line 309 of file matvec3D.h.
Value of the mat3 is set using the 3 column vectors v1, v2, v3.
Definition at line 961 of file matvec3D.h.
void mat3::set | ( | const Quaternion & | q | ) | [inline] |
Converts a quaternion to a 3x3 rotation matrix and sets the mat3 to this value.
Definition at line 939 of file matvec3D.h.
void mat3::set | ( | const double | M[9] | ) | [inline] |
Copies the matrix M.
Definition at line 286 of file matvec3D.h.
void mat3::setCrossProductMatrix | ( | const vec3 & | v | ) | [inline] |
This matrix becomes the cross product matrix for the given vector. In other words, multiplying a second vector v2 with this matrix is equivalent with perrforming the cross product v2 * v
Definition at line 972 of file matvec3D.h.
void mat3::ToEulerAngles | ( | double & | roll, | |
double & | pitch, | |||
double & | yaw | |||
) | const |
Converts a rotation matrix to the Euler angles roll, pitch, and yaw.
Definition at line 86 of file matvec.cpp.
mat3 mat3::transpose | ( | ) | const [inline] |
Returns a mat3 that is the transpose of this one.
Definition at line 999 of file matvec3D.h.
Scales matrix m by the scalar s.
Definition at line 1020 of file matvec3D.h.
Returns the product of m1 * m2.
Definition at line 151 of file matvec.cpp.
Definition at line 727 of file matvec3D.h.
std::ostream& operator<< | ( | std::ostream & | os, | |
const mat3 & | m | |||
) | [friend] |
Writes the matrix out on 3 lines in the following format:
[ # # #] [ # # #] [ # # #]
Definition at line 497 of file matvec.cpp.
std::istream& operator>> | ( | std::istream & | is, | |
mat3 & | m | |||
) | [friend] |
Reads the 9 consecutive values of a 3x3 matrix in column major format.
Definition at line 480 of file matvec.cpp.
const mat3 mat3::IDENTITY [static] |
A 3x3 identity matrix.
Definition at line 332 of file matvec3D.h.
double mat3::mat[9] [private] |
Storage for the matrix.
Definition at line 268 of file matvec3D.h.
const mat3 mat3::ZERO [static] |
A 3x3 zero matrix.
Definition at line 329 of file matvec3D.h.