Voltray Engine Docs
Loading...
Searching...
No Matches
Mat4 Struct Reference

4x4 Matrix structure for 3D transformations and projections. More...

#include <Mat4.h>

Public Member Functions

 Mat4 ()
 Constructs an identity matrix.
 
Mat4 operator* (const Mat4 &other) const
 Multiplies this matrix by another matrix.
 
Vec3 MultiplyVec3 (const Vec3 &v) const
 Transforms a Vec3 by this matrix (assumes w=1).
 
Vec4 MultiplyVec4 (const Vec4 &v) const
 Transforms a Vec4 by this matrix.
 
Mat4 Inverse () const
 Returns the inverse of this matrix.
 

Static Public Member Functions

static Mat4 Identity ()
 Returns an identity matrix.
 
static Mat4 Translate (const Vec3 &translation)
 Creates a translation matrix.
 
static Mat4 Scale (const Vec3 &scale)
 Creates a scaling matrix.
 
static Mat4 RotateX (float angleRad)
 Creates a rotation matrix around the X axis.
 
static Mat4 RotateY (float angleRad)
 Creates a rotation matrix around the Y axis.
 
static Mat4 RotateZ (float angleRad)
 Creates a rotation matrix around the Z axis.
 
static Mat4 LookAt (const Vec3 &eye, const Vec3 &center, const Vec3 &up)
 Creates a view matrix using the LookAt method.
 
static Mat4 Perspective (float fovRadians, float aspect, float near, float far)
 Creates a perspective projection matrix.
 
static Mat4 Orthographic (float left, float right, float bottom, float top, float near, float far)
 Creates an orthographic projection matrix.
 

Public Attributes

float data [16]
 Matrix data in column-major order.
 

Detailed Description

4x4 Matrix structure for 3D transformations and projections.

Provides basic matrix operations and utilities for 3D graphics, including identity, multiplication, translation, scaling, rotation (Z axis), view (LookAt), and perspective projection matrices.

Data is stored in a 16-element float array in column-major order.

Constructor & Destructor Documentation

◆ Mat4()

Mat4::Mat4 ( )

Constructs an identity matrix.

Member Function Documentation

◆ Identity()

Mat4 Mat4::Identity ( )
static

Returns an identity matrix.

Returns
Mat4 Identity matrix.

◆ Inverse()

Mat4 Mat4::Inverse ( ) const

Returns the inverse of this matrix.

Returns
Inverse matrix.

◆ LookAt()

Mat4 Mat4::LookAt ( const Vec3 eye,
const Vec3 center,
const Vec3 up 
)
static

Creates a view matrix using the LookAt method.

Parameters
eyeCamera position.
centerTarget position.
upUp direction vector.
Returns
View matrix.

◆ MultiplyVec3()

Vec3 Mat4::MultiplyVec3 ( const Vec3 v) const

Transforms a Vec3 by this matrix (assumes w=1).

Parameters
vThe vector to transform.
Returns
Transformed Vec3.

◆ MultiplyVec4()

Vec4 Mat4::MultiplyVec4 ( const Vec4 v) const

Transforms a Vec4 by this matrix.

Parameters
vThe vector to transform.
Returns
Transformed Vec4.

◆ operator*()

Mat4 Mat4::operator* ( const Mat4 other) const

Multiplies this matrix by another matrix.

Parameters
otherThe matrix to multiply with.
Returns
Resulting matrix after multiplication.

◆ Orthographic()

Mat4 Mat4::Orthographic ( float  left,
float  right,
float  bottom,
float  top,
float  near,
float  far 
)
static

Creates an orthographic projection matrix.

Parameters
leftLeft clipping plane.
rightRight clipping plane.
bottomBottom clipping plane.
topTop clipping plane.
nearNear clipping plane.
farFar clipping plane.
Returns
Orthographic projection matrix.

◆ Perspective()

Mat4 Mat4::Perspective ( float  fovRadians,
float  aspect,
float  near,
float  far 
)
static

Creates a perspective projection matrix.

Parameters
fovRadiansField of view in radians.
aspectAspect ratio (width/height).
nearNear clipping plane.
farFar clipping plane.
Returns
Perspective projection matrix.

◆ RotateX()

Mat4 Mat4::RotateX ( float  angleRad)
static

Creates a rotation matrix around the X axis.

Parameters
angleRadRotation angle in radians.
Returns
Rotation matrix.

◆ RotateY()

Mat4 Mat4::RotateY ( float  angleRad)
static

Creates a rotation matrix around the Y axis.

Parameters
angleRadRotation angle in radians.
Returns
Rotation matrix.

◆ RotateZ()

Mat4 Mat4::RotateZ ( float  angleRad)
static

Creates a rotation matrix around the Z axis.

Parameters
angleRadRotation angle in radians.
Returns
Rotation matrix.

◆ Scale()

Mat4 Mat4::Scale ( const Vec3 scale)
static

Creates a scaling matrix.

Parameters
scaleThe scaling vector.
Returns
Scaling matrix.

◆ Translate()

Mat4 Mat4::Translate ( const Vec3 translation)
static

Creates a translation matrix.

Parameters
translationThe translation vector.
Returns
Translation matrix.

Member Data Documentation

◆ data

float Mat4::data[16]

Matrix data in column-major order.


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