Loading...
Searching...
No Matches
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T > Class Template Reference

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.
 
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.
 

Detailed Description

template<typename T>
class ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >

A 4x4 matrix class.

Constructor & Destructor Documentation

◆ Matrix4() [1/5]

◆ Matrix4() [2/5]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4 ( const Matrix4< T > & _m)
inline

Copy constructor.

Parameters
_mMatrix to copy

◆ Matrix4() [3/5]

template<typename T >
ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::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 )
inline

Constructor.

Parameters
[in]_v00Row 0, Col 0 value
[in]_v01Row 0, Col 1 value
[in]_v02Row 0, Col 2 value
[in]_v03Row 0, Col 3 value
[in]_v10Row 1, Col 0 value
[in]_v11Row 1, Col 1 value
[in]_v12Row 1, Col 2 value
[in]_v13Row 1, Col 3 value
[in]_v20Row 2, Col 0 value
[in]_v21Row 2, Col 1 value
[in]_v22Row 2, Col 2 value
[in]_v23Row 2, Col 3 value
[in]_v30Row 3, Col 0 value
[in]_v31Row 3, Col 1 value
[in]_v32Row 3, Col 2 value
[in]_v33Row 3, Col 3 value

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Set().

◆ Matrix4() [4/5]

◆ Matrix4() [5/5]

◆ ~Matrix4()

template<typename T >
virtual ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::~Matrix4 ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ Axis()

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Axis ( const Vector3< T > & _axis,
T _angle )
inline

Set the upper-left 3x3 matrix from an axis and angle.

Parameters
[in]_axisthe axis
[in]_angleccw 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().

◆ Determinant()

template<typename T >
T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Determinant ( ) const
inline

Return the determinant of the matrix.

Returns
Determinant of this matrix.

◆ Equal()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Equal ( const Matrix4< T > & _m,
const T & _tol ) const
inline

Equality test with tolerance.

Parameters
[in]_mthe matrix to compare to
[in]_tolequality tolerance.
Returns
true if the elements of the matrices are equal within the tolerence specified by _tol.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::equal().

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator==().

◆ EulerRotation()

template<typename T >
Vector3< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::EulerRotation ( bool _firstSolution) const
inline

Get the rotation as a Euler angles.

Parameters
[in]_firstSolutionTrue to get the first Euler solution, false to get the second.
Returns
the rotation

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().

◆ IGN_DEPRECATED() [1/3]

template<typename T >
Vector3< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IGN_DEPRECATED ( 3. 0) const &
inline

Perform an affine transformation.

Parameters
[in]_vVector3 value for the transformation
Returns
The result of the transformation. A default constructed Vector3<T> is returned if this matrix is not affine.
Deprecated
Use bool TransformAffine(const Vector3<T> &_v, Vector3<T> &_result) const;

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IsAffine().

◆ IGN_DEPRECATED() [2/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IGN_DEPRECATED ( 4 ) const &
inline

Set the translational values [ (0, 3) (1, 3) (2, 3) ].

Parameters
[in]_tValues to set
Deprecated
Use SetTranslation instead

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::SetTranslation().

◆ IGN_DEPRECATED() [3/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IGN_DEPRECATED ( 4 )

Set the translational values [ (0, 3) (1, 3) (2, 3) ].

Parameters
[in]_xX translation value.
[in]_yY translation value.
[in]_zZ translation value.
Deprecated
Use SetTranslation instead

◆ Inverse()

template<typename T >
Matrix4< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Inverse ( ) const
inline

Return the inverse matrix.

This is a non-destructive operation.

Returns
Inverse of this matrix.

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::OrientedBox< T >::Contains().

◆ IsAffine()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::IsAffine ( ) const
inline

◆ LookAt()

template<typename T >
static Matrix4< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::LookAt ( const Vector3< T > & _eye,
const Vector3< T > & _target,
const Vector3< T > & _up = Vector3<T>::UnitZ )
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,

Parameters
[in]_eyeCoordinate frame translation.
[in]_targetPoint which the X axis should face. If _target is equal to _eye, the X axis won't be rotated.
[in]_upDirection in which the Z axis should point. If _up is zero or parallel to X, it will be set to +Z.
Returns
Transformation matrix.

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().

◆ operator!=()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator!= ( const Matrix4< T > & _m) const
inline

Inequality test operator.

Parameters
[in]_mMatrix4<T> to test
Returns
True if not equal (using the default tolerance of 1e-6)

◆ operator()() [1/2]

template<typename T >
T & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator() ( const size_t _row,
const size_t _col )
inline

Get a mutable version the value at the specified row, column index.

Parameters
[in]_colThe column index. Index values are clamped to a range of [0, 3].
[in]_rowthe row index. Index values are clamped to a range of [0, 3].
Returns
The value at the specified index

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.

◆ operator()() [2/2]

template<typename T >
const T & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator() ( const size_t _row,
const size_t _col ) const
inline

Get the value at the specified row, column index.

Parameters
[in]_colThe column index. Index values are clamped to a range of [0, 3].
[in]_rowthe row index. Index values are clamped to a range of [0, 3].
Returns
The value at the specified index

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.

◆ operator*() [1/2]

template<typename T >
Matrix4< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator* ( const Matrix4< T > & _m2) const
inline

Multiplication operator.

Parameters
_matIncoming matrix
Returns
This matrix * _mat

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4().

◆ operator*() [2/2]

template<typename T >
Vector3< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator* ( const Vector3< T > & _vec) const
inline

◆ operator=() [1/2]

template<typename T >
const Matrix4< T > & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator= ( const Matrix3< T > & _mat)
inline

Equal operator for 3x3 matrix.

Parameters
_matIncoming matrix
Returns
itself

◆ operator=() [2/2]

template<typename T >
Matrix4< T > & ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator= ( const Matrix4< T > & _mat)
inline

Equal operator.

this = _mat

Parameters
_matIncoming matrix
Returns
itself

◆ operator==()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::operator== ( const Matrix4< T > & _m) const
inline

Equality operator.

Parameters
[in]_mMatrix3 to test
Returns
true if the 2 matrices are equal (using the tolerance 1e-6), false otherwise

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Equal().

◆ Pose()

◆ Rotation()

template<typename T >
Quaternion< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Rotation ( ) const
inline

Get the rotation as a quaternion.

Returns
the rotation

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().

◆ Scale() [1/3]

template<typename T >
Vector3< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Scale ( ) const
inline

Get the scale values as a Vector3<T>

Returns
x,y,z scale values

◆ Scale() [2/3]

◆ Scale() [3/3]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Scale ( T _x,
T _y,
T _z )
inline

Set the scale.

Parameters
[in]_xX scale value.
[in]_yY scale value.
[in]_zZ scale value.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_y, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_z.

◆ Set()

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::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 )
inline

Change the values.

Parameters
[in]_v00Row 0, Col 0 value
[in]_v01Row 0, Col 1 value
[in]_v02Row 0, Col 2 value
[in]_v03Row 0, Col 3 value
[in]_v10Row 1, Col 0 value
[in]_v11Row 1, Col 1 value
[in]_v12Row 1, Col 2 value
[in]_v13Row 1, Col 3 value
[in]_v20Row 2, Col 0 value
[in]_v21Row 2, Col 1 value
[in]_v22Row 2, Col 2 value
[in]_v23Row 2, Col 3 value
[in]_v30Row 3, Col 0 value
[in]_v31Row 3, Col 1 value
[in]_v32Row 3, Col 2 value
[in]_v33Row 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().

◆ SetTranslation() [1/2]

◆ SetTranslation() [2/2]

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::SetTranslation ( T _x,
T _y,
T _z )
inline

Set the translational values [ (0, 3) (1, 3) (2, 3) ].

Parameters
[in]_xX translation value.
[in]_yY translation value.
[in]_zZ translation value.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_y, and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_z.

◆ TransformAffine()

template<typename T >
bool ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::TransformAffine ( const Vector3< T > & _v,
Vector3< T > & _result ) const
inline

Perform an affine transformation.

Parameters
[in]_vVector3 value for the transformation
[out]_resultThe result of the transformation. _result is not changed if this matrix is not affine.
Returns
True if this matrix is affine, false otherwise.

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().

◆ Translation()

template<typename T >
Vector3< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Translation ( ) const
inline

Get the translational values as a Vector3.

Returns
x,y,z translation values

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Pose().

◆ Transpose()

template<typename T >
void ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Transpose ( )
inline

Transpose this matrix.

◆ Transposed()

template<typename T >
Matrix4< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Transposed ( ) const
inline

Return the transpose of this matrix.

Returns
Transpose of this matrix.

References ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Matrix4().

Member Data Documentation

◆ _y

◆ _z

template<typename T >
void T T ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::_z
Initial value:
{
this->SetTranslation(_x, _y, _z)
void SetTranslation(const Vector3< T > &_t)
Set the translational values [ (0, 3) (1, 3) (2, 3) ].
Definition Matrix4.hh:197

Referenced by ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Scale(), and ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::SetTranslation().

◆ Identity

template<typename T >
const Matrix4< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Identity
static

Identity matrix.

◆ Zero

template<typename T >
const Matrix4< T > ignition::math::IGNITION_MATH_VERSION_NAMESPACE::Matrix4< T >::Zero
static

Zero matrix.


The documentation for this class was generated from the following file: