33 memcpy(
A, Other.
A,
sizeof(
T) * 16);
42 T A10, T A11, T A12, T A13,
43 T A20, T A21, T A22, T A23,
44 T A30, T A31, T A32, T A33) :
45 A { {A00, A01, A02, A03},
48 {A30, A31, A32, A33} } {}
68 mutable bool IsInverseEvaluated;
76 void EvaluateInverseMatrix()
const
78 if (IsInverseEvaluated)
return;
79 IsInverseEvaluated =
true;
84 this->
A[2][1], this->
A[2][2], this->
A[2][3],
85 this->
A[3][1], this->
A[3][2], this->
A[3][3]);
88 this->
A[2][0], this->
A[2][2], this->
A[2][3],
89 this->
A[3][0], this->
A[3][2], this->
A[3][3]);
92 this->
A[2][0], this->
A[2][1], this->
A[2][3],
93 this->
A[3][0], this->
A[3][1], this->
A[3][3]);
96 this->
A[2][0], this->
A[2][1], this->
A[2][2],
97 this->
A[3][0], this->
A[3][1], this->
A[3][2]);
101 this->
A[2][1], this->
A[2][2], this->
A[2][3],
102 this->
A[3][1], this->
A[3][2], this->
A[3][3]);
105 this->
A[2][0], this->
A[2][2], this->
A[2][3],
106 this->
A[3][0], this->
A[3][2], this->
A[3][3]);
109 this->
A[2][0], this->
A[2][1], this->
A[2][3],
110 this->
A[3][0], this->
A[3][1], this->
A[3][3]);
113 this->
A[2][0], this->
A[2][1], this->
A[2][2],
114 this->
A[3][0], this->
A[3][1], this->
A[3][2]);
118 this->
A[1][1], this->
A[1][2], this->
A[1][3],
119 this->
A[3][1], this->
A[3][2], this->
A[3][3]);
122 this->
A[1][0], this->
A[1][2], this->
A[1][3],
123 this->
A[3][0], this->
A[3][2], this->
A[3][3]);
126 this->
A[1][0], this->
A[1][1], this->
A[1][3],
127 this->
A[3][0], this->
A[3][1], this->
A[3][3]);
130 this->
A[1][0], this->
A[1][1], this->
A[1][2],
131 this->
A[3][0], this->
A[3][1], this->
A[3][2]);
135 this->
A[1][1], this->
A[1][2], this->
A[1][3],
136 this->
A[2][1], this->
A[2][2], this->
A[2][3]);
139 this->
A[1][0], this->
A[1][2], this->
A[1][3],
140 this->
A[2][0], this->
A[2][2], this->
A[2][3]);
143 this->
A[1][0], this->
A[1][1], this->
A[1][3],
144 this->
A[2][0], this->
A[2][1], this->
A[2][3]);
147 this->
A[1][0], this->
A[1][1], this->
A[1][2],
148 this->
A[2][0], this->
A[2][1], this->
A[2][2]);
153 InvA[0][0] *= det; InvA[1][0] *= det; InvA[2][0] *= det; InvA[3][0] *= det;
154 InvA[0][1] *= det; InvA[1][1] *= det; InvA[2][1] *= det; InvA[3][1] *= det;
155 InvA[0][2] *= det; InvA[1][2] *= det; InvA[2][2] *= det; InvA[3][2] *= det;
156 InvA[0][3] *= det; InvA[1][3] *= det; InvA[2][3] *= det; InvA[3][3] *= det;
172 IsInverseEvaluated(
false) {}
180 T A10, T A11, T A12, T A13,
181 T A20, T A21, T A22, T A23,
182 T A30, T A31, T A32, T A33) :
191 IsInverseEvaluated(
false) {}
203 IsInverseEvaluated(
false)
205 memcpy(this->A, A, 4 * 4 *
sizeof(T));
222 IsInverseEvaluated(
false) {}
235 IsInverseEvaluated(
false) {}
245 return matr4(1, 0, 0, 0,
259 T x = Transform.
GetX(), y = Transform.
GetY(), z = Transform.
GetZ();
260 return matr4(1, 0, 0, 0,
274 T x =
S.X, y =
S.Y, z =
S.Z;
275 return matr4(x, 0, 0, 0,
294 return matr4(c + v.
X * v.
X * (1 - c), v.
X * v.
Y * (1 - c) + v.
Z * s, v.
X * v.
Z * (1 - c) - v.
Y * s, 0,
295 v.
Y * v.
X * (1 - c) - v.
Z * s, c + v.
Y * v.
Y * (1 - c), v.
Y * v.
Z * (1 - c) + v.
X * s, 0,
296 v.
Z * v.
X * (1 - c) + v.
Y * s, v.
Z * v.
Y * (1 - c) - v.
X * s, c + v.
Z * v.
Z * (1 - c), 0,
311 return matr4(1, 0, 0, 0,
328 return matr4(c, 0, -s, 0,
345 return matr4(c, -s, 0, 0,
361 return matr4(2 * Near / (Right - Left), 0, 0, 0,
362 0, 2 * Near / (Top - Bottom), 0, 0,
363 (Right + Left) / (Right - Left), (Top + Bottom) / (Top - Bottom), -(Far + Near) / (Far - Near), -1,
364 0, 0, -2 * Near * Far / (Far - Near), 0);
375 static matr4 Ortho(T Left, T Right, T Bottom, T Top, T Near, T Far)
377 return matr4(2 / (Right - Left), 0, 0, 0,
378 0, 2 / (Top - Bottom), 0, 0,
379 0, 0, -2 / (Far - Near), 0,
380 -(Right + Left) / (Right - Left), -(Top + Bottom) / (Top - Bottom), -(Near + Far) / (Far - Near), 1);
393 vec3<T> d = (At - Location).Normalized();
404 -Location.
Dot(r), -Location.
Dot(u), Location.
Dot(d), 1);
419 for (
int i = 0; i < 4; i++)
420 for (
int j = 0; j < 4; j++)
435 return matr4(this->
A[0][0], this->
A[1][0], this->
A[2][0], this->
A[3][0],
436 this->
A[0][1], this->
A[1][1], this->
A[2][1], this->
A[3][1],
437 this->
A[0][2], this->
A[1][2], this->
A[2][2], this->
A[3][2],
438 this->
A[0][3], this->
A[1][3], this->
A[2][3], this->
A[3][3]);
452 for (
int i = 0; i < 4; i++)
453 for (
int j = 0; j < 4; j++)
454 for (k = 0, r.
A[i][j] = 0; k < 4; k++)
455 r.
A[i][j] += this->
A[i][k] *
M.A[k][j];
469 this->
A[2][1], this->
A[2][2], this->
A[2][3],
470 this->
A[3][1], this->
A[3][2], this->
A[3][3]) +
472 this->
A[2][0], this->
A[2][2], this->
A[2][3],
473 this->
A[3][0], this->
A[3][2], this->
A[3][3]) +
475 this->
A[2][0], this->
A[2][1], this->
A[2][3],
476 this->
A[3][0], this->
A[3][1], this->
A[3][3]) +
478 this->
A[2][0], this->
A[2][1], this->
A[2][2],
479 this->
A[3][0], this->
A[3][1], this->
A[3][2]);
490 EvaluateInverseMatrix();
502 return vec3<T>(
V.X * this->A[0][0] +
V.Y * this->A[1][0] +
V.Z * this->A[2][0] + this->A[3][0],
503 V.X * this->A[0][1] +
V.Y * this->A[1][1] +
V.Z * this->A[2][1] + this->A[3][1],
504 V.X * this->A[0][2] +
V.Y * this->A[1][2] +
V.Z * this->A[2][2] + this->A[3][2]);
515 return vec3<T>(
V.X * this->A[0][0] +
V.Y * this->A[1][0] +
V.Z * this->A[2][0],
516 V.X * this->A[0][1] +
V.Y * this->A[1][1] +
V.Z * this->A[2][1],
517 V.X * this->A[0][2] +
V.Y * this->A[1][2] +
V.Z * this->A[2][2]);
528 float w =
V.X * this->
A[0][3] +
V.Y * this->
A[1][3] +
V.Z * this->
A[2][3] + this->
A[3][3];
530 return vec3<T>((
V.X * this->A[0][0] +
V.Y * this->A[1][0] +
V.Z * this->A[2][0] + this->A[3][0]) / w,
531 (
V.X * this->A[0][1] +
V.Y * this->A[1][1] +
V.Z * this->A[2][1] + this->A[3][1]) / w,
532 (
V.X * this->A[0][2] +
V.Y * this->A[1][2] +
V.Z * this->A[2][2] + this->A[3][2]) / w);
541 T &operator [](
int Index)
552 T operator [](
int Index)
const
matr4_data(T A00, T A01, T A02, T A03, T A10, T A11, T A12, T A13, T A20, T A21, T A22, T A23, T A30, T A31, T A32, T A33)
matr4_data(const matr4_data &Other)
vec3< T > Transform4x4(const vec3< T > &V) const
static matr4 Rotate(vec3< T > Axis, degrees< T > Angle)
static matr4 RotateY(degrees< T > Angle)
matr4 operator*(const matr4 &M) const
matr4(const matr4_data< T > &Other)
static matr4 Frustum(T Left, T Right, T Bottom, T Top, T Near, T Far)
static matr4 Lerp(const matr4 &Start, const matr4 &End, T Current)
static matr4 View(vec3< T > Location, vec3< T > At, vec3< T > Up)
matr4(T A00, T A01, T A02, T A03, T A10, T A11, T A12, T A13, T A20, T A21, T A22, T A23, T A30, T A31, T A32, T A33)
static matr4 Scale(vec3< T > S)
static matr4 Ortho(T Left, T Right, T Bottom, T Top, T Near, T Far)
static matr4 RotateZ(degrees< T > Angle)
vec3< T > TransformVector(const vec3< T > &V) const
static matr4 RotateX(degrees< T > Angle)
vec3< T > TransformPoint(const vec3< T > &V) const
static matr4 Translate(const vec3< T > &Transform)
T Dot(const vec3 &Other) const
vec3 Cross(const vec3 &Other) const
T Clamp(T Num, T Min=0, T Max=1)
T Lerp(T Start, T End, T Current)
math::matr4< float > matr4