HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends
hi::v1::matrix3 Class Reference

#include <hikogui/geometry/matrix3.hpp>

Public Member Functions

constexpr matrix3 (matrix3 const &) noexcept=default
 
constexpr matrix3 (matrix3 &&) noexcept=default
 
constexpr matrix3operator= (matrix3 const &) noexcept=default
 
constexpr matrix3operator= (matrix3 &&) noexcept=default
 
constexpr matrix3 () noexcept
 Constructs an identity matrix.
 
constexpr matrix3 (f32x4 col0, f32x4 col1, f32x4 col2, f32x4 col3=f32x4{0.0f, 0.0f, 0.0f, 1.0f}) noexcept
 Construct a matrix from four columns.
 
constexpr matrix3 (vector3 col0, vector3 col1, vector3 col2, vector3 col3=vector3{}) noexcept
 Construct a matrix from four vectors.
 
constexpr matrix3 (float c0r0, float c1r0, float c2r0, float c0r1, float c1r1, float c2r1, float c0r2, float c1r2, float c2r2) noexcept
 Construct a matrix from two vectors.
 
constexpr matrix3 (float c0r0, float c1r0, float c2r0, float c3r0, float c0r1, float c1r1, float c2r1, float c3r1, float c0r2, float c1r2, float c2r2, float c3r2, float c0r3, float c1r3, float c2r3, float c3r3) noexcept
 Construct a 4x4 matrix from scalar values.
 
constexpr matrix3 (matrix2 const &other) noexcept
 Copy-construct a matrix from a smaller matrix.
 
constexpr operator matrix2 () const noexcept
 
constexpr matrix3 (scale3 const &rhs) noexcept
 
constexpr matrix3 (translate3 const &rhs) noexcept
 
constexpr matrix3 (rotate3 const &rhs) noexcept
 Convert quaternion to matrix.
 
constexpr operator std::array< f32x4, 4 > () const noexcept
 Convert a point to its f32x4-nummeric_array.
 
constexpr bool holds_invariant () const noexcept
 
constexpr f32x4 operator* (f32x4 const &rhs) const noexcept
 Transform a f32x4 numeric array by the matrix.
 
constexpr matrix3 operator~ () const
 Invert matrix.
 

Static Public Member Functions

static constexpr matrix3 uniform (aarectangle src_rectangle, aarectangle dst_rectangle, alignment alignment) noexcept
 Create a transformation matrix to translate and uniformly-scale a src_rectangle to a dst_rectangle.
 

Friends

template<int I>
constexpr f32x4 const & get (matrix3 const &rhs) noexcept
 Get a column.
 
template<int I>
constexpr f32x4get (matrix3 &rhs) noexcept
 Get a column.
 
constexpr matrix3 transpose (matrix3 const &rhs) noexcept
 Matrix transpose.
 
template<char DstX, char DstY, char DstZ, char DstW = 'w'>
constexpr matrix3 reflect (matrix3 const &rhs) noexcept
 Reflect axis of a matrix.
 
constexpr friend bool operator== (matrix3 const &lhs, matrix3 const &rhs) noexcept
 Compare two matrices potentially of different dimensions.
 

Detailed Description

A 2D or 3D homogenius matrix for transforming homogenious vectors and points.

This matrix is in column major order. It is implemented as 4 columns made from a f32x4 numeric-array.

Constructor & Destructor Documentation

◆ matrix3() [1/7]

constexpr hi::v1::matrix3::matrix3 ( )
inlineconstexprnoexcept

Constructs an identity matrix.

◆ matrix3() [2/7]

constexpr hi::v1::matrix3::matrix3 ( f32x4 col0,
f32x4 col1,
f32x4 col2,
f32x4 col3 = f32x4{0.0f, 0.0f, 0.0f, 1.0f} )
inlineconstexprnoexcept

Construct a matrix from four columns.

Parameters
col0The 1st f32x4 column.
col1The 2nd f32x4 column.
col2The 3rd f32x4 column.
col3The 4th f32x4 column.

◆ matrix3() [3/7]

constexpr hi::v1::matrix3::matrix3 ( vector3 col0,
vector3 col1,
vector3 col2,
vector3 col3 = vector3{} )
inlineconstexprnoexcept

Construct a matrix from four vectors.

Parameters
col0The 1st vector3 column.
col1The 2nd vector3 column.
col2The 3rd vector3 column.
col3The 4th vector3 column.

◆ matrix3() [4/7]

constexpr hi::v1::matrix3::matrix3 ( float c0r0,
float c1r0,
float c2r0,
float c0r1,
float c1r1,
float c2r1,
float c0r2,
float c1r2,
float c2r2 )
inlineconstexprnoexcept

Construct a matrix from two vectors.

Parameters
col0The 1st vector2 column.
col1The 2nd vector2 column. Construct a 3x3 matrix from scalar values.

The function parameters are in row-major order for pretty formatting in source code. The matrix itself remains in column-major order.

Parameters
c0r0Value for column 0, row 0
c1r0Value for column 1, row 0
c2r0Value for column 2, row 0
c0r1Value for column 0, row 1
c1r1Value for column 1, row 1
c2r1Value for column 2, row 1
c0r2Value for column 0, row 2
c1r2Value for column 1, row 2
c2r2Value for column 2, row 2

◆ matrix3() [5/7]

constexpr hi::v1::matrix3::matrix3 ( float c0r0,
float c1r0,
float c2r0,
float c3r0,
float c0r1,
float c1r1,
float c2r1,
float c3r1,
float c0r2,
float c1r2,
float c2r2,
float c3r2,
float c0r3,
float c1r3,
float c2r3,
float c3r3 )
inlineconstexprnoexcept

Construct a 4x4 matrix from scalar values.

The function parameters are in row-major order for pretty formatting in source code. The matrix itself remains in column-major order.

Parameters
c0r0Value for column 0, row 0
c1r0Value for column 1, row 0
c2r0Value for column 2, row 0
c3r0Value for column 3, row 0
c0r1Value for column 0, row 1
c1r1Value for column 1, row 1
c2r1Value for column 2, row 1
c3r1Value for column 3, row 1
c0r2Value for column 0, row 2
c1r2Value for column 1, row 2
c2r2Value for column 2, row 2
c3r2Value for column 3, row 2
c0r3Value for column 0, row 3
c1r3Value for column 1, row 3
c2r3Value for column 2, row 3
c3r3Value for column 3, row 3

◆ matrix3() [6/7]

constexpr hi::v1::matrix3::matrix3 ( matrix2 const & other)
inlineconstexprnoexcept

Copy-construct a matrix from a smaller matrix.

◆ matrix3() [7/7]

constexpr hi::v1::matrix3::matrix3 ( rotate3 const & rhs)
inlineconstexprnoexcept

Convert quaternion to matrix.

Member Function Documentation

◆ operator std::array< f32x4, 4 >()

constexpr hi::v1::matrix3::operator std::array< f32x4, 4 > ( ) const
inlineexplicitconstexprnoexcept

Convert a point to its f32x4-nummeric_array.

◆ operator*()

constexpr f32x4 hi::v1::matrix3::operator* ( f32x4 const & rhs) const
inlineconstexprnoexcept

Transform a f32x4 numeric array by the matrix.

Parameters
rhsThe f32x4 numeric array to transform.
Returns
The transformed numeric array.

◆ operator~()

constexpr matrix3 hi::v1::matrix3::operator~ ( ) const
inlineconstexpr

Invert matrix.

◆ uniform()

static constexpr matrix3 hi::v1::matrix3::uniform ( aarectangle src_rectangle,
aarectangle dst_rectangle,
alignment alignment )
inlinestaticconstexprnoexcept

Create a transformation matrix to translate and uniformly-scale a src_rectangle to a dst_rectangle.

The implementation is located in scale.hpp since the definition requires both scale and translate.

Parameters
src_rectangleThe rectangle to be transformed.
dst_rectangleThe rectangle after transformation.
alignmentHow the src_rectangle should be aligned inside the dst_rectangle after scaling and moving.
Returns
A transformation matrix to move and scale the src_rectangle to the dst_rectangle.

Friends And Related Symbol Documentation

◆ get [1/2]

template<int I>
constexpr f32x4 & get ( matrix3 & rhs)
friend

Get a column.

Template Parameters
IThe index of the column.
Returns
A reference to the selected column as a f32x4.

◆ get [2/2]

template<int I>
constexpr f32x4 const & get ( matrix3 const & rhs)
friend

Get a column.

Template Parameters
IThe index of the column.
Returns
A const reference to the selected column as a f32x4.

◆ operator==

constexpr friend bool operator== ( matrix3 const & lhs,
matrix3 const & rhs )
friend

Compare two matrices potentially of different dimensions.

Parameters
rhsThe right-hand-side matrix.
Return values
trueWhen the two matrices compare equal.

◆ reflect

template<char DstX, char DstY, char DstZ, char DstW = 'w'>
constexpr matrix3 reflect ( matrix3 const & rhs)
friend

Reflect axis of a matrix.

The default axis of HikoGUI's geometry system are:

+y
| -z (away from camera)
| /
| /
|/
-x ----+---- +x
/|
/ |
/ |
+z |
-y
friend constexpr f32x4 const & get(matrix3 const &rhs) noexcept
Get a column.
Definition matrix3.hpp:271

In Vulkan the Y axis is downward; so to translate a matrix from HikoGUI to Vulkan you can use:

The original axis are defined as the lower-case characters 'x', 'y', 'z' and 'w'; or for the negated axis as the upper-case characters 'X', 'Y', 'Z' and 'W'.

Template Parameters
DstXWhich of the original axis to use for the new matrix's x-axis.
DstYWhich of the original axis to use for the new matrix's y-axis.
DstZWhich of the original axis to use for the new matrix's z-axis.
DstWWhich of the original axis to use for the new matrix's w-axis.
Parameters
rhsThe matrix to reflect
Returns
The reflected matrix.

◆ transpose

constexpr matrix3 transpose ( matrix3 const & rhs)
friend

Matrix transpose.


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