Gamedev Framework (gf)  0.9.0
A C++14 framework for 2D games
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
gf::Matrix< T, 2, 2 > Struct Template Reference

A 2x2 matrix. More...

#include <gf/Matrix.h>

Public Types

using value_type = T
 The value type of the elements of the matrix. More...
 

Public Member Functions

 Matrix ()=default
 Default constructor. More...
 
constexpr Matrix (ZeroType) noexcept
 
constexpr Matrix (T val) noexcept
 
constexpr Matrix (const T *array)
 
constexpr Matrix (T e11, T e12, T e21, T e22) noexcept
 Constructor that takes all the elements. More...
 
const TgetData () const noexcept
 
TgetData () noexcept
 
T operator() (std::size_t row, std::size_t col) const
 
Toperator() (std::size_t row, std::size_t col)
 
constexpr void zero () noexcept
 

Public Attributes

union gf::Matrix< T, 2, 2 >:: { ... }  
 
union gf::Matrix< T, 2, 2 >:: { ... }  
 
union gf::Matrix< T, 2, 2 >:: { ... }  
 
union gf::Matrix< T, 2, 2 >:: { ... }  
 
T xx
 
T m11
 
T xy
 
T m12
 
T yx
 
T m21
 
T yy
 
T m22
 

Static Public Attributes

static constexpr std::size_t Rows = 2
 The number of rows in the matrix. More...
 
static constexpr std::size_t Cols = 2
 The number of columns in the matrix. More...
 

Detailed Description

template<typename T>
struct gf::Matrix< T, 2, 2 >

A 2x2 matrix.

This specialization of gf::Matrix handles linear transformation of 2D vectors. As translation is not a linear transformation but an affine transformation, this specialization is not used in the library. Instead use a gf::Matrix<T, 3, 3>. It is provided for convinience.

Each element of the matrix can be accessed through a name with a double letter indicating the column and row of the element (e.g. xy indicates the first row and second column).

A common typedef is defined:

Member Typedef Documentation

◆ value_type

template<typename T >
using gf::Matrix< T, 2, 2 >::value_type = T

The value type of the elements of the matrix.

Constructor & Destructor Documentation

◆ Matrix() [1/5]

template<typename T >
gf::Matrix< T, 2, 2 >::Matrix ( )
default

Default constructor.

◆ Matrix() [2/5]

template<typename T >
constexpr gf::Matrix< T, 2, 2 >::Matrix ( ZeroType  )
inlinenoexcept

◆ Matrix() [3/5]

template<typename T >
constexpr gf::Matrix< T, 2, 2 >::Matrix ( T  val)
inlineexplicitnoexcept

◆ Matrix() [4/5]

template<typename T >
constexpr gf::Matrix< T, 2, 2 >::Matrix ( const T array)
inlineexplicit

◆ Matrix() [5/5]

template<typename T >
constexpr gf::Matrix< T, 2, 2 >::Matrix ( T  e11,
T  e12,
T  e21,
T  e22 
)
inlinenoexcept

Constructor that takes all the elements.

Parameters
e11The element in the first row and first column
e12The element in the first row and second column
e21The element in the second row and first column
e22The element in the second row and second column

Member Function Documentation

◆ getData() [1/2]

template<typename T >
const T* gf::Matrix< T, 2, 2 >::getData ( ) const
inlinenoexcept

◆ getData() [2/2]

template<typename T >
T* gf::Matrix< T, 2, 2 >::getData ( )
inlinenoexcept

◆ operator()() [1/2]

template<typename T >
T gf::Matrix< T, 2, 2 >::operator() ( std::size_t  row,
std::size_t  col 
) const
inline

◆ operator()() [2/2]

template<typename T >
T& gf::Matrix< T, 2, 2 >::operator() ( std::size_t  row,
std::size_t  col 
)
inline

◆ zero()

template<typename T >
constexpr void gf::Matrix< T, 2, 2 >::zero ( )
inlinenoexcept

Member Data Documentation

◆ @11

union { ... }

◆ @13

union { ... }

◆ @7

union { ... }

◆ @9

union { ... }

◆ Cols

template<typename T >
constexpr std::size_t gf::Matrix< T, 2, 2 >::Cols = 2
static

The number of columns in the matrix.

◆ m11

template<typename T >
T gf::Matrix< T, 2, 2 >::m11

◆ m12

template<typename T >
T gf::Matrix< T, 2, 2 >::m12

◆ m21

template<typename T >
T gf::Matrix< T, 2, 2 >::m21

◆ m22

template<typename T >
T gf::Matrix< T, 2, 2 >::m22

◆ Rows

template<typename T >
constexpr std::size_t gf::Matrix< T, 2, 2 >::Rows = 2
static

The number of rows in the matrix.

◆ xx

template<typename T >
T gf::Matrix< T, 2, 2 >::xx

◆ xy

template<typename T >
T gf::Matrix< T, 2, 2 >::xy

◆ yx

template<typename T >
T gf::Matrix< T, 2, 2 >::yx

◆ yy

template<typename T >
T gf::Matrix< T, 2, 2 >::yy