Gamedev Framework (gf)  0.4.0
A C++11 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 (T xx, T xy, T yx, T yy)
 Constructor that takes all the elements. More...
 

Public Attributes

union gf::Matrix< T, 2, 2 >:: { ... }  
 
T grid [2][2]
 Grid representation. More...
 
T data [4]
 Array representation. More...
 
T xx
 
T xy
 
T yx
 
T yy
 

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

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

The value type of the elements of the matrix.

Constructor & Destructor Documentation

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

Default constructor.

template<typename T >
constexpr gf::Matrix< T, 2, 2 >::Matrix ( T  xx,
T  xy,
T  yx,
T  yy 
)
inline

Constructor that takes all the elements.

Parameters
xxThe element in the first row and first column
xyThe element in the first row and second column
yxThe element in the second row and first column
yyThe element in the second row and second column

Member Data Documentation

union { ... }

An anonymous union to handle the various representations

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

The number of columns in the matrix.

template<typename T >
T gf::Matrix< T, 2, 2 >::data[4]

Array representation.

template<typename T >
T gf::Matrix< T, 2, 2 >::grid[2][2]

Grid representation.

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

The number of rows in the matrix.

template<typename T >
T gf::Matrix< T, 2, 2 >::xx
template<typename T >
T gf::Matrix< T, 2, 2 >::xy
template<typename T >
T gf::Matrix< T, 2, 2 >::yx
template<typename T >
T gf::Matrix< T, 2, 2 >::yy