Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::TMatrix44< T > Class Template Reference

Generic 4 x 4 matrix template. More...

#include <TMatrix44.h>

Collaboration diagram for sf::TMatrix44< T >:

Classes

union  data_type
 Storage union of the 4x4 matrix as array and 4 x4 array. It is initialized as a unit-matrix. More...
 

Public Types

enum  EAxis : unsigned int { axisX = 0 , axisY = 1 , axisZ = 2 , axisT = 3 }
 Enumerate for identifying a matrix axis. More...
 
typedef T value_type
 Type accessible when implemented.
 

Public Member Functions

 TMatrix44 ()=default
 Default constructor which is by default a unit-matrix.
 
 TMatrix44 (T m00, T m01, T m02, T m03, T m10, T m11, T m12, T m13, T m20, T m21, T m22, T m23, T m30, T m31, T m32, T m33)
 Initialization constructor for 16 single floating point values.
 
 TMatrix44 (std::initializer_list< T[4]> list)
 Constructor using an initializer list.
 
 TMatrix44 (const T[4][4])
 Initialization constructor for 4x4 floating point values.
 
 TMatrix44 (const T *)
 Initialization constructor for 16 floating point values.
 
 TMatrix44 (const TVector3D< T > &tv)
 Construct from a translation vector. Construct a translation transformation from a given 3D Vector.
 
 TMatrix44 (T tilt, T pan, T roll)
 Construct from rotations.
 
 TMatrix44 (const TQuaternion< T > &q)
 Construct from quaternion rotation.
 
 TMatrix44 (const TMatrix44 &)
 Copy constructor.
 
 TMatrix44 (TMatrix44 &&) noexcept
 Move constructor.
 
TMatrix44unit ()
 Set or resets this instance as unit/identity matrix. A unit matrix, also known as the identity matrix, is a square matrix in which all the elements along the main diagonal (from the top-left to the bottom-right) are 1, and all other elements are 0. It acts as the multiplicative identity in matrix algebra, meaning that multiplying any matrix by the identity matrix results in the original matrix itself.
 
determinant () const
 Gets the 3x3 determinant from this instance.
 
TMatrix44invert ()
 Inverts this matrix.
 
TMatrix44 inverse () const
 Gets the inverted version of this instance. Call the method invert() to do this.
 
TMatrix44 transposed () const
 Get a transposed matrix of this instance.
 
TMatrix44transpose ()
 Transpose this matrix.
 
TMatrix44assign (const T[4][4])
 Assigns the 4x4 array structure to this matrix.
 
TMatrix44assign (const T *)
 Assigns the 16 values from pointer to this matrix.
 
TMatrix44transposeAssign (const T[4][4])
 Assigns the transposed 4x4 array structure to this matrix.
 
TMatrix44operator= (const TMatrix44 &)
 Assignment operator.
 
TMatrix44operator= (TMatrix44 &&m) noexcept
 Assignment move operator.
 
TMatrix44operator*= (const TMatrix44 &)
 Applies passed matrix on the axes of this matrix.
 
TVector3D< T > operator* (const TVector3D< T > &) const
 Applies matrix on the passed 3D vector.
 
value_typedata ()
 Gets the pointer to the array of this matrix.
 
const value_typedata () const
 Gets the pointer to the array of this matrix.
 
 operator T* ()
 Cast operator to pointer of type 'T'.
 
 operator const T * () const
 Cast operator to pointer of type 'T'.
 
bool isEqual (const TMatrix44 &m, T tol=tolerance) const
 Compares the passed matrix within the set tolerance.
 
bool isRotational () const
 Determines if the matrix is a rotation matrix.
 
bool operator== (const TMatrix44 &) const
 Compare equal operator using the tolerance when comparing.
 
bool operator!= (const TMatrix44 &) const
 Compare unequal operator using the tolerance when comparing.
 
void copyTo (T[4][4]) const
 Copies the matrix to a 4x4 array.
 
void copyTo (T *) const
 Copies the matrix to a 16 deep array.
 
void transposeCopyTo (T[4][4]) const
 Transposed copy to a 4x4 array for compatibility with OpenGL.
 
TMatrix44setTiltPanRoll (T tilt, T pan, T roll)
 Sets/resets rotation part of the matrix according to tilt pan roll and does not touch the translation or scaling part.
 
void getTiltPanRoll (T &tilt, T &pan, T &roll) const
 Translates rotation part of matrix to tilt, pan and roll values.
 
TMatrix44rotate (T angle, const TVector3D< T > &vec, bool only=true)
 Applies rotation on the current matrix around a vector.
 
TMatrix44rotate (T angle, T x, T y, T z, bool only=true)
 Applies rotation on the current matrix.
 
TMatrix44 rotated (T angle, T x, T y, T z, bool only=true) const
 Same as rotate() but only returns the changed matrix and does not affect this matrix.
 
TMatrix44 rotated (T angle, const TVector3D< T > &vec, bool only=true) const
 Same as rotate() but only returns the changed matrix and does not affect this matrix.
 
void setPerspectiveProjection (T near_plane, T far_plane, T fov)
 Sets the projection for this matrix.
 
TMatrix44multiply (const TMatrix44 &m)
 Multiplies this matrix with the passed one so that the given matrix is applied on the matrix axes.
 
TMatrix44 multiplied (const TMatrix44 &m) const
 Same as multiply() but returns the changed matrix and does not affect this matrix.
 
TMatrix44rotate (const TMatrix44 &m)
 Multiplies this matrix only with the 3x3 part of the given matrix applying only rotation and scaling.
 
TMatrix44 rotated (const TMatrix44 &m) const
 Same as rotate() but returns the changed matrix and does not affect this matrix.
 
TVector3D< T > transformed (const TVector3D< T > &v) const
 Applies the matrix rotation up on a 3D-vector.
 
void clearTranslation ()
 Zero's or clears translation part of this instance.
 
TMatrix44translate (const TVector3D< T > &v)
 Adds a translation vector of this instance using a 3D vector.
 
TMatrix44translate (T x, T y, T z)
 Adds the translation vector of this instance using individual.
 
TMatrix44 translated (const TVector3D< T > &v) const
 Same as translate() but does not change this matrix only returns the translated one.
 
TMatrix44 translated (T x, T y, T z) const
 Same as translate() but does not change this matrix only returns the translated one.
 
TVector3D< T > getTranslation () const
 Gets translation part of matrix.
 
TMatrix44 setTranslation (const TVector3D< T > &v)
 Sets translation part of this matrix.
 
TVector3D< T > getAxis (EAxis axis) const
 Gets given axis of matrix as a 3D vector.
 
TMatrix44 orbit (T horizontal, T vertical) const
 Gets transformation of rotation around local x- and y-axis of current matrix.
 
TMatrix44 orientation () const
 Gets the orientation part of matrix.
 
void setElement (unsigned int column, unsigned int row, T value)
 Sets the element specified by the row and column.
 
element (unsigned int column, unsigned int row) const
 Gets the element specified by the row and column.
 
T & element (unsigned int column, unsigned int row)
 Gets the element reference specified by the row and column.
 
T & operator() (int row, int column)
 Function operator for row column value manipulations. This is different from the element() method.
 
operator() (int row, int column) const
 Gets the element from row and column index. This is different from the element() method.
 
template<typename R >
void toOpenGL (R *matrix) const
 Copies this matrix to a column-major matrix array compatible with OpenGL standard. A one on one copy is not possible and a transpose of the 3x3 matrix part within is needed.
 
template<typename R >
std::array< R, 16 > toOpenGL () const
 Gets a column-major matrix array buffer compatible with OpenGL standard. Essentially converts from a row-major to column-major and OpenGL compatible matrix. Useful when calling OpenGL functions glLoadMatrix[fd]() and glMultMatrix[fd]().
 
template<typename R >
TMatrix44assignOpenGL (const R *matrix)
 Assigns a row-major matrix array compatible with OpenGL standard to this instance. A one on one copy is not possible and a transpose of the 3x3 matrix part within is needed. Essentially converts from a OpenGL column-major to this row-major matrix.
 
TQuaternion< T > quaternion () const
 Convert rotation matrix part to identity or unit quaternion. Calls sf::TQuaternion::fromMatrix()
 
TMatrix44resetOrientation ()
 Resets the orientation and leaves the translation as is.
 
TMatrix44setOrientationXY (const TVector3D< T > &x_axis, const TVector3D< T > &y_axis)
 Set orientation using 2 direction vectors. y-axis direction dominates x-axis (x-axis is corrected if x-axis and y-axis not perpendicular)
 
TMatrix44setOrientationZY (const TVector3D< T > &z_axis, const TVector3D< T > &y_axis)
 Set orientation using 2 direction vectors. The z-axis direction dominates y-axis (y-axis is corrected if y & z not perpendicular)
 
TMatrix44insertGIGRotXYZ (T rx, T ry, T rz)
 Another way of applying rotation to the matrix.
 
std::string toString () const
 Gets the string representation of the matrix formed like '({m00,m01,m02,m03},{m10,m11,m12,m13},{m20,m21,m22,m23},{m30,m31,m32,m33})'.
 
TMatrix44fromString (const std::string &s) noexcept(false)
 Gets matrix values from the string representation formed like '({1,2,3,4},{11,12,13,14},{21,22,23,24},{31,32,33,34})'. Throws an exception when the string is not in the correct format.
 

Static Public Member Functions

template<typename R >
static TMatrix44 fromOpenGL (const R *matrix)
 Creates a instance from a row-major matrix array compatible with OpenGL standard. Essentially converts from a OpenGL column-major to this row-major matrix.
 

Static Public Attributes

static constexpr auto tolerance = TVector3D<T>::tolerance
 Tolerance for when comparing in the equal operator.
 

Protected Attributes

union sf::TMatrix44::data_type _data = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}
 

Detailed Description

template<typename T>
class sf::TMatrix44< T >

Generic 4 x 4 matrix template.

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T sf::TMatrix44< T >::value_type

Type accessible when implemented.

Member Enumeration Documentation

◆ EAxis

template<typename T >
enum sf::TMatrix44::EAxis : unsigned int

Enumerate for identifying a matrix axis.

Enumerator
axisX 

X-axis of the matrix.

axisY 

Y-axis of the matrix.

axisZ 

Z-axis of the matrix.

axisT 

Translation axis of the matrix.

Constructor & Destructor Documentation

◆ TMatrix44() [1/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( )
default

Default constructor which is by default a unit-matrix.

◆ TMatrix44() [2/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( m00,
m01,
m02,
m03,
m10,
m11,
m12,
m13,
m20,
m21,
m22,
m23,
m30,
m31,
m32,
m33 
)

Initialization constructor for 16 single floating point values.

◆ TMatrix44() [3/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( std::initializer_list< T[4]>  list)

Constructor using an initializer list.

◆ TMatrix44() [4/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( const T  [4][4])
explicit

Initialization constructor for 4x4 floating point values.

◆ TMatrix44() [5/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( const T *  )
explicit

Initialization constructor for 16 floating point values.

◆ TMatrix44() [6/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( const TVector3D< T > &  tv)
explicit

Construct from a translation vector. Construct a translation transformation from a given 3D Vector.

◆ TMatrix44() [7/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( tilt,
pan,
roll 
)

Construct from rotations.

See also
setTiltPanRoll()

◆ TMatrix44() [8/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( const TQuaternion< T > &  q)
explicit

Construct from quaternion rotation.

◆ TMatrix44() [9/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( const TMatrix44< T > &  )

Copy constructor.

◆ TMatrix44() [10/10]

template<typename T >
sf::TMatrix44< T >::TMatrix44 ( TMatrix44< T > &&  )
noexcept

Move constructor.

Member Function Documentation

◆ assign() [1/2]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::assign ( const T *  )

Assigns the 16 values from pointer to this matrix.

Returns
This matrix.

◆ assign() [2/2]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::assign ( const T  [4][4])

Assigns the 4x4 array structure to this matrix.

Returns
This matrix.

◆ assignOpenGL()

template<typename T >
template<typename R >
TMatrix44 & sf::TMatrix44< T >::assignOpenGL ( const R *  matrix)

Assigns a row-major matrix array compatible with OpenGL standard to this instance. A one on one copy is not possible and a transpose of the 3x3 matrix part within is needed. Essentially converts from a OpenGL column-major to this row-major matrix.

Template Parameters
RType of the array pointer.
Returns
Itself.

◆ clearTranslation()

template<typename T >
void sf::TMatrix44< T >::clearTranslation ( )

Zero's or clears translation part of this instance.

◆ copyTo() [1/2]

template<typename T >
void sf::TMatrix44< T >::copyTo ( T *  ) const

Copies the matrix to a 16 deep array.

◆ copyTo() [2/2]

template<typename T >
void sf::TMatrix44< T >::copyTo ( [4][4]) const

Copies the matrix to a 4x4 array.

◆ data() [1/2]

template<typename T >
value_type * sf::TMatrix44< T >::data ( )

Gets the pointer to the array of this matrix.

Returns
Pointer.

◆ data() [2/2]

template<typename T >
const value_type * sf::TMatrix44< T >::data ( ) const

Gets the pointer to the array of this matrix.

Returns
Pointer.

◆ determinant()

template<typename T >
T sf::TMatrix44< T >::determinant ( ) const

Gets the 3x3 determinant from this instance.

Returns
Determinant 3x3 value.

◆ element() [1/2]

template<typename T >
T & sf::TMatrix44< T >::element ( unsigned int  column,
unsigned int  row 
)

Gets the element reference specified by the row and column.

Parameters
columnRow number between 0 and 3.
rowColumn number between 0 and 3.
Returns
Matrix element value.

◆ element() [2/2]

template<typename T >
T sf::TMatrix44< T >::element ( unsigned int  column,
unsigned int  row 
) const

Gets the element specified by the row and column.

Parameters
columnRow number between 0 and 3.
rowColumn number between 0 and 3.
Returns
Matrix element value.

◆ fromOpenGL()

template<typename T >
template<typename R >
static TMatrix44 sf::TMatrix44< T >::fromOpenGL ( const R *  matrix)
static

Creates a instance from a row-major matrix array compatible with OpenGL standard. Essentially converts from a OpenGL column-major to this row-major matrix.

Template Parameters
RType of the array pointer.
Parameters
matrixArray pointer expected to be at least of 16 length.
Returns
Itself.

◆ fromString()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::fromString ( const std::string &  s)

Gets matrix values from the string representation formed like '({1,2,3,4},{11,12,13,14},{21,22,23,24},{31,32,33,34})'. Throws an exception when the string is not in the correct format.

Exceptions
std::invalid_argument

◆ getAxis()

template<typename T >
TVector3D< T > sf::TMatrix44< T >::getAxis ( EAxis  axis) const

Gets given axis of matrix as a 3D vector.

Parameters
axisRequested axis.
Returns
3D-vector.

◆ getTiltPanRoll()

template<typename T >
void sf::TMatrix44< T >::getTiltPanRoll ( T &  tilt,
T &  pan,
T &  roll 
) const

Translates rotation part of matrix to tilt, pan and roll values.

Note
Only valid for rotation matrices without scaling info!
Parameters
tiltTilt angle in radians.
panPan angle in radians.
rollRoll angle in radians.

◆ getTranslation()

template<typename T >
TVector3D< T > sf::TMatrix44< T >::getTranslation ( ) const

Gets translation part of matrix.

Returns
Translation vector.

◆ insertGIGRotXYZ()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::insertGIGRotXYZ ( rx,
ry,
rz 
)

Another way of applying rotation to the matrix.

Parameters
rxX in Radians.
ryY in Radians
rzZ in Radians.

◆ inverse()

template<typename T >
TMatrix44 sf::TMatrix44< T >::inverse ( ) const

Gets the inverted version of this instance. Call the method invert() to do this.

Exceptions
std::range_error
See also
invert()

◆ invert()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::invert ( )

Inverts this matrix.

Exceptions
std::range_error

◆ isEqual()

template<typename T >
bool sf::TMatrix44< T >::isEqual ( const TMatrix44< T > &  m,
tol = tolerance 
) const

Compares the passed matrix within the set tolerance.

Parameters
mMatrix to compare with.
tolThe tolerance when comparing which has a default.
Returns
True when equal.

◆ isRotational()

template<typename T >
bool sf::TMatrix44< T >::isRotational ( ) const

Determines if the matrix is a rotation matrix.

Returns

◆ multiplied()

template<typename T >
TMatrix44 sf::TMatrix44< T >::multiplied ( const TMatrix44< T > &  m) const

Same as multiply() but returns the changed matrix and does not affect this matrix.

Returns
This matrix reference.

◆ multiply()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::multiply ( const TMatrix44< T > &  m)

Multiplies this matrix with the passed one so that the given matrix is applied on the matrix axes.

Returns
This matrix reference.

◆ operator const T *()

template<typename T >
sf::TMatrix44< T >::operator const T * ( ) const

Cast operator to pointer of type 'T'.

Returns
Const pointer.

◆ operator T*()

template<typename T >
sf::TMatrix44< T >::operator T* ( )

Cast operator to pointer of type 'T'.

Returns
Pointer.

◆ operator!=()

template<typename T >
bool sf::TMatrix44< T >::operator!= ( const TMatrix44< T > &  ) const

Compare unequal operator using the tolerance when comparing.

Returns
True when unequal.

◆ operator()() [1/2]

template<typename T >
T & sf::TMatrix44< T >::operator() ( int  row,
int  column 
)

Function operator for row column value manipulations. This is different from the element() method.

Parameters
rowRow index.
columnColumn index.
Returns
Reference to the value.

◆ operator()() [2/2]

template<typename T >
T sf::TMatrix44< T >::operator() ( int  row,
int  column 
) const

Gets the element from row and column index. This is different from the element() method.

Parameters
rowRow index.
columnColumn index.
Returns
Value of the element.

◆ operator*()

template<typename T >
TVector3D< T > sf::TMatrix44< T >::operator* ( const TVector3D< T > &  ) const

Applies matrix on the passed 3D vector.

Returns
Modified 3D-vector.

◆ operator*=()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::operator*= ( const TMatrix44< T > &  )

Applies passed matrix on the axes of this matrix.

Returns
This modified matrix.

◆ operator=() [1/2]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::operator= ( const TMatrix44< T > &  )

Assignment operator.

◆ operator=() [2/2]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::operator= ( TMatrix44< T > &&  m)
noexcept

Assignment move operator.

◆ operator==()

template<typename T >
bool sf::TMatrix44< T >::operator== ( const TMatrix44< T > &  ) const

Compare equal operator using the tolerance when comparing.

Returns
True when equal.

◆ orbit()

template<typename T >
TMatrix44 sf::TMatrix44< T >::orbit ( horizontal,
vertical 
) const

Gets transformation of rotation around local x- and y-axis of current matrix.

Parameters
horizontal
vertical
Returns
The matrix.

◆ orientation()

template<typename T >
TMatrix44 sf::TMatrix44< T >::orientation ( ) const

Gets the orientation part of matrix.

◆ quaternion()

template<typename T >
TQuaternion< T > sf::TMatrix44< T >::quaternion ( ) const

Convert rotation matrix part to identity or unit quaternion. Calls sf::TQuaternion::fromMatrix()

Returns
A Quaternion instance.

◆ resetOrientation()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::resetOrientation ( )

Resets the orientation and leaves the translation as is.

Returns
This instance reference.

◆ rotate() [1/3]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::rotate ( const TMatrix44< T > &  m)

Multiplies this matrix only with the 3x3 part of the given matrix applying only rotation and scaling.

Returns
This matrix reference.

◆ rotate() [2/3]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::rotate ( angle,
const TVector3D< T > &  vec,
bool  only = true 
)

Applies rotation on the current matrix around a vector.

Parameters
angleAngle f rotation in radians.
vecVector to rotating around.
onlyWhen true it only rotates and leaves the translation untouched.
Returns
Itself.

◆ rotate() [3/3]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::rotate ( angle,
x,
y,
z,
bool  only = true 
)

Applies rotation on the current matrix.

Parameters
angleAngle of rotation in radians.
xRotation around the horizontal (x-axis).
yRotation around the vertical (y-axis).
zRotation around the forward (z-axis).
onlyWhen true it only rotates and leaves the translation untouched.
Returns
Itself.

◆ rotated() [1/3]

template<typename T >
TMatrix44 sf::TMatrix44< T >::rotated ( const TMatrix44< T > &  m) const

Same as rotate() but returns the changed matrix and does not affect this matrix.

Returns
This matrix reference.

◆ rotated() [2/3]

template<typename T >
TMatrix44 sf::TMatrix44< T >::rotated ( angle,
const TVector3D< T > &  vec,
bool  only = true 
) const

Same as rotate() but only returns the changed matrix and does not affect this matrix.

Parameters
angleAngle of rotation.
vecVector to rotating around.
onlyWhen true it only rotates and leaves the translation untouched.
Returns
Rotated matrix.

◆ rotated() [3/3]

template<typename T >
TMatrix44 sf::TMatrix44< T >::rotated ( angle,
x,
y,
z,
bool  only = true 
) const

Same as rotate() but only returns the changed matrix and does not affect this matrix.

Parameters
angleAngle of rotation.
xRotation around the horizontal (x-axis).
yRotation around the vertical (y-axis).
zRotation around the forward (z-axis).
onlyWhen true it only rotates and leaves the translation untouched.
Returns
Rotated matrix.

◆ setElement()

template<typename T >
void sf::TMatrix44< T >::setElement ( unsigned int  column,
unsigned int  row,
value 
)

Sets the element specified by the row and column.

Parameters
columnRow number between 0 and 3.
rowColumn number between 0 and 3.
valueElement value.

◆ setOrientationXY()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::setOrientationXY ( const TVector3D< T > &  x_axis,
const TVector3D< T > &  y_axis 
)

Set orientation using 2 direction vectors. y-axis direction dominates x-axis (x-axis is corrected if x-axis and y-axis not perpendicular)

Parameters
x_axis
y_axis
Returns
This instance reference.
Exceptions
std::invalid_argument

◆ setOrientationZY()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::setOrientationZY ( const TVector3D< T > &  z_axis,
const TVector3D< T > &  y_axis 
)

Set orientation using 2 direction vectors. The z-axis direction dominates y-axis (y-axis is corrected if y & z not perpendicular)

Parameters
z_axis
y_axis
Returns
This instance reference.
Exceptions
std::invalid_argument

◆ setPerspectiveProjection()

template<typename T >
void sf::TMatrix44< T >::setPerspectiveProjection ( near_plane,
far_plane,
fov 
)

Sets the projection for this matrix.

Parameters
near_planeNear plane of the camera frustum.
far_planeFar plane of the camera frustum.
fovField of view in radians.
See also
https://learnwebgl.brown37.net/08_projections/projections_perspective.html

◆ setTiltPanRoll()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::setTiltPanRoll ( tilt,
pan,
roll 
)

Sets/resets rotation part of the matrix according to tilt pan roll and does not touch the translation or scaling part.

Parameters
tiltTilt is a rotation around the horizontal (x-axis).
panPan is a rotation around the vertical (y-axis).
rollRoll is a rotation around the forward (z-axis).
Returns
This matrix.

◆ setTranslation()

template<typename T >
TMatrix44 sf::TMatrix44< T >::setTranslation ( const TVector3D< T > &  v)

Sets translation part of this matrix.

Returns
Itself.

◆ toOpenGL() [1/2]

template<typename T >
template<typename R >
std::array< R, 16 > sf::TMatrix44< T >::toOpenGL ( ) const

Gets a column-major matrix array buffer compatible with OpenGL standard. Essentially converts from a row-major to column-major and OpenGL compatible matrix. Useful when calling OpenGL functions glLoadMatrix[fd]() and glMultMatrix[fd]().

Template Parameters
RType of the array.
Returns
A column-major matrix array buffer.

◆ toOpenGL() [2/2]

template<typename T >
template<typename R >
void sf::TMatrix44< T >::toOpenGL ( R *  matrix) const

Copies this matrix to a column-major matrix array compatible with OpenGL standard. A one on one copy is not possible and a transpose of the 3x3 matrix part within is needed.

Template Parameters
RType of the pointer.
Parameters
matrixArray pointer expected to be at least of 16 length.
Returns
A column-major matrix array.

◆ toString()

template<typename T >
std::string sf::TMatrix44< T >::toString ( ) const

Gets the string representation of the matrix formed like '({m00,m01,m02,m03},{m10,m11,m12,m13},{m20,m21,m22,m23},{m30,m31,m32,m33})'.

◆ transformed()

template<typename T >
TVector3D< T > sf::TMatrix44< T >::transformed ( const TVector3D< T > &  v) const

Applies the matrix rotation up on a 3D-vector.

Parameters
v3D vector.
Returns
Rotated and translated 3D-vector.

◆ translate() [1/2]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::translate ( const TVector3D< T > &  v)

Adds a translation vector of this instance using a 3D vector.

◆ translate() [2/2]

template<typename T >
TMatrix44 & sf::TMatrix44< T >::translate ( x,
y,
z 
)

Adds the translation vector of this instance using individual.

◆ translated() [1/2]

template<typename T >
TMatrix44 sf::TMatrix44< T >::translated ( const TVector3D< T > &  v) const

Same as translate() but does not change this matrix only returns the translated one.

◆ translated() [2/2]

template<typename T >
TMatrix44 sf::TMatrix44< T >::translated ( x,
y,
z 
) const

Same as translate() but does not change this matrix only returns the translated one.

◆ transpose()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::transpose ( )

Transpose this matrix.

Returns
This matrix

◆ transposeAssign()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::transposeAssign ( const T  [4][4])

Assigns the transposed 4x4 array structure to this matrix.

Returns
This matrix.

◆ transposeCopyTo()

template<typename T >
void sf::TMatrix44< T >::transposeCopyTo ( [4][4]) const

Transposed copy to a 4x4 array for compatibility with OpenGL.

◆ transposed()

template<typename T >
TMatrix44 sf::TMatrix44< T >::transposed ( ) const

Get a transposed matrix of this instance.

Returns
Transposed matrix.

◆ unit()

template<typename T >
TMatrix44 & sf::TMatrix44< T >::unit ( )

Set or resets this instance as unit/identity matrix. A unit matrix, also known as the identity matrix, is a square matrix in which all the elements along the main diagonal (from the top-left to the bottom-right) are 1, and all other elements are 0. It acts as the multiplicative identity in matrix algebra, meaning that multiplying any matrix by the identity matrix results in the original matrix itself.

Returns
Itself.

Member Data Documentation

◆ _data

template<typename T >
union sf::TMatrix44::data_type sf::TMatrix44< T >::_data = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}
protected

◆ tolerance

template<typename T >
constexpr auto sf::TMatrix44< T >::tolerance = TVector3D<T>::tolerance
staticconstexpr

Tolerance for when comparing in the equal operator.

Used as: std::fabs(x1 - x2) < tolerance


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