Gin
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
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 ( )

References Mat4< T >::m.

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

Member Function Documentation

◆ identity()

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

Creates an identity matrix.

References Mat4< T >::Mat4().

◆ translation() [1/2]

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

Creates a translation matrix.

References Mat4< T >::m.

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

◆ translation() [2/2]

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

◆ scale() [1/2]

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

Creates a scaling matrix.

References Mat4< T >::m.

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

◆ scale() [2/2]

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

References Mat4< T >::scale().

◆ rotationX()

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

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

References Mat4< T >::m.

◆ rotationY()

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

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

References Mat4< T >::m.

◆ rotationZ()

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

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

References Mat4< T >::m.

◆ perspective()

template<typename T >
static Mat4 Mat4< T >::perspective ( fovY,
aspect,
nearZ,
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

References Mat4< T >::m.

◆ orthographic()

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

Creates an orthographic projection matrix.

References Mat4< T >::m.

◆ lookAt()

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

Creates a look-at view matrix.

References Mat4< T >::m, Point< T >::x, and Point< T >::y.

◆ operator*()

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

Matrix multiplication.

References Mat4< T >::m.

◆ transformPoint()

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

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

References Mat4< T >::m, Point< T >::x, and Point< T >::y.

◆ transformVector()

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

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

References Mat4< T >::m, Point< T >::x, and Point< T >::y.

◆ 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).

References Mat4< T >::m, Point< T >::x, and Point< T >::y.

Member Data Documentation

◆ m

template<typename T >
std::array<std::array<T, 4>, 4> Mat4< T >::m

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