HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Static Public Member Functions | Friends
tt::mat Class Reference

#include <TTauri/Foundation/mat.hpp>

Data Structures

struct  S
 Optimized scale matrix. More...
 
struct  T
 Optimized translate matrix. More...
 
struct  T2
 Optimized 2D translate matrix. More...
 

Public Member Functions

tt_force_inline mat () noexcept
 Create an identity matrix.
 
tt_force_inline mat (mat const &rhs) noexcept=default
 
tt_force_inline matoperator= (mat const &rhs) noexcept=default
 
tt_force_inline mat (mat &&rhs) noexcept=default
 
tt_force_inline matoperator= (mat &&rhs) noexcept=default
 
tt_force_inline mat (vec col0, vec col1, vec col2, vec col3=vec{0.0f, 0.0f, 0.0f, 1.0f}) noexcept
 Create a matrix for 4 vector-columns.
 
tt_force_inline mat (float i00, float i10, float i20, float i30, float i01, float i11, float i21, float i31, float i02, float i12, float i22, float i32, float i03, float i13, float i23, float i33)
 Construct a matrix from the individual values.
 
constexpr size_t size () noexcept
 
template<size_t I>
tt_force_inline vecget () noexcept
 
template<size_t I>
tt_force_inline vec get () const noexcept
 
bool is_z_rot90 () const noexcept
 Rotation around z axis is a multiple of 90 degree.
 

Static Public Member Functions

static mat I () noexcept
 Create an identity matrix.
 
static mat RGBtoXYZ (float wx, float wy, float rx, float ry, float gx, float gy, float bx, float by) noexcept
 
static mat shear (float _00, float _01, float _10, float _11) noexcept
 Create a 2D shearing matrix.
 
template<int N = 2, typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
static mat R (T rhs) noexcept
 Create a rotation matrix.
 
static mat::T align (aarect haystack, aarect needle, Alignment alignment) noexcept
 Align a rectangle within another rectangle.
 
static mat uniform2D_scale_and_translate (aarect haystack, aarect needle, Alignment alignment) noexcept
 

Friends

tt_force_inline friend vec operator* (mat const &lhs, vec const &rhs) noexcept
 Matrix/Vector multiplication.
 
tt_force_inline friend rect operator* (mat const &lhs, aarect const &rhs) noexcept
 Matrix/aarect multiplication.
 
tt_force_inline friend rect operator* (mat const &lhs, rect const &rhs) noexcept
 Matrix/rect multiplication.
 
mat operator* (mat const &lhs, mat const &rhs) noexcept
 Matrix/Matrix multiplication.
 
mat operator* (S const &lhs, mat const &rhs) noexcept
 Scale/Matrix multiplication.
 
mat operator* (T const &lhs, mat const &rhs) noexcept
 Translate/Matrix multiplication.
 
mat transpose (mat rhs) noexcept
 Matrix transpose.
 
mat operator~ (mat const &rhs)
 Invert matrix.
 
bool operator== (mat const &lhs, mat const &rhs) noexcept
 
bool operator!= (mat const &lhs, mat const &rhs) noexcept
 
std::string to_string (mat const &rhs) noexcept
 
std::ostreamoperator<< (std::ostream &lhs, mat const &rhs) noexcept
 

Detailed Description

A 4x4 matrix.

You can use this to transform vec (which has 4 elements)

Constructor & Destructor Documentation

◆ mat() [1/3]

tt_force_inline tt::mat::mat ( )
inlinenoexcept

Create an identity matrix.

◆ mat() [2/3]

tt_force_inline tt::mat::mat ( vec col0,
vec col1,
vec col2,
vec col3 = vec{0.0f, 0.0f, 0.0f, 1.0f} )
inlinenoexcept

Create a matrix for 4 vector-columns.

◆ mat() [3/3]

tt_force_inline tt::mat::mat ( float i00,
float i10,
float i20,
float i30,
float i01,
float i11,
float i21,
float i31,
float i02,
float i12,
float i22,
float i32,
float i03,
float i13,
float i23,
float i33 )
inline

Construct a matrix from the individual values.

The arguments are ordered so that 4 rows of 4 values will construct the matrix visually in the same way as common mathamatics papers.

Member Function Documentation

◆ align()

static mat::T tt::mat::align ( aarect haystack,
aarect needle,
Alignment alignment )
inlinestaticnoexcept

Align a rectangle within another rectangle.

Parameters
haystackThe outside rectangle
needleThe inside rectangle; to be aligned.
alignmentHow the inside rectangle should be aligned.
Returns
Translation matrix to move and align the needle in the haystack

◆ I()

static mat tt::mat::I ( )
inlinestaticnoexcept

Create an identity matrix.

◆ is_z_rot90()

bool tt::mat::is_z_rot90 ( ) const
inlinenoexcept

Rotation around z axis is a multiple of 90 degree.

◆ R()

template<int N = 2, typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
static mat tt::mat::R ( T rhs)
inlinestaticnoexcept

Create a rotation matrix.

Parameters
N0 = rotate around x-axis, 1=rotate around y-axis, 2=rotate around z-axis
rhsAngle in radials counter-clockwise.

◆ shear()

static mat tt::mat::shear ( float _00,
float _01,
float _10,
float _11 )
inlinestaticnoexcept

Create a 2D shearing matrix.

Parameters
_00row 0, col 0
_01row 0, col 1
_10row 1, col 0
_11row 1, col 1

Friends And Related Symbol Documentation

◆ operator* [1/6]

tt_force_inline friend rect operator* ( mat const & lhs,
aarect const & rhs )
friend

Matrix/aarect multiplication.

◆ operator* [2/6]

mat operator* ( mat const & lhs,
mat const & rhs )
friend

Matrix/Matrix multiplication.

◆ operator* [3/6]

tt_force_inline friend rect operator* ( mat const & lhs,
rect const & rhs )
friend

Matrix/rect multiplication.

◆ operator* [4/6]

tt_force_inline friend vec operator* ( mat const & lhs,
vec const & rhs )
friend

Matrix/Vector multiplication.

Used for transforming vectors.

◆ operator* [5/6]

mat operator* ( S const & lhs,
mat const & rhs )
friend

Scale/Matrix multiplication.

◆ operator* [6/6]

mat operator* ( T const & lhs,
mat const & rhs )
friend

Translate/Matrix multiplication.

◆ operator~

mat operator~ ( mat const & rhs)
friend

Invert matrix.

◆ transpose

mat transpose ( mat rhs)
friend

Matrix transpose.


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