A 4x4 matrix class. More...
#include <ignition/math/Matrix4.hh>
Public Member Functions | |
Matrix4 () | |
Constructor. | |
Matrix4 (const Matrix4< T > &_m) | |
Copy constructor. | |
Matrix4 (const Pose3< T > &_pose) | |
Construct Matrix4 from a math::Pose3. | |
Matrix4 (const Quaternion< T > &_q) | |
Construct Matrix4 from a quaternion. | |
Matrix4 (T _v00, T _v01, T _v02, T _v03, T _v10, T _v11, T _v12, T _v13, T _v20, T _v21, T _v22, T _v23, T _v30, T _v31, T _v32, T _v33) | |
Constructor. | |
virtual | ~Matrix4 () |
Destructor. | |
void | Axis (const Vector3< T > &_axis, T _angle) |
Set the upper-left 3x3 matrix from an axis and angle. | |
T | Determinant () const |
Return the determinant of the matrix. | |
bool | Equal (const Matrix4 &_m, const T &_tol) const |
Equality test with tolerance. | |
Vector3< T > | EulerRotation (bool _firstSolution) const |
Get the rotation as a Euler angles. | |
Vector3< T > | IGN_DEPRECATED (3.0) TransformAffine(const Vector3< T > &_v) const |
Perform an affine transformation. | |
void | IGN_DEPRECATED (4) Translate(const Vector3< T > &_t) |
Set the translational values [ (0, 3) (1, 3) (2, 3) ]. | |
void | IGN_DEPRECATED (4) Translate(T _x |
Set the translational values [ (0, 3) (1, 3) (2, 3) ]. | |
Matrix4< T > | Inverse () const |
Return the inverse matrix. | |
bool | IsAffine () const |
Return true if the matrix is affine. | |
bool | operator!= (const Matrix4< T > &_m) const |
Inequality test operator. | |
T & | operator() (const size_t _row, const size_t _col) |
Get a mutable version the value at the specified row, column index. | |
const T & | operator() (const size_t _row, const size_t _col) const |
Get the value at the specified row, column index. | |
Matrix4< T > | operator* (const Matrix4< T > &_m2) const |
Multiplication operator. | |
Vector3< T > | operator* (const Vector3< T > &_vec) const |
Multiplication operator. | |
const Matrix4< T > & | operator= (const Matrix3< T > &_mat) |
Equal operator for 3x3 matrix. | |
Matrix4< T > & | operator= (const Matrix4< T > &_mat) |
Equal operator. | |
bool | operator== (const Matrix4< T > &_m) const |
Equality operator. | |
Pose3< T > | Pose () const |
Get the transformation as math::Pose. | |
Quaternion< T > | Rotation () const |
Get the rotation as a quaternion. | |
Vector3< T > | Scale () const |
Get the scale values as a Vector3<T> | |
void | Scale (const Vector3< T > &_s) |
Set the scale. | |
void | Scale (T _x, T _y, T _z) |
Set the scale. | |
void | Set (T _v00, T _v01, T _v02, T _v03, T _v10, T _v11, T _v12, T _v13, T _v20, T _v21, T _v22, T _v23, T _v30, T _v31, T _v32, T _v33) |
Change the values. | |
void | SetTranslation (const Vector3< T > &_t) |
Set the translational values [ (0, 3) (1, 3) (2, 3) ]. | |
void | SetTranslation (T _x, T _y, T _z) |
Set the translational values [ (0, 3) (1, 3) (2, 3) ]. | |
bool | TransformAffine (const Vector3< T > &_v, Vector3< T > &_result) const |
Perform an affine transformation. | |
Vector3< T > | Translation () const |
Get the translational values as a Vector3. | |
void | Transpose () |
Transpose this matrix. | |
Matrix4< T > | Transposed () const |
Return the transpose of this matrix. | |
Static Public Member Functions | |
static Matrix4< T > | LookAt (const Vector3< T > &_eye, const Vector3< T > &_target, const Vector3< T > &_up=Vector3< T >::UnitZ) |
Get transform which translates to _eye and rotates the X axis so it faces the _target. | |
Public Attributes | |
void T | _y |
void T T | _z |
Static Public Attributes | |
static const Matrix4< T > | Identity |
Identity matrix. | |
static const Matrix4< T > | Zero |
Zero matrix. | |
A 4x4 matrix class.
|
inline |
|
inline |
Copy constructor.
_m | Matrix to copy |
|
inline |
Constructor.
[in] | _v00 | Row 0, Col 0 value |
[in] | _v01 | Row 0, Col 1 value |
[in] | _v02 | Row 0, Col 2 value |
[in] | _v03 | Row 0, Col 3 value |
[in] | _v10 | Row 1, Col 0 value |
[in] | _v11 | Row 1, Col 1 value |
[in] | _v12 | Row 1, Col 2 value |
[in] | _v13 | Row 1, Col 3 value |
[in] | _v20 | Row 2, Col 0 value |
[in] | _v21 | Row 2, Col 1 value |
[in] | _v22 | Row 2, Col 2 value |
[in] | _v23 | Row 2, Col 3 value |
[in] | _v30 | Row 3, Col 0 value |
[in] | _v31 | Row 3, Col 1 value |
[in] | _v32 | Row 3, Col 2 value |
[in] | _v33 | Row 3, Col 3 value |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Set().
|
inlineexplicit |
Construct Matrix4 from a quaternion.
[in] | _q | Quaternion. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::Normalize(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Set(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::W(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::Z().
|
inlineexplicit |
Construct Matrix4 from a math::Pose3.
[in] | _pose | Pose. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Pose3< T >::Pos(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::SetTranslation().
|
inlinevirtual |
Destructor.
|
inline |
Set the upper-left 3x3 matrix from an axis and angle.
[in] | _axis | the axis |
[in] | _angle | ccw rotation around the axis in radians |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().
|
inline |
Return the determinant of the matrix.
|
inline |
Equality test with tolerance.
[in] | _m | the matrix to compare to |
[in] | _tol | equality tolerance. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::equal().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator==().
|
inline |
Get the rotation as a Euler angles.
[in] | _firstSolution | True to get the first Euler solution, false to get the second. |
References IGN_PI, ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().
|
inline |
Perform an affine transformation.
[in] | _v | Vector3 value for the transformation |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IsAffine().
|
inline |
Set the translational values [ (0, 3) (1, 3) (2, 3) ].
[in] | _t | Values to set |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::SetTranslation().
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IGN_DEPRECATED | ( | 4 | ) |
Set the translational values [ (0, 3) (1, 3) (2, 3) ].
[in] | _x | X translation value. |
[in] | _y | Y translation value. |
[in] | _z | Z translation value. |
|
inline |
Return the inverse matrix.
This is a non-destructive operation.
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::OrientedBox< T >::Contains().
|
inline |
Return true if the matrix is affine.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::equal().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IGN_DEPRECATED(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::TransformAffine().
|
inlinestatic |
Get transform which translates to _eye and rotates the X axis so it faces the _target.
The rotation is such that Z axis is in the _up direction, if possible. The coordinate system is right-handed,
[in] | _eye | Coordinate frame translation. |
[in] | _target | Point which the X axis should face. If _target is equal to _eye, the X axis won't be rotated. |
[in] | _up | Direction in which the Z axis should point. If _up is zero or parallel to X, it will be set to +Z. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Cross(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Normalize(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().
|
inline |
Inequality test operator.
[in] | _m | Matrix4<T> to test |
|
inline |
Get a mutable version the value at the specified row, column index.
[in] | _col | The column index. Index values are clamped to a range of [0, 3]. |
[in] | _row | the row index. Index values are clamped to a range of [0, 3]. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_THREE_SIZE_T, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T.
|
inline |
Get the value at the specified row, column index.
[in] | _col | The column index. Index values are clamped to a range of [0, 3]. |
[in] | _row | the row index. Index values are clamped to a range of [0, 3]. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::clamp(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_THREE_SIZE_T, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::IGN_ZERO_SIZE_T.
|
inline |
Multiplication operator.
_mat | Incoming matrix |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4().
|
inline |
Multiplication operator.
_vec | Vector3 |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().
|
inline |
Equal operator for 3x3 matrix.
_mat | Incoming matrix |
|
inline |
Equal operator.
this = _mat
_mat | Incoming matrix |
|
inline |
Equality operator.
[in] | _m | Matrix3 to test |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Equal().
|
inline |
Get the transformation as math::Pose.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Rotation(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Translation().
|
inline |
Get the rotation as a quaternion.
algorithm from Ogre::Quaternion<T> source, which in turn is based on Ken Shoemake's article "Quaternion<T> Calculus and Fast Animation".
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::W(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Quaternion< T >::Z().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Pose().
|
inline |
Get the scale values as a Vector3<T>
|
inline |
Set the scale.
[in] | _s | scale |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().
|
inline |
Set the scale.
[in] | _x | X scale value. |
[in] | _y | Y scale value. |
[in] | _z | Z scale value. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_y, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_z.
|
inline |
Change the values.
[in] | _v00 | Row 0, Col 0 value |
[in] | _v01 | Row 0, Col 1 value |
[in] | _v02 | Row 0, Col 2 value |
[in] | _v03 | Row 0, Col 3 value |
[in] | _v10 | Row 1, Col 0 value |
[in] | _v11 | Row 1, Col 1 value |
[in] | _v12 | Row 1, Col 2 value |
[in] | _v13 | Row 1, Col 3 value |
[in] | _v20 | Row 2, Col 0 value |
[in] | _v21 | Row 2, Col 1 value |
[in] | _v22 | Row 2, Col 2 value |
[in] | _v23 | Row 2, Col 3 value |
[in] | _v30 | Row 3, Col 0 value |
[in] | _v31 | Row 3, Col 1 value |
[in] | _v32 | Row 3, Col 2 value |
[in] | _v33 | Row 3, Col 3 value |
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4().
|
inline |
Set the translational values [ (0, 3) (1, 3) (2, 3) ].
[in] | _t | Values to set |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IGN_DEPRECATED().
|
inline |
Set the translational values [ (0, 3) (1, 3) (2, 3) ].
[in] | _x | X translation value. |
[in] | _y | Y translation value. |
[in] | _z | Z translation value. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_y, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_z.
|
inline |
Perform an affine transformation.
[in] | _v | Vector3 value for the transformation |
[out] | _result | The result of the transformation. _result is not changed if this matrix is not affine. |
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IsAffine(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Set(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::X(), ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Y(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Vector3< T >::Z().
|
inline |
Get the translational values as a Vector3.
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Pose().
|
inline |
Transpose this matrix.
|
inline |
Return the transpose of this matrix.
References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4().
void T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_y |
void T T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_z |
Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Scale(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::SetTranslation().
|
static |
Identity matrix.
|
static |
Zero matrix.