Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
matrix4 Struct Reference

floating point 4x4 array object More...

#include <geom.h>

Public Member Functions

template<class T , class U >
transformnormal (const U &in) const
 
template<class T , class U >
transform (const U &in) const
 
template<class T >
vec perspectivetransform (const T &in) const
 
template<class T >
void mult (const matrix4 &x, const matrix4 &y)
 
 matrix4 (const float *m)
 
 matrix4 (const vec &a, const vec &b, const vec &c=vec(0, 0, 1))
 
 matrix4 (const vec4< float > &a, const vec4< float > &b, const vec4< float > &c, const vec4< float > &d=vec4< float >(0, 0, 0, 1))
 
 matrix4 (const matrix4x3 &m)
 
 matrix4 (const matrix3 &rot, const vec &trans)
 
void mul (const matrix4 &x, const matrix3 &y)
 
void mul (const matrix3 &y)
 
void mul (const matrix4 &x, const matrix4 &y)
 Sets this matrix to the product of the two matrices provided.
 
void mul (const matrix4 &y)
 Sets this matrix to the product of this and another matrix.
 
void muld (const matrix4 &x, const matrix4 &y)
 Sets this matrix to the product of the two matrices provided.
 
void muld (const matrix4 &y)
 Sets this matrix to the product of this and another matrix.
 
void rotate_around_x (float ck, float sk)
 
void rotate_around_x (float angle)
 
void rotate_around_x (const vec2 &sc)
 
void rotate_around_y (float ck, float sk)
 
void rotate_around_y (float angle)
 
void rotate_around_y (const vec2 &sc)
 
void rotate_around_z (float ck, float sk)
 
void rotate_around_z (float angle)
 
void rotate_around_z (const vec2 &sc)
 
void rotate (float ck, float sk, const vec &axis)
 
void rotate (float angle, const vec &dir)
 
void rotate (const vec2 &sc, const vec &dir)
 
void identity ()
 Sets the matrix to I, the identity matrix.
 
void settranslation (const vec &v)
 
void settranslation (float x, float y, float z)
 
void translate (const vec &p)
 
void translate (float x, float y, float z)
 
void translate (const vec &p, float scale)
 
void setscale (float x, float y, float z)
 
void setscale (const vec &v)
 
void setscale (float n)
 
void scale (float x, float y, float z)
 
void scale (const vec &v)
 
void scale (float n)
 
void scalez (float k)
 
void jitter (float x, float y)
 
void transpose ()
 Transposes the matrix along the diagonal.
 
void transpose (const matrix4 &m)
 Copies the transpose of the given matrix4 to this
 
void frustum (float left, float right, float bottom, float top, float znear, float zfar)
 
void perspective (float fovy, float aspect, float znear, float zfar)
 
void ortho (float left, float right, float bottom, float top, float znear, float zfar)
 
void transform (const vec &in, vec &out) const
 
void transform (const vec4< float > &in, vec &out) const
 
void transform (const vec &in, vec4< float > &out) const
 
void transform (const vec4< float > &in, vec4< float > &out) const
 
void transformnormal (const vec &in, vec &out) const
 
void transformnormal (const vec &in, vec4< float > &out) const
 
void transposedtransform (const vec &in, vec &out) const
 
void transposedtransformnormal (const vec &in, vec &out) const
 
void transposedtransform (const plane &in, plane &out) const
 
vec gettranslation () const
 
vec4< float > rowx () const
 Returns the first row of the matrix.
 
vec4< float > rowy () const
 Returns the second row of the matrix.
 
vec4< float > rowz () const
 Returns the third row of the matrix.
 
vec4< float > roww () const
 Returns the fourth row of the matrix.
 
bool invert (const matrix4 &m, double mindet=1.0e-12)
 Sets this matrix to the inverse of the provided matrix.
 
matrix4 inverse (double mindet=1.0e-12) const
 Returns the inverse of the matrix.
 
vec2 lineardepthscale () const
 

Public Attributes

vec4< float > a
 
vec4< float > b
 
vec4< float > c
 
vec4< float > d
 

Detailed Description

floating point 4x4 array object

Member Function Documentation

◆ identity()

void matrix4::identity ( )

Sets the matrix to I, the identity matrix.

Sets the matrix to I, with the form as follows:

a b c d
x 1 0 0 0
y 0 1 0 0
z 0 0 1 0
w 0 0 0 1

◆ inverse()

matrix4 matrix4::inverse ( double mindet = 1.0e-12) const

Returns the inverse of the matrix.

Returns a zero matrix if the matrix is singular.

Parameters
mindetthe determinant value at which matrices are considered singular
Returns
a matrix4 containing the matrix inverse

◆ invert()

bool matrix4::invert ( const matrix4 & m,
double mindet = 1.0e-12 )

Sets this matrix to the inverse of the provided matrix.

Sets the matrix values to the inverse of the provided matrix A*A^-1 = I returns false if singular (or nearly singular to within tolerance of mindet) or true if matrix was inverted successfully

Parameters
ma matrix4 object to be inverted and assigned to the object
mindetthe determinant value at which matrices are considered singular
Returns
false if the matrix is singular, true otherwise

◆ mul() [1/2]

void matrix4::mul ( const matrix4 & x,
const matrix4 & y )

Sets this matrix to the product of the two matrices provided.

The original contents of the matrix are disregarded. All calculations at single precision (float).

Parameters
xthe first matrix to multiply
ythe second matrix to multiply

◆ mul() [2/2]

void matrix4::mul ( const matrix4 & y)

Sets this matrix to the product of this and another matrix.

The original contents of the matrix are the left element in the product. All calculations at single precision (float).

Parameters
ythe second matrix to multiply

◆ muld() [1/2]

void matrix4::muld ( const matrix4 & x,
const matrix4 & y )

Sets this matrix to the product of the two matrices provided.

The original contents of the matrix are disregarded. Uses double precision to perform calculations, and is narrowed at the end to float.

Parameters
xthe first matrix to multiply
ythe second matrix to multiply

◆ muld() [2/2]

void matrix4::muld ( const matrix4 & y)

Sets this matrix to the product of this and another matrix.

The original contents of the matrix are the left element in the product. Uses double precision to perform calculations, and is narrowed at the end to float.

Parameters
ythe second matrix to multiply

◆ roww()

vec4< float > matrix4::roww ( ) const

Returns the fourth row of the matrix.

Returns the fourth value of each column vector that makes up the matrix.

Returns
a vec4 of the last row of the vector

◆ rowx()

vec4< float > matrix4::rowx ( ) const

Returns the first row of the matrix.

Returns the first value of each column vector that makes up the matrix.

Returns
a vec4 of the first row of the vector

◆ rowy()

vec4< float > matrix4::rowy ( ) const

Returns the second row of the matrix.

Returns the second value of each column vector that makes up the matrix.

Returns
a vec4 of the second row of the vector

◆ rowz()

vec4< float > matrix4::rowz ( ) const

Returns the third row of the matrix.

Returns the third value of each column vector that makes up the matrix.

Returns
a vec4 of the third row of the vector

◆ transpose() [1/2]

void matrix4::transpose ( )

Transposes the matrix along the diagonal.

Transforms the matrix like so (letters are just arbitrary value placeholders)

a b c d a e i m
e f g h -> b f j n
i j k l c g k o
m n o p d h l p

◆ transpose() [2/2]

void matrix4::transpose ( const matrix4 & m)

Copies the transpose of the given matrix4 to this

Copies the transform of the matrix passed like so (letters are just arbitrary value placeholders) to this object.

a b c d a e i m
e f g h -> b f j n
i j k l c g k o
m n o p d h l p

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