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

Generic 2 x 2 matrix template. More...

#include <TMatrix22.h>

Collaboration diagram for sf::TMatrix22< T >:

Classes

union  data_type
 Storage union of the 2x2 matrix. More...
 

Public Types

typedef T value_type
 Type accessible when implemented.
 

Public Member Functions

 TMatrix22 ()
 Default constructor.
 
 TMatrix22 (const TMatrix22 &m)
 Copy constructor.
 
 TMatrix22 (TMatrix22 &&) noexcept
 Move constructor.
 
 TMatrix22 (std::initializer_list< T > list)
 Initializer list constructor.
 
 TMatrix22 (T m00, T m01, T m10, T m11)
 Initializing constructor.
 
 TMatrix22 (T scale_x, T scale_y)
 Scaling constructor.
 
 TMatrix22 (T angle)
 Constructs a rotation matrix passing a single angle.
 
TMatrix22 transposed () const
 Gets the transposed version of the matrix. A transposed rotation matrix inverts the rotation.
 
TMatrix22assign (const T[2][2])
 Assignment using a 2 by 2 array.
 
TMatrix22assign (value_type m00, value_type m01, value_type m10, value_type m11)
 Assignment using 4 separate values.
 
TMatrix22operator= (const TMatrix22 &m)
 Assignment operator.
 
TMatrix22operator= (TMatrix22 &&m) noexcept
 Assignment move operator.
 
TMatrix22operator*= (const TMatrix22 &m)
 Vector transformation operator.
 
TVector2D< T > transformed (const TVector2D< T > &) const
 Vector transformation method.
 
TVector2D< T > operator* (const TVector2D< T > &) const
 Vector transformation operator.
 
constexpr operator T* ()
 Pointer cast operators.
 
constexpr operator const T * () const
 Const pointer cast operators.
 
bool isEqual (const TMatrix22 &m, T tol=tolerance) const
 Compares the passed matrix within the set tolerance.
 
bool operator== (const TMatrix22 &) const
 Compare equal operator using the tolerance for comparing.
 
bool operator!= (const TMatrix22 &) const
 Compare unequal operator using the tolerance for comparing.
 
TMatrix22resetOrientation ()
 Reset the matrix to the so-called 'identity' matrix where a vector is not changed during transformation.
 
void setRotation (T angle)
 Sets the rotation for the matrix.
 
getRotation () const
 Gets the rotation of the matrix when it is a square matrix.
 
std::string toString () const
 Gets the string representation of the matrix formed like '((m00,m01),(m10,m11))'.
 
TMatrix22fromString (const std::string &s) noexcept(false)
 Gets matrix values from the string representation formed like '({1.2,4.5},{5.6,7.8})'. Throws an exception when the string is not in the correct format.
 
void copyTo (T[2][2]) const
 Copy to matrix to 2 by 2 value_type array.
 

Static Public Attributes

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

Protected Attributes

union sf::TMatrix22::data_type _data = {0, 0, 0, 0}
 

Detailed Description

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

Generic 2 x 2 matrix template.

Member Typedef Documentation

◆ value_type

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

Type accessible when implemented.

Constructor & Destructor Documentation

◆ TMatrix22() [1/7]

template<typename T >
sf::TMatrix22< T >::TMatrix22 ( )

Default constructor.

◆ TMatrix22() [2/7]

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

Copy constructor.

◆ TMatrix22() [3/7]

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

Move constructor.

◆ TMatrix22() [4/7]

template<typename T >
sf::TMatrix22< T >::TMatrix22 ( std::initializer_list< T >  list)

Initializer list constructor.

◆ TMatrix22() [5/7]

template<typename T >
sf::TMatrix22< T >::TMatrix22 ( m00,
m01,
m10,
m11 
)

Initializing constructor.

◆ TMatrix22() [6/7]

template<typename T >
sf::TMatrix22< T >::TMatrix22 ( scale_x,
scale_y 
)

Scaling constructor.

◆ TMatrix22() [7/7]

template<typename T >
sf::TMatrix22< T >::TMatrix22 ( angle)
explicit

Constructs a rotation matrix passing a single angle.

Parameters
angleangle of rotation.

Member Function Documentation

◆ assign() [1/2]

template<typename T >
TMatrix22 & sf::TMatrix22< T >::assign ( const T  [2][2])

Assignment using a 2 by 2 array.

Returns
The matrix itself.

◆ assign() [2/2]

template<typename T >
TMatrix22 & sf::TMatrix22< T >::assign ( value_type  m00,
value_type  m01,
value_type  m10,
value_type  m11 
)

Assignment using 4 separate values.

Returns
The matrix itself.

◆ copyTo()

template<typename T >
void sf::TMatrix22< T >::copyTo ( [2][2]) const

Copy to matrix to 2 by 2 value_type array.

◆ fromString()

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

Gets matrix values from the string representation formed like '({1.2,4.5},{5.6,7.8})'. Throws an exception when the string is not in the correct format.

Exceptions
std::invalid_argument

◆ getRotation()

template<typename T >
T sf::TMatrix22< T >::getRotation ( ) const

Gets the rotation of the matrix when it is a square matrix.

◆ isEqual()

template<typename T >
bool sf::TMatrix22< T >::isEqual ( const TMatrix22< 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.

◆ operator const T *()

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

Const pointer cast operators.

◆ operator T*()

template<typename T >
constexpr sf::TMatrix22< T >::operator T* ( )
constexpr

Pointer cast operators.

◆ operator!=()

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

Compare unequal operator using the tolerance for comparing.

Returns
True when unequal.

◆ operator*()

template<typename T >
TVector2D< T > sf::TMatrix22< T >::operator* ( const TVector2D< T > &  ) const

Vector transformation operator.

Returns
New transformed vector.

◆ operator*=()

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

Vector transformation operator.

Returns
Matrix itself.

◆ operator=() [1/2]

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

Assignment operator.

Returns
Matrix itself.

◆ operator=() [2/2]

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

Assignment move operator.

◆ operator==()

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

Compare equal operator using the tolerance for comparing.

Returns
True when equal.

◆ resetOrientation()

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

Reset the matrix to the so-called 'identity' matrix where a vector is not changed during transformation.

Returns
Matrix itself.

◆ setRotation()

template<typename T >
void sf::TMatrix22< T >::setRotation ( angle)

Sets the rotation for the matrix.

Parameters
angleAngle in radians.

◆ toString()

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

Gets the string representation of the matrix formed like '((m00,m01),(m10,m11))'.

◆ transformed()

template<typename T >
TVector2D< T > sf::TMatrix22< T >::transformed ( const TVector2D< T > &  ) const

Vector transformation method.

Returns
New transformed vector.

◆ transposed()

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

Gets the transposed version of the matrix. A transposed rotation matrix inverts the rotation.

Returns
Transposed matrix.

Member Data Documentation

◆ _data

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

◆ tolerance

template<typename T >
constexpr auto sf::TMatrix22< T >::tolerance = TVector2D<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: