Gin
Loading...
Searching...
No Matches
Mat4< T > Struct Template Reference

A 4x4 matrix class for 3D transformations. More...

#include <gin_mat4.h>

Public Member Functions

 Mat4 ()
Mat4 operator* (const Mat4 &other) const
 Matrix multiplication.
Vec3< T > transformPoint (const Vec3< T > &v) const
 Transform a 3D point (applies full transformation including translation).
Vec3< T > transformVector (const Vec3< T > &v) const
 Transform a 3D vector (applies rotation/scale only, no translation).
std::array< T, 4 > project (const Vec3< T > &v) const
 Project a point and return clip-space coordinates (x, y, z, w).

Static Public Member Functions

static Mat4 identity ()
 Creates an identity matrix.
static Mat4 translation (T x, T y, T z)
 Creates a translation matrix.
static Mat4 translation (const Vec3< T > &v)
static Mat4 scale (T x, T y, T z)
 Creates a scaling matrix.
static Mat4 scale (T s)
static Mat4 rotationX (T angle)
 Creates a rotation matrix around the X axis (angle in radians).
static Mat4 rotationY (T angle)
 Creates a rotation matrix around the Y axis (angle in radians).
static Mat4 rotationZ (T angle)
 Creates a rotation matrix around the Z axis (angle in radians).
static Mat4 perspective (T fovY, T aspect, T nearZ, T farZ)
 Creates a perspective projection matrix.
static Mat4 orthographic (T left, T right, T bottom, T top, T nearZ, T farZ)
 Creates an orthographic projection matrix.
static Mat4 lookAt (const Vec3< T > &eye, const Vec3< T > &target, const Vec3< T > &up)
 Creates a look-at view matrix.

Public Attributes

std::array< std::array< T, 4 >, 4 > m

Detailed Description

template<typename T>
struct Mat4< T >

A 4x4 matrix class for 3D transformations.

Stored in column-major order for OpenGL compatibility.

Constructor & Destructor Documentation

◆ Mat4()

template<typename T>
Mat4< T >::Mat4 ( )

Referenced by Mat4< float >::identity().

Member Function Documentation

◆ identity()

template<typename T>
Mat4 Mat4< T >::identity ( )
static

Creates an identity matrix.

◆ translation() [1/2]

template<typename T>
Mat4 Mat4< T >::translation ( T x,
T y,
T z )
static

Creates a translation matrix.

Referenced by Mat4< float >::translation().

◆ translation() [2/2]

template<typename T>
Mat4 Mat4< T >::translation ( const Vec3< T > & v)
static

◆ scale() [1/2]

template<typename T>
Mat4 Mat4< T >::scale ( T x,
T y,
T z )
static

Creates a scaling matrix.

Referenced by Mat4< float >::scale().

◆ scale() [2/2]

template<typename T>
Mat4 Mat4< T >::scale ( T s)
static

◆ rotationX()

template<typename T>
Mat4 Mat4< T >::rotationX ( T angle)
static

Creates a rotation matrix around the X axis (angle in radians).

◆ rotationY()

template<typename T>
Mat4 Mat4< T >::rotationY ( T angle)
static

Creates a rotation matrix around the Y axis (angle in radians).

◆ rotationZ()

template<typename T>
Mat4 Mat4< T >::rotationZ ( T angle)
static

Creates a rotation matrix around the Z axis (angle in radians).

◆ perspective()

template<typename T>
Mat4 Mat4< T >::perspective ( T fovY,
T aspect,
T nearZ,
T farZ )
static

Creates a perspective projection matrix.

Parameters
fovYField of view in the Y direction (radians)
aspectAspect ratio (width / height)
nearZNear clipping plane
farZFar clipping plane

◆ orthographic()

template<typename T>
Mat4 Mat4< T >::orthographic ( T left,
T right,
T bottom,
T top,
T nearZ,
T farZ )
static

Creates an orthographic projection matrix.

◆ lookAt()

template<typename T>
Mat4 Mat4< T >::lookAt ( const Vec3< T > & eye,
const Vec3< T > & target,
const Vec3< T > & up )
static

Creates a look-at view matrix.

◆ operator*()

template<typename T>
Mat4 Mat4< T >::operator* ( const Mat4< T > & other) const

Matrix multiplication.

◆ transformPoint()

template<typename T>
Vec3< T > Mat4< T >::transformPoint ( const Vec3< T > & v) const

Transform a 3D point (applies full transformation including translation).

◆ transformVector()

template<typename T>
Vec3< T > Mat4< T >::transformVector ( const Vec3< T > & v) const

Transform a 3D vector (applies rotation/scale only, no translation).

◆ project()

template<typename T>
std::array< T, 4 > Mat4< T >::project ( const Vec3< T > & v) const

Project a point and return clip-space coordinates (x, y, z, w).

Referenced by Renderer3D::render().

Member Data Documentation

◆ m


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