# Ignition Math

## API Reference

6.9.3~pre2
Matrix3< T > Class Template Reference

A 3x3 matrix class. More...

#include <ignition/math/Matrix3.hh>

## Public Member Functions

Matrix3 ()
Constructor. More...

Matrix3 (const Matrix3< T > &_m)
Copy constructor. More...

Matrix3 (T _v00, T _v01, T _v02, T _v10, T _v11, T _v12, T _v20, T _v21, T _v22)
Constructor. More...

Matrix3 (const Quaternion< T > &_q)
Construct Matrix3 from a quaternion. More...

virtual ~Matrix3 ()
Desctructor. More...

void Axes (const Vector3< T > &_xAxis, const Vector3< T > &_yAxis, const Vector3< T > &_zAxis)
Set the matrix from three axis (1 per column) More...

void Axis (const Vector3< T > &_axis, T _angle)
Set the matrix from an axis and angle. More...

void Col (unsigned int _c, const Vector3< T > &_v)
Set a column. More...

Determinant () const
Return the determinant of the matrix. More...

bool Equal (const Matrix3 &_m, const T &_tol) const
Equality test with tolerance. More...

void From2Axes (const Vector3< T > &_v1, const Vector3< T > &_v2)
Set the matrix to represent rotation from vector _v1 to vector _v2, so that _v2.Normalize() == this * _v1.Normalize() holds. More...

Matrix3< T > Inverse () const
Return the inverse matrix. More...

bool operator!= (const Matrix3< T > &_m) const
Inequality test operator. More...

const T & operator() (size_t _row, size_t _col) const
Array subscript operator. More...

T & operator() (size_t _row, size_t _col)
Array subscript operator. More...

Matrix3< T > operator* (const T &_s) const
returns the element wise scalar multiplication More...

Matrix3< T > operator* (const Matrix3< T > &_m) const
Matrix multiplication operator. More...

Vector3< T > operator* (const Vector3< T > &_vec) const
Multiplication operator with Vector3 on the right treated like a column vector. More...

Matrix3< T > operator+ (const Matrix3< T > &_m) const
returns the element wise sum of two matrices More...

Matrix3< T > operator- (const Matrix3< T > &_m) const
returns the element wise difference of two matrices More...

Matrix3< T > & operator= (const Matrix3< T > &_mat)
Equal operator. this = _mat. More...

Matrix3< T > & operator= (const Quaternion< T > &_q)
Set the matrix3 from a quaternion. More...

bool operator== (const Matrix3< T > &_m) const
Equality test operator. More...

void Set (T _v00, T _v01, T _v02, T _v10, T _v11, T _v12, T _v20, T _v21, T _v22)
Set values. More...

void Transpose ()
Transpose this matrix. More...

Matrix3< T > Transposed () const
Return the transpose of this matrix. More...

## Static Public Attributes

static const Matrix3< T > Identity
Identity matrix. More...

static const Matrix3< T > Zero
Zero matrix. More...

## Friends

Matrix3< T > operator* (T _s, const Matrix3< T > &_m)
Matrix multiplication operator for scaling. More...

Vector3< T > operator* (const Vector3< T > &_v, const Matrix3< T > &_m)
Matrix left multiplication operator for Vector3. Treats the Vector3 like a row vector multiplying the matrix from the left. More...

std::ostreamoperator<< (std::ostream &_out, const Matrix3< T > &_m)
Stream insertion operator. More...

std::istreamoperator>> (std::istream &_in, Matrix3< T > &_m)
Stream extraction operator. More...

## Detailed Description

### template<typename T> class ignition::math::Matrix3< T >

A 3x3 matrix class.

## ◆ Matrix3() [1/4]

 Matrix3 ( )
inline

Constructor.

References std::memset().

## ◆ Matrix3() [2/4]

 Matrix3 ( const Matrix3< T > & _m )
inline

Copy constructor.

Parameters
 _m Matrix to copy

References std::memcpy().

## ◆ Matrix3() [3/4]

 Matrix3 ( T _v00, T _v01, T _v02, T _v10, T _v11, T _v12, T _v20, T _v21, T _v22 )
inline

Constructor.

Parameters
 [in] _v00 Row 0, Col 0 value [in] _v01 Row 0, Col 1 value [in] _v02 Row 0, Col 2 value [in] _v10 Row 1, Col 0 value [in] _v11 Row 1, Col 1 value [in] _v12 Row 1, Col 2 value [in] _v20 Row 2, Col 0 value [in] _v21 Row 2, Col 1 value [in] _v22 Row 2, Col 2 value

## ◆ Matrix3() [4/4]

 Matrix3 ( const Quaternion< T > & _q )
inlineexplicit

Construct Matrix3 from a quaternion.

Parameters
 [in] _q Quaternion.

## ◆ ~Matrix3()

 virtual ~Matrix3 ( )
inlinevirtual

Desctructor.

## ◆ Axes()

 void Axes ( const Vector3< T > & _xAxis, const Vector3< T > & _yAxis, const Vector3< T > & _zAxis )
inline

Set the matrix from three axis (1 per column)

Parameters
 [in] _xAxis The x axis [in] _yAxis The y axis [in] _zAxis The z axis

References Matrix3< T >::Col().

## ◆ Axis()

 void Axis ( const Vector3< T > & _axis, T _angle )
inline

Set the matrix from an axis and angle.

Parameters
 [in] _axis the axis [in] _angle ccw rotation around the axis in radians

References Vector3< T >::X(), Vector3< T >::Y(), and Vector3< T >::Z().

Referenced by Matrix3< T >::From2Axes().

## ◆ Col()

 void Col ( unsigned int _c, const Vector3< T > & _v )
inline

Set a column.

Parameters
 [in] _c The colum index [0, 1, 2]. _col is clamped to the range [0, 2]. [in] _v The value to set in each row of the column.

Referenced by Matrix3< T >::Axes().

## ◆ Determinant()

 T Determinant ( ) const
inline

Return the determinant of the matrix.

Returns
Determinant of this matrix.

## ◆ Equal()

 bool Equal ( const Matrix3< T > & _m, const T & _tol ) const
inline

Equality test with tolerance.

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

Referenced by Matrix3< T >::operator==().

## ◆ From2Axes()

 void From2Axes ( const Vector3< T > & _v1, const Vector3< T > & _v2 )
inline

Set the matrix to represent rotation from vector _v1 to vector _v2, so that _v2.Normalize() == this * _v1.Normalize() holds.

Parameters
 [in] _v1 The first vector [in] _v2 The second vector

## ◆ Inverse()

 Matrix3 Inverse ( ) const
inline

Return the inverse matrix.

Returns
Inverse of this matrix.

## ◆ operator!=()

 bool operator!= ( const Matrix3< T > & _m ) const
inline

Inequality test operator.

Parameters
 [in] _m Matrix3 to test
Returns
True if not equal (using the default tolerance of 1e-6)

## ◆ operator()() [1/2]

 const T& operator() ( size_t _row, size_t _col ) const
inline

Array subscript operator.

Parameters
 [in] _row row index. _row is clamped to the range [0,2] [in] _col column index. _col is clamped to the range [0,2]
Returns
a pointer to the row

## ◆ operator()() [2/2]

 T& operator() ( size_t _row, size_t _col )
inline

Array subscript operator.

Parameters
 [in] _row row index. _row is clamped to the range [0,2] [in] _col column index. _col is clamped to the range [0,2]
Returns
a pointer to the row

## ◆ operator*() [1/3]

 Matrix3 operator* ( const T & _s ) const
inline

returns the element wise scalar multiplication

## ◆ operator*() [2/3]

 Matrix3 operator* ( const Matrix3< T > & _m ) const
inline

Matrix multiplication operator.

Parameters
 [in] _m Matrix3 to multiply
Returns
product of this * _m

## ◆ operator*() [3/3]

 Vector3 operator* ( const Vector3< T > & _vec ) const
inline

Multiplication operator with Vector3 on the right treated like a column vector.

Parameters
 _vec Vector3
Returns
Resulting vector from multiplication

References Vector3< T >::X(), Vector3< T >::Y(), and Vector3< T >::Z().

## ◆ operator+()

 Matrix3 operator+ ( const Matrix3< T > & _m ) const
inline

returns the element wise sum of two matrices

## ◆ operator-()

 Matrix3 operator- ( const Matrix3< T > & _m ) const
inline

returns the element wise difference of two matrices

## ◆ operator=() [1/2]

 Matrix3& operator= ( const Matrix3< T > & _mat )
inline

Equal operator. this = _mat.

Parameters
 _mat Incoming matrix
Returns
itself

## ◆ operator=() [2/2]

 Matrix3& operator= ( const Quaternion< T > & _q )
inline

Set the matrix3 from a quaternion.

Parameters
 [in] _q Quaternion to set the matrix3 from.
Returns
Reference to the new matrix3 object.

## ◆ operator==()

 bool operator== ( const Matrix3< T > & _m ) const
inline

Equality test operator.

Parameters
 [in] _m Matrix3 to test
Returns
True if equal (using the default tolerance of 1e-6)

References Matrix3< T >::Equal().

## ◆ Set()

 void Set ( T _v00, T _v01, T _v02, T _v10, T _v11, T _v12, T _v20, T _v21, T _v22 )
inline

Set values.

Parameters
 [in] _v00 Row 0, Col 0 value [in] _v01 Row 0, Col 1 value [in] _v02 Row 0, Col 2 value [in] _v10 Row 1, Col 0 value [in] _v11 Row 1, Col 1 value [in] _v12 Row 1, Col 2 value [in] _v20 Row 2, Col 0 value [in] _v21 Row 2, Col 1 value [in] _v22 Row 2, Col 2 value

Referenced by Matrix3< T >::From2Axes(), and Matrix3< T >::Matrix3().

## ◆ Transpose()

 void Transpose ( )
inline

Transpose this matrix.

References std::swap().

## ◆ Transposed()

 Matrix3 Transposed ( ) const
inline

Return the transpose of this matrix.

Returns
Transpose of this matrix.

## ◆ operator* [1/2]

 Matrix3 operator* ( T _s, const Matrix3< T > & _m )
friend

Matrix multiplication operator for scaling.

Parameters
 [in] _s Scaling factor. [in] _m Input matrix.
Returns
A scaled matrix.

## ◆ operator* [2/2]

 Vector3 operator* ( const Vector3< T > & _v, const Matrix3< T > & _m )
friend

Matrix left multiplication operator for Vector3. Treats the Vector3 like a row vector multiplying the matrix from the left.

Parameters
 [in] _v Input vector. [in] _m Input matrix.
Returns
The product vector.

## ◆ operator<<

 std::ostream& operator<< ( std::ostream & _out, const Matrix3< T > & _m )
friend

Stream insertion operator.

Parameters
 [in] _out Output stream [in] _m Matrix to output
Returns
the stream

## ◆ operator>>

 std::istream& operator>> ( std::istream & _in, Matrix3< T > & _m )
friend

Stream extraction operator.

Parameters
 [in,out] _in input stream [out] _m Matrix3 to read values into
Returns
the stream

## ◆ Identity

 const Matrix3< T > Identity
static

Identity matrix.

## ◆ Zero

 const Matrix3< T > Zero
static

Zero matrix.

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