Euphoria
eu::m4 Struct Reference

4x4 matrix More...

Public Member Functions

float * get_column_major_data_ptr ()
 Get a direct pointer to the data in column major format, for API integration.
const float * get_column_major_data_ptr () const
 Get a direct pointer to the const data in column major format, for API integration.
bool invert ()
 Invert the current matrix.
m4 get_inverted () const
 Return the inverted matrix.
float get (int row, int col) const
 Return a single value given a row and column.
v4 get_transformed (const v4 &p) const
 Get a transformed vec4.
v3 get_transformed_point (const v3 &p) const
 Get a transformed vec3 assuming it's a point.
v3 get_transformed_vec (const v3 &p) const
 Get a transformed vec3, assuming it's a normal vector.
n3 get_transformed_vec (const n3 &p) const
 Get a transformed unit3.
v4 get_row (int r) const
 Get a row as a vec4.
v4 get_column (int c) const
 Get a column as vec4.
m4 get_translated (const v3 &t) const
 Combine this with a translation matrix.
m4 get_rotated (const AA &aa) const
 Combine this with a rotation matrix.
v3 get_translation () const
 Get the current translation of the transformation matrix.
v4 get_major () const
 Get the major vector.
n3 get_x_axis () const
 Get the local X axis.
n3 get_y_axis () const
 Get the local Y axis.
n3 get_z_axis () const
 Get the local Z azis.
m4 get_transposed () const
 Gets the transpose of a matrix.
void operator+= (const m4 &rhs)
void operator-= (const m4 &rhs)

Static Public Member Functions

static m4 from_col_major (float t00, float t01, float t02, float t03, float t10, float t11, float t12, float t13, float t20, float t21, float t22, float t23, float t30, float t31, float t32, float t33)
 Create a new matrix from column major format.
static constexpr m4 from_row_major (float t00, float t10, float t20, float t30, float t01, float t11, float t21, float t31, float t02, float t12, float t22, float t32, float t03, float t13, float t23, float t33)
 Create a new matrix from row major format.
static m4 from_major (const v4 &major)
 Create a matrix from the major, aka the diagonal.
static constexpr m4 from_scalar (float scalar)
 Create a matrix from a single scalar.
static m4 from_basis (const n3 &a, const n3 &b, const n3 &c)
static m4 from_scale (const v3 &s)
static m4 from_translation (const v3 &v)
 Create a translation matrix.
static m4 from_rot_x (const An &a)
 Create a rotation matrix, around the X axis.
static m4 from_rot_y (const An &a)
 Create a rotation matrix, around the Y axis.
static m4 from_rot_z (const An &a)
 Create a rotation matrix, around the Z axis.
static m4 from (const AA &aa)
 Create a rotation matrix, from an axis angle.
static std::optional< m4 > from (const Q &q)
 Create a rotation matrix, from a quaternion.
static m4 create_ortho_lrud (float l, float r, float t, float b, float n, float f)
 Create an orthographic projection matrix.
static m4 create_perspective (const An &fov, float aspect_ratio, float near, float far)
 Create a perspective projection matrix.

Detailed Description

4x4 matrix

Definition at line 18 of file mat4.h.

Member Function Documentation

◆ create_ortho_lrud()

m4 eu::m4::create_ortho_lrud ( float l,
float r,
float t,
float b,
float n,
float f )
staticnodiscard

Create an orthographic projection matrix.

Also known as a clip_from_view transformation. Clip Space is in OpenGL NDC (-1 to +1) z range.

Parameters
lthe left side
rthe right side
tthe up side
bthe down side
nnear
ffar

◆ create_perspective()

m4 eu::m4::create_perspective ( const An & fov,
float aspect_ratio,
float near,
float far )
staticnodiscard

Create a perspective projection matrix.

◆ from() [1/2]

m4 eu::m4::from ( const AA & aa)
staticnodiscard

Create a rotation matrix, from an axis angle.

◆ from() [2/2]

std::optional< m4 > eu::m4::from ( const Q & q)
staticnodiscard

Create a rotation matrix, from a quaternion.

◆ from_basis()

m4 eu::m4::from_basis ( const n3 & a,
const n3 & b,
const n3 & c )
staticnodiscard

◆ from_col_major()

m4 eu::m4::from_col_major ( float t00,
float t01,
float t02,
float t03,
float t10,
float t11,
float t12,
float t13,
float t20,
float t21,
float t22,
float t23,
float t30,
float t31,
float t32,
float t33 )
staticnodiscard

Create a new matrix from column major format.

◆ from_major()

m4 eu::m4::from_major ( const v4 & major)
staticnodiscard

Create a matrix from the major, aka the diagonal.

See also
from_scalar

◆ from_rot_x()

m4 eu::m4::from_rot_x ( const An & a)
staticnodiscard

Create a rotation matrix, around the X axis.

◆ from_rot_y()

m4 eu::m4::from_rot_y ( const An & a)
staticnodiscard

Create a rotation matrix, around the Y axis.

◆ from_rot_z()

m4 eu::m4::from_rot_z ( const An & a)
staticnodiscard

Create a rotation matrix, around the Z axis.

◆ from_row_major()

constexpr m4 eu::m4::from_row_major ( float t00,
float t10,
float t20,
float t30,
float t01,
float t11,
float t21,
float t31,
float t02,
float t12,
float t22,
float t32,
float t03,
float t13,
float t23,
float t33 )
inlinestaticnodiscardconstexpr

Create a new matrix from row major format.

Definition at line 28 of file mat4.h.

◆ from_scalar()

constexpr m4 eu::m4::from_scalar ( float scalar)
inlinestaticnodiscardconstexpr

Create a matrix from a single scalar.

See also
from_major

Definition at line 47 of file mat4.h.

◆ from_scale()

m4 eu::m4::from_scale ( const v3 & s)
staticnodiscard

◆ from_translation()

m4 eu::m4::from_translation ( const v3 & v)
staticnodiscard

Create a translation matrix.

◆ get()

float eu::m4::get ( int row,
int col ) const
nodiscard

Return a single value given a row and column.

◆ get_column()

v4 eu::m4::get_column ( int c) const
nodiscard

Get a column as vec4.

◆ get_column_major_data_ptr() [1/2]

float * eu::m4::get_column_major_data_ptr ( )

Get a direct pointer to the data in column major format, for API integration.

◆ get_column_major_data_ptr() [2/2]

const float * eu::m4::get_column_major_data_ptr ( ) const
nodiscard

Get a direct pointer to the const data in column major format, for API integration.

◆ get_inverted()

m4 eu::m4::get_inverted ( ) const
nodiscard

Return the inverted matrix.

See also
invert

◆ get_major()

v4 eu::m4::get_major ( ) const
nodiscard

Get the major vector.

◆ get_rotated()

m4 eu::m4::get_rotated ( const AA & aa) const
nodiscard

Combine this with a rotation matrix.

◆ get_row()

v4 eu::m4::get_row ( int r) const
nodiscard

Get a row as a vec4.

◆ get_transformed()

v4 eu::m4::get_transformed ( const v4 & p) const
nodiscard

Get a transformed vec4.

◆ get_transformed_point()

v3 eu::m4::get_transformed_point ( const v3 & p) const
nodiscard

Get a transformed vec3 assuming it's a point.

◆ get_transformed_vec() [1/2]

n3 eu::m4::get_transformed_vec ( const n3 & p) const
nodiscard

Get a transformed unit3.

◆ get_transformed_vec() [2/2]

v3 eu::m4::get_transformed_vec ( const v3 & p) const
nodiscard

Get a transformed vec3, assuming it's a normal vector.

◆ get_translated()

m4 eu::m4::get_translated ( const v3 & t) const
nodiscard

Combine this with a translation matrix.

◆ get_translation()

v3 eu::m4::get_translation ( ) const
nodiscard

Get the current translation of the transformation matrix.

◆ get_transposed()

m4 eu::m4::get_transposed ( ) const
nodiscard

Gets the transpose of a matrix.

If the matrix is a rotation matrix, then the transpose is guaranteed to be the inverse of the matrix.

◆ get_x_axis()

n3 eu::m4::get_x_axis ( ) const
nodiscard

Get the local X axis.

◆ get_y_axis()

n3 eu::m4::get_y_axis ( ) const
nodiscard

Get the local Y axis.

◆ get_z_axis()

n3 eu::m4::get_z_axis ( ) const
nodiscard

Get the local Z azis.

◆ invert()

bool eu::m4::invert ( )

Invert the current matrix.

See also
get_inverted

◆ operator+=()

void eu::m4::operator+= ( const m4 & rhs)

◆ operator-=()

void eu::m4::operator-= ( const m4 & rhs)

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