JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Mat3 Class Reference

3x3 matrix More...

#include <jngl/Mat3.hpp>

Public Member Functions

 Mat3 ()=default
 creates identity matrix
 
 Mat3 (std::initializer_list< float >)
 construct matrix from row-major array with 9 elements
 
Mat3translate (const Vec2 &v)
 Multiplies the matrix with a translation matrix generated from v.
 
Mat3translate (Pixels x, Pixels y)
 Multiplies the matrix with a translation matrix generated from (x,y)
 
Mat3scale (float factor)
 Multiplies the matrix by a scaling matrix.
 
Mat3scale (float xfactor, float yfactor)
 Multiplies the matrix by a scaling matrix.
 
Mat3rotate (float radian)
 Multiplies the matrix with a rotation matrix.
 

Public Attributes

float data [9] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 }
 column-major
 

Detailed Description

3x3 matrix

identical to boost::qvm::mat<float, 3, 3>, but stores the elements column-major in memory

Definition at line 18 of file Mat3.hpp.

Constructor & Destructor Documentation

◆ Mat3() [1/2]

Mat3 ( )
default

creates identity matrix

\[
\left( \begin{array}{rrr}
1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
\end{array}\right)
\]

◆ Mat3() [2/2]

construct matrix from row-major array with 9 elements

jngl::Mat3({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }) is equivalent to:

\[
\left( \begin{array}{rrr}
1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9
\end{array}\right)
\]

Member Function Documentation

◆ translate() [1/2]

Mat3 & translate ( const Vec2 & v)

Multiplies the matrix with a translation matrix generated from v.

Returns
*this

◆ translate() [2/2]

Mat3 & translate ( Pixels x,
Pixels y )

Multiplies the matrix with a translation matrix generated from (x,y)

Returns
*this

◆ scale() [1/2]

Mat3 & scale ( float factor)

Multiplies the matrix by a scaling matrix.

Equivalent to calling Mat3::scale(factor, factor).

Returns
*this

◆ scale() [2/2]

Mat3 & scale ( float xfactor,
float yfactor )

Multiplies the matrix by a scaling matrix.

Returns
*this

If you want to draw a sprite with double the width, but the correct height:

yourSprite.draw(jngl::modelview().scale(2, 1));
Mat3 & scale(float factor)
Multiplies the matrix by a scaling matrix.
jngl::Mat3 modelview()
Returns a copy of the global ModelView matrix.

◆ rotate()

Mat3 & rotate ( float radian)

Multiplies the matrix with a rotation matrix.

Returns
*this

Member Data Documentation

◆ data

float data[9] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 }

column-major

Definition at line 71 of file Mat3.hpp.


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