39 result[3] =
vec4(xyz, 1.0f);
50 A[0] * xyz.x + A[1] * xyz.y + A[2] * xyz.z + A[3]};
60 float s = sinf(angle);
61 float c = cosf(angle);
62 vec3 temp = (1.0f - c) * axis;
64 return {
vec4(axis.x * temp.x + c,
65 axis.y * temp.x + s * axis.z,
66 axis.z * temp.x - s * axis.y,
68 vec4(axis.x * temp.y - s * axis.z,
70 axis.z * temp.y + s * axis.x,
72 vec4(axis.x * temp.z + s * axis.y,
73 axis.y * temp.z - s * axis.x,
87 return A *
rotate(angle, axis);
95 float s = sinf(angle);
96 float c = cosf(angle);
97 return {
vec4(1.0f, 0.0f, 0.0f, 0.0f),
98 vec4(0.0f, c , s , 0.0f),
99 vec4(0.0f, -s , c , 0.0f),
100 vec4(0.0f, 0.0f, 0.0f, 1.0f)};
107 float s = sinf(angle);
108 float c = cosf(angle);
120 float s = sinf(angle);
121 float c = cosf(angle);
122 return {
vec4( c , 0.0f, -s , 0.0f),
123 vec4(0.0f, 1.0f, 0.0f, 0.0f),
124 vec4( s , 0.0f, c , 0.0f),
125 vec4(0.0f, 0.0f, 0.0f, 1.0f)};
132 float s = sinf(angle);
133 float c = cosf(angle);
134 return {A[0] * c - A[2] * s,
145 float s = sinf(angle);
146 float c = cosf(angle);
147 return {
vec4( c , s , 0.0f, 0.0f),
148 vec4(-s , c , 0.0f, 0.0f),
149 vec4(0.0f, 0.0f, 1.0f, 0.0f),
150 vec4(0.0f, 0.0f, 0.0f, 1.0f)};
157 float s = sinf(angle);
158 float c = cosf(angle);
159 return {A[0] * c + A[1] * s,
170 float left,
float right,
171 float bottom,
float top,
172 float nearVal,
float farVal)
174 return {
vec4(-2.0f / (left - right), 0.0f, 0.0f, 0.0f),
175 vec4( 0.0f, -2.0f / (bottom - top), 0.0f, 0.0f),
176 vec4( 0.0f, 0.0f, 2.0f / (nearVal - farVal), 0.0f),
177 vec4((left + right ) / (left - right ),
178 (bottom + top ) / (bottom - top ),
179 (nearVal + farVal) / (nearVal - farVal),
187[[nodiscard]]
constexpr mat4 ortho(
float width,
float height)
189 return {
vec4(2.0f / width, 0.0f, 0.0f, 0.0f),
190 vec4(0.0f, -2.0f / height, 0.0f, 0.0f),
191 vec4(0.0f, 0.0f, -1.0f, 0.0f),
192 vec4(-1.0f, 1.0f, 0.0f, 1.0f)};
198 float left,
float right,
199 float bottom,
float top,
200 float nearVal,
float farVal)
202 return {
vec4((2.0f * nearVal) / (right - left), 0.0f, 0.0f, 0.0f),
203 vec4(0.0f, (2.0f * nearVal) / (top - bottom), 0.0f, 0.0f),
204 vec4((right + left ) / (right - left ),
205 (top + bottom) / (top - bottom),
206 (nearVal + farVal) / (nearVal - farVal),
210 (2.0f * farVal * nearVal) / (nearVal - farVal),
mat4 rotateZ(float angle)
mat4 rotate(float angle, const vec3 &axis)
mat4 rotateY(float angle)
mat4 rotateX(float angle)
constexpr mat4 ortho(float left, float right, float bottom, float top, float nearVal, float farVal)
matMxN< 4, 4, float > mat4
constexpr mat4 frustum(float left, float right, float bottom, float top, float nearVal, float farVal)
constexpr mat4 translate(const vec3 &xyz)
constexpr mat4 scale(const vec3 &xyz)