17 template <
typename Real>
21 template <
typename Real>
23 bool* reportInvertibility =
nullptr);
25 template <
typename Real>
28 template <
typename Real>
31 template <
typename Real>
56 template <
typename Real>
69 template <
typename Real>
81 template <
typename Real>
86 template <
typename Real>
91 Real a0 = M(0, 0) * M(1, 1) - M(0, 1) * M(1, 0);
92 Real a1 = M(0, 0) * M(1, 2) - M(0, 2) * M(1, 0);
93 Real a2 = M(0, 0) * M(1, 3) - M(0, 3) * M(1, 0);
94 Real a3 = M(0, 1) * M(1, 2) - M(0, 2) * M(1, 1);
95 Real a4 = M(0, 1) * M(1, 3) - M(0, 3) * M(1, 1);
96 Real a5 = M(0, 2) * M(1, 3) - M(0, 3) * M(1, 2);
97 Real b0 = M(2, 0) * M(3, 1) - M(2, 1) * M(3, 0);
98 Real b1 = M(2, 0) * M(3, 2) - M(2, 2) * M(3, 0);
99 Real b2 = M(2, 0) * M(3, 3) - M(2, 3) * M(3, 0);
100 Real b3 = M(2, 1) * M(3, 2) - M(2, 2) * M(3, 1);
101 Real b4 = M(2, 1) * M(3, 3) - M(2, 3) * M(3, 1);
102 Real b5 = M(2, 2) * M(3, 3) - M(2, 3) * M(3, 2);
103 Real det = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0;
106 Real invDet = ((Real)1) / det;
109 (+M(1, 1) * b5 - M(1, 2) * b4 + M(1, 3) * b3) * invDet,
110 (-M(0, 1) * b5 + M(0, 2) * b4 - M(0, 3) * b3) * invDet,
111 (+M(3, 1) * a5 - M(3, 2) * a4 + M(3, 3) * a3) * invDet,
112 (-M(2, 1) * a5 + M(2, 2) * a4 - M(2, 3) * a3) * invDet,
113 (-M(1, 0) * b5 + M(1, 2) * b2 - M(1, 3) * b1) * invDet,
114 (+M(0, 0) * b5 - M(0, 2) * b2 + M(0, 3) * b1) * invDet,
115 (-M(3, 0) * a5 + M(3, 2) * a2 - M(3, 3) * a1) * invDet,
116 (+M(2, 0) * a5 - M(2, 2) * a2 + M(2, 3) * a1) * invDet,
117 (+M(1, 0) * b4 - M(1, 1) * b2 + M(1, 3) * b0) * invDet,
118 (-M(0, 0) * b4 + M(0, 1) * b2 - M(0, 3) * b0) * invDet,
119 (+M(3, 0) * a4 - M(3, 1) * a2 + M(3, 3) * a0) * invDet,
120 (-M(2, 0) * a4 + M(2, 1) * a2 - M(2, 3) * a0) * invDet,
121 (-M(1, 0) * b3 + M(1, 1) * b1 - M(1, 2) * b0) * invDet,
122 (+M(0, 0) * b3 - M(0, 1) * b1 + M(0, 2) * b0) * invDet,
123 (-M(3, 0) * a3 + M(3, 1) * a1 - M(3, 2) * a0) * invDet,
124 (+M(2, 0) * a3 - M(2, 1) * a1 + M(2, 2) * a0) * invDet
134 if (reportInvertibility)
136 *reportInvertibility = invertible;
141 template <
typename Real>
144 Real a0 = M(0, 0) * M(1, 1) - M(0, 1) * M(1, 0);
145 Real a1 = M(0, 0) * M(1, 2) - M(0, 2) * M(1, 0);
146 Real a2 = M(0, 0) * M(1, 3) - M(0, 3) * M(1, 0);
147 Real a3 = M(0, 1) * M(1, 2) - M(0, 2) * M(1, 1);
148 Real a4 = M(0, 1) * M(1, 3) - M(0, 3) * M(1, 1);
149 Real a5 = M(0, 2) * M(1, 3) - M(0, 3) * M(1, 2);
150 Real b0 = M(2, 0) * M(3, 1) - M(2, 1) * M(3, 0);
151 Real b1 = M(2, 0) * M(3, 2) - M(2, 2) * M(3, 0);
152 Real b2 = M(2, 0) * M(3, 3) - M(2, 3) * M(3, 0);
153 Real b3 = M(2, 1) * M(3, 2) - M(2, 2) * M(3, 1);
154 Real b4 = M(2, 1) * M(3, 3) - M(2, 3) * M(3, 1);
155 Real b5 = M(2, 2) * M(3, 3) - M(2, 3) * M(3, 2);
159 +M(1, 1) * b5 - M(1, 2) * b4 + M(1, 3) * b3,
160 -M(0, 1) * b5 + M(0, 2) * b4 - M(0, 3) * b3,
161 +M(3, 1) * a5 - M(3, 2) * a4 + M(3, 3) * a3,
162 -M(2, 1) * a5 + M(2, 2) * a4 - M(2, 3) * a3,
163 -M(1, 0) * b5 + M(1, 2) * b2 - M(1, 3) * b1,
164 +M(0, 0) * b5 - M(0, 2) * b2 + M(0, 3) * b1,
165 -M(3, 0) * a5 + M(3, 2) * a2 - M(3, 3) * a1,
166 +M(2, 0) * a5 - M(2, 2) * a2 + M(2, 3) * a1,
167 +M(1, 0) * b4 - M(1, 1) * b2 + M(1, 3) * b0,
168 -M(0, 0) * b4 + M(0, 1) * b2 - M(0, 3) * b0,
169 +M(3, 0) * a4 - M(3, 1) * a2 + M(3, 3) * a0,
170 -M(2, 0) * a4 + M(2, 1) * a2 - M(2, 3) * a0,
171 -M(1, 0) * b3 + M(1, 1) * b1 - M(1, 2) * b0,
172 +M(0, 0) * b3 - M(0, 1) * b1 + M(0, 2) * b0,
173 -M(3, 0) * a3 + M(3, 1) * a1 - M(3, 2) * a0,
174 +M(2, 0) * a3 - M(2, 1) * a1 + M(2, 2) * a0
178 template <
typename Real>
181 Real a0 = M(0, 0) * M(1, 1) - M(0, 1) * M(1, 0);
182 Real a1 = M(0, 0) * M(1, 2) - M(0, 2) * M(1, 0);
183 Real a2 = M(0, 0) * M(1, 3) - M(0, 3) * M(1, 0);
184 Real a3 = M(0, 1) * M(1, 2) - M(0, 2) * M(1, 1);
185 Real a4 = M(0, 1) * M(1, 3) - M(0, 3) * M(1, 1);
186 Real a5 = M(0, 2) * M(1, 3) - M(0, 3) * M(1, 2);
187 Real b0 = M(2, 0) * M(3, 1) - M(2, 1) * M(3, 0);
188 Real b1 = M(2, 0) * M(3, 2) - M(2, 2) * M(3, 0);
189 Real b2 = M(2, 0) * M(3, 3) - M(2, 3) * M(3, 0);
190 Real b3 = M(2, 1) * M(3, 2) - M(2, 2) * M(3, 1);
191 Real b4 = M(2, 1) * M(3, 3) - M(2, 3) * M(3, 1);
192 Real b5 = M(2, 2) * M(3, 3) - M(2, 3) * M(3, 2);
193 Real det = a0 * b5 - a1 * b4 + a2 * b3 + a3 * b2 - a4 * b1 + a5 * b0;
197 template <
typename Real>
200 Real trace = M(0, 0) + M(1, 1) + M(2, 2) + M(3, 3);
204 template <
typename Real>
210 Real
const zero = (Real)0;
211 Real dotND =
Dot(normal, direction);
212 Real dotNO =
Dot(origin, normal);
214 #if defined(GTE_USE_MAT_VEC) 215 M(0, 0) = direction[0] * normal[0] - dotND;
216 M(0, 1) = direction[0] * normal[1];
217 M(0, 2) = direction[0] * normal[2];
218 M(0, 3) = -dotNO * direction[0];
219 M(1, 0) = direction[1] * normal[0];
220 M(1, 1) = direction[1] * normal[1] - dotND;
221 M(1, 2) = direction[1] * normal[2];
222 M(1, 3) = -dotNO * direction[1];
223 M(2, 0) = direction[2] * normal[0];
224 M(2, 1) = direction[2] * normal[1];
225 M(2, 2) = direction[2] * normal[2] - dotND;
226 M(2, 3) = -dotNO * direction[2];
232 M(0, 0) = direction[0] * normal[0] - dotND;
233 M(1, 0) = direction[0] * normal[1];
234 M(2, 0) = direction[0] * normal[2];
235 M(3, 0) = -dotNO * direction[0];
236 M(0, 1) = direction[1] * normal[0];
237 M(1, 1) = direction[1] * normal[1] - dotND;
238 M(2, 1) = direction[1] * normal[2];
239 M(3, 1) = -dotNO * direction[1];
240 M(0, 2) = direction[2] * normal[0];
241 M(1, 2) = direction[2] * normal[1];
242 M(2, 2) = direction[2] * normal[2] - dotND;
243 M(3, 2) = -dotNO * direction[2];
253 template <
typename Real>
259 Real dotND =
Dot(normal, eye - origin);
261 #if defined(GTE_USE_MAT_VEC) 262 M(0, 0) = dotND - eye[0] * normal[0];
263 M(0, 1) = -eye[0] * normal[1];
264 M(0, 2) = -eye[0] * normal[2];
265 M(0, 3) = -(M(0, 0) * eye[0] + M(0, 1) * eye[1] + M(0, 2) * eye[2]);
266 M(1, 0) = -eye[1] * normal[0];
267 M(1, 1) = dotND - eye[1] * normal[1];
268 M(1, 2) = -eye[1] * normal[2];
269 M(1, 3) = -(M(1, 0) * eye[0] + M(1, 1) * eye[1] + M(1, 2) * eye[2]);
270 M(2, 0) = -eye[2] * normal[0];
271 M(2, 1) = -eye[2] * normal[1];
272 M(2, 2) = dotND - eye[2] * normal[2];
273 M(2, 3) = -(M(2, 0) * eye[0] + M(2, 1) * eye[1] + M(2, 2) * eye[2]);
274 M(3, 0) = -normal[0];
275 M(3, 1) = -normal[1];
276 M(3, 2) = -normal[2];
277 M(3, 3) =
Dot(eye, normal);
279 M(0, 0) = dotND - eye[0] * normal[0];
280 M(1, 0) = -eye[0] * normal[1];
281 M(2, 0) = -eye[0] * normal[2];
282 M(3, 0) = -(M(0, 0) * eye[0] + M(0, 1) * eye[1] + M(0, 2) * eye[2]);
283 M(0, 1) = -eye[1] * normal[0];
284 M(1, 1) = dotND - eye[1] * normal[1];
285 M(2, 1) = -eye[1] * normal[2];
286 M(3, 1) = -(M(1, 0) * eye[0] + M(1, 1) * eye[1] + M(1, 2) * eye[2]);
287 M(0, 2) = -eye[2] * normal[0];
288 M(1, 2) = -eye[2] * normal[1];
289 M(2, 2) = dotND - eye[2] * normal[2];
290 M(3, 2) = -(M(2, 0) * eye[0] + M(2, 1) * eye[1] + M(2, 2) * eye[2]);
291 M(0, 3) = -normal[0];
292 M(1, 3) = -normal[1];
293 M(2, 3) = -normal[2];
294 M(3, 3) =
Dot(eye, normal);
300 template <
typename Real>
306 Real
const zero = (Real)0, one = (Real)1, two = (Real)2;
307 Real twoDotNO = two *
Dot(origin, normal);
309 #if defined(GTE_USE_MAT_VEC) 310 M(0, 0) = one - two * normal[0] * normal[0];
311 M(0, 1) = -two * normal[0] * normal[1];
312 M(0, 2) = -two * normal[0] * normal[2];
313 M(0, 3) = twoDotNO * normal[0];
315 M(1, 1) = one - two * normal[1] * normal[1];
316 M(1, 2) = -two * normal[1] * normal[2];
317 M(1, 3) = twoDotNO * normal[1];
320 M(2, 2) = one - two * normal[2] * normal[2];
321 M(2, 3) = twoDotNO * normal[2];
327 M(0, 0) = one - two * normal[0] * normal[0];
328 M(1, 0) = -two * normal[0] * normal[1];
329 M(2, 0) = -two * normal[0] * normal[2];
330 M(3, 0) = twoDotNO * normal[0];
332 M(1, 1) = one - two * normal[1] * normal[1];
333 M(2, 1) = -two * normal[1] * normal[2];
334 M(3, 1) = twoDotNO * normal[1];
337 M(2, 2) = one - two * normal[2] * normal[2];
338 M(3, 2) = twoDotNO * normal[2];
Matrix2x2< Real > Adjoint(Matrix2x2< Real > const &M)
Real Trace(Matrix2x2< Real > const &M)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
Matrix4x4< Real > MakeReflection(Vector4< Real > const &origin, Vector4< Real > const &normal)
Matrix4x4< Real > MakeObliqueProjection(Vector4< Real > const &origin, Vector4< Real > const &normal, Vector4< Real > const &direction)
Quaternion< Real > Inverse(Quaternion< Real > const &d)
Real Determinant(GMatrix< Real > const &M)
Matrix4x4< Real > MakePerspectiveProjection(Vector4< Real > const &origin, Vector4< Real > const &normal, Vector4< Real > const &eye)