Voltray Engine Docs
Loading...
Searching...
No Matches
Mat4.h
Go to the documentation of this file.
1#pragma once
2
3#include "Vec3.h"
4#include "Vec4.h"
5
15struct Mat4
16{
20 float data[16];
21
25 Mat4();
26
31 static Mat4 Identity();
32
38 Mat4 operator*(const Mat4 &other) const;
39
45 Vec3 MultiplyVec3(const Vec3 &v) const;
46
52 Vec4 MultiplyVec4(const Vec4 &v) const;
53
59 static Mat4 Translate(const Vec3 &translation);
60
66 static Mat4 Scale(const Vec3 &scale);
71 static Mat4 RotateX(float angleRad);
72
78 static Mat4 RotateY(float angleRad);
79
85 static Mat4 RotateZ(float angleRad);
86
94 static Mat4 LookAt(const Vec3 &eye, const Vec3 &center, const Vec3 &up);
95
104 static Mat4 Perspective(float fovRadians, float aspect, float near, float far);
105
116 static Mat4 Orthographic(float left, float right, float bottom, float top, float near, float far);
117
122 Mat4 Inverse() const;
123};
4x4 Matrix structure for 3D transformations and projections.
Definition Mat4.h:16
Mat4 operator*(const Mat4 &other) const
Multiplies this matrix by another matrix.
Definition Mat4.cpp:21
static Mat4 Identity()
Returns an identity matrix.
Definition Mat4.cpp:16
static Mat4 RotateX(float angleRad)
Creates a rotation matrix around the X axis.
Definition Mat4.cpp:75
Mat4 Inverse() const
Returns the inverse of this matrix.
Definition Mat4.cpp:177
static Mat4 Translate(const Vec3 &translation)
Creates a translation matrix.
Definition Mat4.cpp:55
Vec3 MultiplyVec3(const Vec3 &v) const
Transforms a Vec3 by this matrix (assumes w=1).
Definition Mat4.cpp:38
Vec4 MultiplyVec4(const Vec4 &v) const
Transforms a Vec4 by this matrix.
Definition Mat4.cpp:46
Mat4()
Constructs an identity matrix.
Definition Mat4.cpp:7
static Mat4 Perspective(float fovRadians, float aspect, float near, float far)
Creates a perspective projection matrix.
Definition Mat4.cpp:144
static Mat4 Orthographic(float left, float right, float bottom, float top, float near, float far)
Creates an orthographic projection matrix.
Definition Mat4.cpp:160
static Mat4 LookAt(const Vec3 &eye, const Vec3 &center, const Vec3 &up)
Creates a view matrix using the LookAt method.
Definition Mat4.cpp:118
static Mat4 Scale(const Vec3 &scale)
Creates a scaling matrix.
Definition Mat4.cpp:64
float data[16]
Matrix data in column-major order.
Definition Mat4.h:20
static Mat4 RotateY(float angleRad)
Creates a rotation matrix around the Y axis.
Definition Mat4.cpp:89
static Mat4 RotateZ(float angleRad)
Creates a rotation matrix around the Z axis.
Definition Mat4.cpp:103
Definition Vec3.h:5
Definition Vec4.h:7