Algebra3D
Algebra for 3D transformations
|
A class to store 3x3 rotation matrices. More...
#include <Matrix3.h>
Public Member Functions | |
Matrix3 (bool identity=false) | |
Matrix3 (const fpType(&data)[3][3]) | |
Matrix3 (const fpType *data) | |
Matrix3 (const Vector3< fpType > &col1, const Vector3< fpType > &col2, const Vector3< fpType > &col3) | |
Matrix3 (fpType m11, fpType m12, fpType m13, fpType m21, fpType m22, fpType m23, fpType m31, fpType m32, fpType m33) | |
Matrix3 (const Matrix3< fpType > &mat) | |
Matrix3 (const Vector3< fpType > &cvec) | |
Matrix3 (Vector3< fpType > axis, fpType angle) | |
Matrix3 (const Quaternion< fpType > &quat) | |
virtual | ~Matrix3 () |
virtual void | set (const fpType data[3][3]) |
virtual void | set (const Vector3< fpType > &col1, const Vector3< fpType > &col2, const Vector3< fpType > &col3) |
virtual void | get (fpType storage[3][3]) const |
virtual void | get (fpType *const col1, fpType *const col2, fpType *const col3) const |
virtual void | setColumn (int index, const Vector3< fpType > &col) |
virtual void | getColumn (int index, fpType *const &col) |
virtual Vector3< fpType > | getColumn (int index) |
fpType | getTrace () const |
virtual void | transpose () |
virtual Matrix3 | getTranspose () const |
Vector3< fpType > | getAxis () const |
fpType | getAngle () const |
virtual void | invert () |
virtual Matrix3 | getInverse () const |
virtual fpType | det () |
virtual bool | isOrthogonal () |
virtual void | operator= (const Matrix3 &mat) |
virtual const fpType(& | operator[] (int i1) const)[3] |
virtual fpType(& | operator[] (int i1))[3] |
virtual bool | compare (const Matrix3< fpType > &mat, const fpType &precision=PRECISION) const |
virtual bool | operator== (const Matrix3 &mat) const |
virtual bool | operator!= (const Matrix3 &mat) const |
virtual void | operator+= (const Matrix3 &mat) |
virtual Matrix3 | operator+ (const Matrix3 &mat) const |
virtual Matrix3 | operator- () const |
virtual void | operator-= (const Matrix3 &mat) |
virtual Matrix3 | operator- (const Matrix3 &mat) const |
virtual void | operator*= (const Matrix3 &mat) |
virtual Matrix3 | operator* (const Matrix3 &mat) const |
virtual Vector3< fpType > | operator* (const Vector3< fpType > &vec) const |
virtual void | operator*= (const fpType &scale) |
virtual Matrix3 | operator* (const fpType &scale) const |
virtual void | operator/= (const fpType &scale) |
virtual Matrix3 | operator/ (const fpType &scale) const |
Protected Member Functions | |
virtual void | initialize (bool identity=false) |
Protected Attributes | |
fpType | data [3][3] |
Static Protected Attributes | |
static const int | ADJUGATE_INDICES [3][3][4][2] |
Friends | |
template<class fpT > | |
std::istream & | operator>> (std::istream &stream, Matrix3< fpT > &mat) |
A class to store 3x3 rotation matrices.
Column first storage convention is used here. It is not limited to SO(3) matrices.
algebra3d::Matrix3< fpType >::Matrix3 | ( | bool | identity = false | ) |
Creates an instance of a matrix. The parameter defines if identity (true
) or zero matrix (false
) is requested.
[in] | identity | identity true or zero matrix false is requested; false by default. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | const fpType(&) | data[3][3] | ) |
Creates an instance using the provided data. Data is stored by columns (Matrix::data[2][0] is third column first row)
[in] | data | Reference to the data to set the matrix to. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | const fpType * | data | ) |
Creates an instance using the provided data. First 9 positions. are read: first 3 - first column, second 3 - second column, third 3 - third column.
[in] | data | Reference to the data to set the matrix to. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | const Vector3< fpType > & | col1, |
const Vector3< fpType > & | col2, | ||
const Vector3< fpType > & | col3 | ||
) |
Creates an instance using the provided vectors as columns. Data is stored by columns, so Matrix::data[0] becomes the fist vector, Matrix::data[1] the second and so on.
[in] | col1 | The first column of the matrix. |
[in] | col2 | The second column of the matrix. |
[in] | col3 | The third column of the matrix. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | fpType | m11, |
fpType | m12, | ||
fpType | m13, | ||
fpType | m21, | ||
fpType | m22, | ||
fpType | m23, | ||
fpType | m31, | ||
fpType | m32, | ||
fpType | m33 | ||
) |
Creates an instance using the provided values.
[in] | m11 | The element to becomeMatrix::data[0][0]. |
[in] | m12 | The element to becomeMatrix::data[1][0]. |
[in] | m13 | The element to becomeMatrix::data[2][0]. |
[in] | m21 | The element to becomeMatrix::data[0][1]. |
[in] | m22 | The element to becomeMatrix::data[1][1]. |
[in] | m23 | The element to becomeMatrix::data[2][1]. |
[in] | m31 | The element to becomeMatrix::data[0][2]. |
[in] | m32 | The element to becomeMatrix::data[1][2]. |
[in] | m33 | The element to becomeMatrix::data[2][2]. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | const Matrix3< fpType > & | mat | ) |
Copies elements of the provided matrix into this one.
[in] | mat | The matrix to copy. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | const Vector3< fpType > & | cvec | ) |
Creates a rotation matrix for the provided Cayley vector.
[in] | cvec | The Cayley vector describing the rotation. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | Vector3< fpType > | axis, |
fpType | angle | ||
) |
Creates a rotation matrix for the provided axis (not necessarily unit length) and angle (in radians).
[in] | axis | The rotation axis (of any length). |
[in] | angle | The rotation angle in radians. |
algebra3d::Matrix3< fpType >::Matrix3 | ( | const Quaternion< fpType > & | quat | ) |
Creates a rotation matrix for the provided quaternion.
[in] | quat | The rotation axis (of any length). |
|
virtual |
Does nothing. Virtual classes require virtual destructors.
|
virtual |
Checks if all elements of the provided matrix are the same as in this one up to the provided precision. The comparison is simply checking if the difference between numbers is smaller or equal the precision.
[in] | mat | The matrix to compare this with. |
[in] | precision | The precision to use; by default the global PRECISION is used. |
true
if all entries are equal up to the precision, false
otherwise.
|
virtual |
Returns the determinant of this matrix.
|
virtual |
Copies the matrix data to the provided array.
[out] | storage | The array to copy the data to. |
|
virtual |
Copies the matrix data to the provided arrays. Each array is assumed to be at least of size [3].
[out] | col1 | Storage for the first column of the matrix. |
[out] | col2 | Storage for the second column of the matrix. |
[out] | col3 | Storage for the third column of the matrix. |
fpType algebra3d::Matrix3< fpType >::getAngle | ( | ) | const |
Returns the angle of the rotation this matrix represents. If the matrix is not orthogonal this may result in an error.
Vector3<fpType> algebra3d::Matrix3< fpType >::getAxis | ( | ) | const |
Returns the unit axis vector of the rotation this matrix represents. For identity and zero vector is returned. For rotation by PI infinity vector. If the matrix is not orthogonal this may result in an error.
|
virtual |
Copies data of the column with the provided index to the provided array.
[in] | index | Index of the column to copy. |
[out] | col | The storage place to copy to. |
|
virtual |
Returns the requested column as a vector.
[in] | index | Index of the column to copy. |
|
virtual |
Returns the inverse of this matrix. If the determinant is close to 0 zero matrix is returned.
fpType algebra3d::Matrix3< fpType >::getTrace | ( | ) | const |
Returns the trace of the matrix.
|
virtual |
Returns the transpose of this matrix.
|
protectedvirtual |
Initializes the instance of a matrix. Used by constructors. The parameter defines if identity (true
) or zero matrix (false
) is requested.
[in] | identity | identity true or zero matrix false is requested; false by default. |
|
virtual |
Inverts this matrix. If the determinant is close to 0.0 the matrix is set to 0.
|
virtual |
Returns true
if the matrix is orthogonal, false
otherwise.
true
if the matrix is orthogonal, false
otherwise.
|
virtual |
Checks if any element of this matrix differs from respective element of the parameter.
[in] | mat | The matrix to compare this with. |
false
if all entries are equal, true
otherwise.
|
virtual |
Post-multiplies a copy of this matrix by the provided one and returns the result.
[in] | mat | The matrix to post-multiply this by. |
|
virtual |
Returns the product of this matrix and the provided vector. (m * v - vector treated as 3x1).
[in] | vec | The vector to pre-multiply by this matrix. |
|
virtual |
Scales a copy of this matrix by the provided number and returns it.
[in] | scale | The scaling factor. |
|
virtual |
Post-multiplies this matrix by the provided one.
[in] | mat | The matrix to post-multiply this by. |
|
virtual |
Scales a this matrix by the provided number.
[in] | scale | The scaling factor. |
|
virtual |
Returns the sum of this matrix and the provided one.
[in] | mat | The other argument of the sum. |
|
virtual |
Adds the provided matrix to this one.
[in] | mat | The matrix to add. |
|
virtual |
Returns a copy of this matrix multiplied by -1.
|
virtual |
Returns the result of subtracting the provided matrix from this one.
[in] | mat | The matrix to subtract. |
|
virtual |
Subtracts the provided matrix from this one.
[in] | mat | The matrix to subtract. |
|
virtual |
Scales a copy of this matrix by the inverse of the provided number and returns it.
[in] | scale | The inverse scaling factor. |
|
virtual |
Scales a this matrix by the inverse of the provided number.
[in] | scale | The inverse scaling factor. |
|
virtual |
Copies elements of the provided matrix into this one.
[in] | mat | The matrix to copy. |
|
virtual |
Comparing operator. Checks if all elements of the provided matrix are the same as this.
[in] | mat | The matrix to compare this with. |
true
if all entries are equal, false
otherwise.
|
virtual |
Returns a reference to the column with the provided index. If the index is incorrect the closest correct one is used is returned. Version for constant instances.
[in] | i1 | Index of the column of the element to return. |
NULL
for incorrect index.
|
virtual |
Returns a reference to the column with the provided index. If the index is incorrect NULL
is returned.
[in] | i1 | Index of the column of the element to return. |
NULL
for incorrect index.
|
virtual |
Sets the matrix data to the values in the provided array.
[in] | data | The array with values to set. |
|
virtual |
Sets the matrix data to the data provided as column vectors.
[in] | col1 | The first column of the matrix. |
[in] | col2 | The second column of the matrix. |
[in] | col3 | The third column of the matrix. |
|
virtual |
Sets the column with the provided index to the provided vector.
[in] | index | Index of the column to set. |
[in] | col | The column data. |
|
virtual |
Transposes this matrix.
|
staticprotected |
Indices for computing adjugate matrix. The indices are:
|
protected |
The matrix data.