Jypeli 10
The simple game programming library
Matrix4x4.cs
Siirry tämän tiedoston dokumentaatioon.
1#region MIT License
2/*
3 * Copyright (c) 2005-2008 Jonathan Mark Porter. http://physics2d.googlepages.com/
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22#endregion
23
24
25
26#if UseDouble
27using Scalar = System.Double;
28#else
29using Scalar = System.Single;
30#endif
31using System;
32
33using System.Runtime.InteropServices;
35using System.Xml.Serialization;
36
37namespace AdvanceMath
38{
39 [StructLayout(LayoutKind.Sequential, Size = Matrix4x4.Size)]
40 [AdvBrowsableOrder("Rx,Ry,Rz,Rw")]
41#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE && !NETFX_CORE
42 [Serializable]
43 [System.ComponentModel.TypeConverter(typeof(AdvTypeConverter<Matrix4x4>))]
44#endif
45 public struct Matrix4x4 : IMatrix<Matrix4x4, Vector4D, Vector4D>
46 {
47 #region const fields
51 public const int RowCount = 4;
55 public const int ColumnCount = 4;
59 public const int Count = RowCount * ColumnCount;
63 public const int Size = sizeof(Scalar) * Count;
64 #endregion
65 #region static fields
66 public readonly static Matrix4x4 Zero = new Matrix4x4(
67 0, 0, 0, 0,
68 0, 0, 0, 0,
69 0, 0, 0, 0,
70 0, 0, 0, 0);
71
72 public readonly static Matrix4x4 Identity = new Matrix4x4(
73 1, 0, 0, 0,
74 0, 1, 0, 0,
75 0, 0, 1, 0,
76 0, 0, 0, 1);
77
80 #endregion
81 #region static methods
82
83 public static void Copy(ref Matrix4x4 matrix, Scalar[] destArray)
84 {
85 Copy(ref matrix, destArray, 0);
86 }
87 public static void Copy(ref Matrix4x4 matrix, Scalar[] destArray, int index)
88 {
89 ThrowHelper.CheckCopy(destArray, index, Count);
90
91 destArray[index] = matrix.m00;
92 destArray[++index] = matrix.m01;
93 destArray[++index] = matrix.m02;
94 destArray[++index] = matrix.m03;
95
96 destArray[++index] = matrix.m10;
97 destArray[++index] = matrix.m11;
98 destArray[++index] = matrix.m12;
99 destArray[++index] = matrix.m13;
100
101 destArray[++index] = matrix.m20;
102 destArray[++index] = matrix.m21;
103 destArray[++index] = matrix.m22;
104 destArray[++index] = matrix.m23;
105
106 destArray[++index] = matrix.m30;
107 destArray[++index] = matrix.m31;
108 destArray[++index] = matrix.m32;
109 destArray[++index] = matrix.m33;
110 }
111 public static void Copy(Scalar[] sourceArray, out Matrix4x4 result)
112 {
113 Copy(sourceArray, 0, out result);
114 }
115 public static void Copy(Scalar[] sourceArray, int index, out Matrix4x4 result)
116 {
117 ThrowHelper.CheckCopy(sourceArray, index, Count);
118
119 result.m00 = sourceArray[index];
120 result.m01 = sourceArray[++index];
121 result.m02 = sourceArray[++index];
122 result.m03 = sourceArray[++index];
123
124 result.m10 = sourceArray[++index];
125 result.m11 = sourceArray[++index];
126 result.m12 = sourceArray[++index];
127 result.m13 = sourceArray[++index];
128
129 result.m20 = sourceArray[++index];
130 result.m21 = sourceArray[++index];
131 result.m22 = sourceArray[++index];
132 result.m23 = sourceArray[++index];
133
134 result.m30 = sourceArray[++index];
135 result.m31 = sourceArray[++index];
136 result.m32 = sourceArray[++index];
137 result.m33 = sourceArray[++index];
138 }
139 public static void CopyTranspose(ref Matrix4x4 matrix, Scalar[] destArray)
140 {
141 CopyTranspose(ref matrix, destArray, 0);
142 }
143 public static void CopyTranspose(ref Matrix4x4 matrix, Scalar[] destArray, int index)
144 {
145 ThrowHelper.CheckCopy(destArray, index, Count);
146
147 destArray[index] = matrix.m00;
148 destArray[++index] = matrix.m10;
149 destArray[++index] = matrix.m20;
150 destArray[++index] = matrix.m30;
151
152 destArray[++index] = matrix.m01;
153 destArray[++index] = matrix.m11;
154 destArray[++index] = matrix.m21;
155 destArray[++index] = matrix.m31;
156
157 destArray[++index] = matrix.m02;
158 destArray[++index] = matrix.m12;
159 destArray[++index] = matrix.m22;
160 destArray[++index] = matrix.m32;
161
162 destArray[++index] = matrix.m03;
163 destArray[++index] = matrix.m13;
164 destArray[++index] = matrix.m23;
165 destArray[++index] = matrix.m33;
166 }
167 public static void CopyTranspose(Scalar[] sourceArray, out Matrix4x4 result)
168 {
169 CopyTranspose(sourceArray, 0, out result);
170 }
171 public static void CopyTranspose(Scalar[] sourceArray, int index, out Matrix4x4 result)
172 {
173 ThrowHelper.CheckCopy(sourceArray, index, Count);
174
175 result.m00 = sourceArray[index];
176 result.m10 = sourceArray[++index];
177 result.m20 = sourceArray[++index];
178 result.m30 = sourceArray[++index];
179
180 result.m01 = sourceArray[++index];
181 result.m11 = sourceArray[++index];
182 result.m21 = sourceArray[++index];
183 result.m31 = sourceArray[++index];
184
185 result.m02 = sourceArray[++index];
186 result.m12 = sourceArray[++index];
187 result.m22 = sourceArray[++index];
188 result.m32 = sourceArray[++index];
189
190 result.m03 = sourceArray[++index];
191 result.m13 = sourceArray[++index];
192 result.m23 = sourceArray[++index];
193 result.m33 = sourceArray[++index];
194 }
195 public static void Copy(ref Matrix3x3 source, ref Matrix4x4 dest)
196 {
197 dest.m00 = source.m00;
198 dest.m01 = source.m01;
199 dest.m02 = source.m02;
200
201 dest.m10 = source.m10;
202 dest.m11 = source.m11;
203 dest.m12 = source.m12;
204
205 dest.m20 = source.m20;
206 dest.m21 = source.m21;
207 dest.m22 = source.m22;
208 }
209 public static void Copy(ref Matrix2x2 source, ref Matrix4x4 dest)
210 {
211 dest.m00 = source.m00;
212 dest.m01 = source.m01;
213
214 dest.m10 = source.m10;
215 dest.m11 = source.m11;
216 }
217
218 public static Matrix4x4 Lerp(Matrix4x4 left, Matrix4x4 right, Scalar amount)
219 {
220 Matrix4x4 result;
221 Lerp(ref left, ref right, ref amount, out result);
222 return result;
223 }
224 public static void Lerp(ref Matrix4x4 left, ref Matrix4x4 right, ref Scalar amount, out Matrix4x4 result)
225 {
226 result.m00 = (right.m00 - left.m00) * amount + left.m00;
227 result.m01 = (right.m01 - left.m01) * amount + left.m01;
228 result.m02 = (right.m02 - left.m02) * amount + left.m02;
229 result.m03 = (right.m03 - left.m03) * amount + left.m03;
230
231 result.m10 = (right.m10 - left.m10) * amount + left.m10;
232 result.m11 = (right.m11 - left.m11) * amount + left.m11;
233 result.m12 = (right.m12 - left.m12) * amount + left.m12;
234 result.m13 = (right.m13 - left.m13) * amount + left.m13;
235
236 result.m20 = (right.m20 - left.m20) * amount + left.m20;
237 result.m21 = (right.m21 - left.m21) * amount + left.m21;
238 result.m22 = (right.m22 - left.m22) * amount + left.m22;
239 result.m23 = (right.m23 - left.m23) * amount + left.m23;
240
241 result.m30 = (right.m30 - left.m30) * amount + left.m30;
242 result.m31 = (right.m31 - left.m31) * amount + left.m31;
243 result.m32 = (right.m32 - left.m32) * amount + left.m32;
244 result.m33 = (right.m33 - left.m33) * amount + left.m33;
245
246 }
247
248
249 public static Matrix4x4 FromArray(Scalar[] array)
250 {
251 Matrix4x4 result;
252 Copy(array, 0, out result);
253 return result;
254 }
255 public static Matrix4x4 FromTransposedArray(Scalar[] array)
256 {
257 Matrix4x4 result;
258 CopyTranspose(array, 0, out result);
259 return result;
260 }
261
262 public static Matrix4x4 FromTranslation(Vector3D translation)
263 {
264 Matrix4x4 result;
265
266 result.m00 = 1;
267 result.m01 = 0;
268 result.m02 = 0;
269 result.m03 = translation.X;
270
271 result.m10 = 0;
272 result.m11 = 1;
273 result.m12 = 0;
274 result.m13 = translation.Y;
275
276 result.m20 = 0;
277 result.m21 = 0;
278 result.m22 = 1;
279 result.m23 = translation.Z;
280
281 result.m30 = 0;
282 result.m31 = 0;
283 result.m32 = 0;
284 result.m33 = 1;
285
286 return result;
287 }
288 public static void FromTranslation(ref Vector3D translation, out Matrix4x4 result)
289 {
290 result.m00 = 1;
291 result.m01 = 0;
292 result.m02 = 0;
293 result.m03 = translation.X;
294
295 result.m10 = 0;
296 result.m11 = 1;
297 result.m12 = 0;
298 result.m13 = translation.Y;
299
300 result.m20 = 0;
301 result.m21 = 0;
302 result.m22 = 1;
303 result.m23 = translation.Z;
304
305 result.m30 = 0;
306 result.m31 = 0;
307 result.m32 = 0;
308 result.m33 = 1;
309 }
310 public static Matrix4x4 FromScale(Vector3D scale)
311 {
312 Matrix4x4 result;
313 result.m00 = scale.X;
314 result.m01 = 0;
315 result.m02 = 0;
316 result.m03 = 0;
317
318 result.m10 = 0;
319 result.m11 = scale.Y;
320 result.m12 = 0;
321 result.m13 = 0;
322
323 result.m20 = 0;
324 result.m21 = 0;
325 result.m22 = scale.Z;
326 result.m23 = 0;
327
328 result.m30 = 0;
329 result.m31 = 0;
330 result.m32 = 0;
331 result.m33 = 1;
332 return result;
333 }
334 public static void FromScale(ref Vector3D scale, out Matrix4x4 result)
335 {
336 result.m00 = scale.X;
337 result.m01 = 0;
338 result.m02 = 0;
339 result.m03 = 0;
340
341 result.m10 = 0;
342 result.m11 = scale.Y;
343 result.m12 = 0;
344 result.m13 = 0;
345
346 result.m20 = 0;
347 result.m21 = 0;
348 result.m22 = scale.Z;
349 result.m23 = 0;
350
351 result.m30 = 0;
352 result.m31 = 0;
353 result.m32 = 0;
354 result.m33 = 1;
355 }
356 public static Matrix4x4 FromLookAt(Vector3D origin, Vector3D positiveZAxis, Vector3D onPositiveY)
357 {
358 return Matrix3x3.FromLookAt(origin, positiveZAxis, onPositiveY) * FromTranslation(-origin);
359 }
360
362 Scalar left, Scalar right,
363 Scalar bottom, Scalar top,
364 Scalar near, Scalar far)
365 {
366
367 Matrix4x4 result;
368 result.m00 = 2 / (right - left);
369 result.m01 = 0;
370 result.m02 = 0;
371 result.m03 = -(right + left) / (right - left);
372
373 result.m10 = 0;
374 result.m11 = 2 / (top - bottom);
375 result.m12 = 0;
376 result.m13 = -(top + bottom) / (top - bottom);
377
378 result.m20 = 0;
379 result.m21 = 0;
380 result.m22 = -2 / (far - near);
381 result.m23 = (far + near) / (far - near);
382
383 result.m30 = 0;
384 result.m31 = 0;
385 result.m32 = 0;
386 result.m33 = 1;
387 return result;
388 }
389
390 public static Matrix4x4 From2DMatrix(Matrix3x3 source)
391 {
392 Matrix4x4 result;
393 From2DMatrix(ref source, out result);
394 return result;
395 }
396 public static void From2DMatrix(ref Matrix3x3 source, out Matrix4x4 result)
397 {
398 result.m00 = source.m00;
399 result.m01 = source.m01;
400 result.m02 = 0;
401 result.m03 = source.m02;
402
403 result.m10 = source.m10;
404 result.m11 = source.m11;
405 result.m12 = 0;
406 result.m13 = source.m12;
407
408 result.m20 = 0;
409 result.m21 = 0;
410 result.m22 = 1;
411 result.m23 = 0;
412
413 result.m30 = source.m20;
414 result.m31 = source.m21;
415 result.m32 = 0;
416 result.m33 = source.m22;
417 }
418
419 public static Matrix4x4 From2DMatrix(Matrix2x3 source)
420 {
421 Matrix4x4 result;
422 From2DMatrix(ref source, out result);
423 return result;
424 }
425 public static void From2DMatrix(ref Matrix2x3 source, out Matrix4x4 result)
426 {
427 result.m00 = source.m00;
428 result.m01 = source.m01;
429 result.m02 = 0;
430 result.m03 = source.m02;
431
432 result.m10 = source.m10;
433 result.m11 = source.m11;
434 result.m12 = 0;
435 result.m13 = source.m12;
436
437 result.m20 = 0;
438 result.m21 = 0;
439 result.m22 = 1;
440 result.m23 = 0;
441
442 result.m30 = 0;
443 result.m31 = 0;
444 result.m32 = 0;
445 result.m33 = 1;
446 }
447
448 public static Matrix4x4 Multiply(Matrix4x4 left, Matrix4x4 right)
449 {
450 Matrix4x4 result;
451
452 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20 + left.m03 * right.m30;
453 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21 + left.m03 * right.m31;
454 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22 + left.m03 * right.m32;
455 result.m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23 + left.m03 * right.m33;
456
457 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20 + left.m13 * right.m30;
458 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21 + left.m13 * right.m31;
459 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22 + left.m13 * right.m32;
460 result.m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23 + left.m13 * right.m33;
461
462 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20 + left.m23 * right.m30;
463 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21 + left.m23 * right.m31;
464 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22 + left.m23 * right.m32;
465 result.m23 = left.m20 * right.m03 + left.m21 * right.m13 + left.m22 * right.m23 + left.m23 * right.m33;
466
467 result.m30 = left.m30 * right.m00 + left.m31 * right.m10 + left.m32 * right.m20 + left.m33 * right.m30;
468 result.m31 = left.m30 * right.m01 + left.m31 * right.m11 + left.m32 * right.m21 + left.m33 * right.m31;
469 result.m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32 * right.m22 + left.m33 * right.m32;
470 result.m33 = left.m30 * right.m03 + left.m31 * right.m13 + left.m32 * right.m23 + left.m33 * right.m33;
471
472 return result;
473 }
474 public static void Multiply(ref Matrix4x4 left, ref Matrix4x4 right, out Matrix4x4 result)
475 {
476
477
478 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20 + left.m03 * right.m30;
479 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21 + left.m03 * right.m31;
480 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22 + left.m03 * right.m32;
481 Scalar m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23 + left.m03 * right.m33;
482
483 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20 + left.m13 * right.m30;
484 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21 + left.m13 * right.m31;
485 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22 + left.m13 * right.m32;
486 Scalar m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23 + left.m13 * right.m33;
487
488 Scalar m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20 + left.m23 * right.m30;
489 Scalar m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21 + left.m23 * right.m31;
490 Scalar m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22 + left.m23 * right.m32;
491 Scalar m23 = left.m20 * right.m03 + left.m21 * right.m13 + left.m22 * right.m23 + left.m23 * right.m33;
492
493 Scalar m30 = left.m30 * right.m00 + left.m31 * right.m10 + left.m32 * right.m20 + left.m33 * right.m30;
494 Scalar m31 = left.m30 * right.m01 + left.m31 * right.m11 + left.m32 * right.m21 + left.m33 * right.m31;
495 Scalar m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32 * right.m22 + left.m33 * right.m32;
496 Scalar m33 = left.m30 * right.m03 + left.m31 * right.m13 + left.m32 * right.m23 + left.m33 * right.m33;
497
498 result.m00 = m00;
499 result.m01 = m01;
500 result.m02 = m02;
501 result.m03 = m03;
502
503 result.m10 = m10;
504 result.m11 = m11;
505 result.m12 = m12;
506 result.m13 = m13;
507
508 result.m20 = m20;
509 result.m21 = m21;
510 result.m22 = m22;
511 result.m23 = m23;
512
513 result.m30 = m30;
514 result.m31 = m31;
515 result.m32 = m32;
516 result.m33 = m33;
517
518
519
520 }
521
522 public static Matrix4x4 Multiply(Matrix4x4 left, Scalar scalar)
523 {
524 Matrix4x4 result;
525
526 result.m00 = left.m00 * scalar;
527 result.m01 = left.m01 * scalar;
528 result.m02 = left.m02 * scalar;
529 result.m03 = left.m03 * scalar;
530
531 result.m10 = left.m10 * scalar;
532 result.m11 = left.m11 * scalar;
533 result.m12 = left.m12 * scalar;
534 result.m13 = left.m13 * scalar;
535
536 result.m20 = left.m20 * scalar;
537 result.m21 = left.m21 * scalar;
538 result.m22 = left.m22 * scalar;
539 result.m23 = left.m23 * scalar;
540
541 result.m30 = left.m30 * scalar;
542 result.m31 = left.m31 * scalar;
543 result.m32 = left.m32 * scalar;
544 result.m33 = left.m33 * scalar;
545
546 return result;
547 }
548 public static void Multiply(ref Matrix4x4 left, ref Scalar scalar, out Matrix4x4 result)
549 {
550
551 result.m00 = left.m00 * scalar;
552 result.m01 = left.m01 * scalar;
553 result.m02 = left.m02 * scalar;
554 result.m03 = left.m03 * scalar;
555
556 result.m10 = left.m10 * scalar;
557 result.m11 = left.m11 * scalar;
558 result.m12 = left.m12 * scalar;
559 result.m13 = left.m13 * scalar;
560
561 result.m20 = left.m20 * scalar;
562 result.m21 = left.m21 * scalar;
563 result.m22 = left.m22 * scalar;
564 result.m23 = left.m23 * scalar;
565
566 result.m30 = left.m30 * scalar;
567 result.m31 = left.m31 * scalar;
568 result.m32 = left.m32 * scalar;
569 result.m33 = left.m33 * scalar;
570 }
571
572 public static Matrix4x4 Multiply(Matrix4x4 left, Matrix3x3 right)
573 {
574 Matrix4x4 result;
575
576 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
577 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
578 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
579 result.m03 = left.m03;
580
581 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
582 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
583 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
584 result.m13 = left.m13;
585
586 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
587 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
588 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
589 result.m23 = left.m23;
590
591 result.m30 = left.m30 * right.m00 + left.m31 * right.m10 + left.m32 * right.m20;
592 result.m31 = left.m30 * right.m01 + left.m31 * right.m11 + left.m32 * right.m21;
593 result.m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32 * right.m22;
594 result.m33 = left.m33;
595
596 return result;
597 }
598 public static void Multiply(ref Matrix4x4 left, ref Matrix3x3 right, out Matrix4x4 result)
599 {
600 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
601 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
602 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
603
604 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
605 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
606 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
607
608 Scalar m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
609 Scalar m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
610 Scalar m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
611
612 Scalar m30 = left.m30 * right.m00 + left.m31 * right.m10 + left.m32 * right.m20;
613 Scalar m31 = left.m30 * right.m01 + left.m31 * right.m11 + left.m32 * right.m21;
614 Scalar m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32 * right.m22;
615
616
617 result.m00 = m00;
618 result.m01 = m01;
619 result.m02 = m02;
620 result.m03 = left.m03;
621
622 result.m10 = m10;
623 result.m11 = m11;
624 result.m12 = m12;
625 result.m13 = left.m13;
626
627 result.m20 = m20;
628 result.m21 = m21;
629 result.m22 = m22;
630 result.m23 = left.m23;
631
632 result.m30 = m30;
633 result.m31 = m31;
634 result.m32 = m32;
635 result.m33 = left.m33;
636 }
637
638 public static Matrix4x4 Multiply(Matrix3x3 left, Matrix4x4 right)
639 {
640 Matrix4x4 result;
641
642 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
643 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
644 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
645 result.m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23;
646
647 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
648 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
649 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
650 result.m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23;
651
652 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
653 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
654 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
655 result.m23 = left.m20 * right.m03 + left.m21 * right.m13 + left.m22 * right.m23;
656
657 result.m30 = right.m30;
658 result.m31 = right.m31;
659 result.m32 = right.m32;
660 result.m33 = right.m33;
661
662 return result;
663 }
664 public static void Multiply(ref Matrix3x3 left, ref Matrix4x4 right, out Matrix4x4 result)
665 {
666 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
667 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
668 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
669 Scalar m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23;
670
671 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
672 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
673 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
674 Scalar m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23;
675
676 Scalar m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
677 Scalar m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
678 Scalar m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
679 Scalar m23 = left.m20 * right.m03 + left.m21 * right.m13 + left.m22 * right.m23;
680
681 result.m00 = m00;
682 result.m01 = m01;
683 result.m02 = m02;
684 result.m03 = m03;
685
686 result.m10 = m10;
687 result.m11 = m11;
688 result.m12 = m12;
689 result.m13 = m13;
690
691 result.m20 = m20;
692 result.m21 = m21;
693 result.m22 = m22;
694 result.m23 = m23;
695
696 result.m30 = right.m30;
697 result.m31 = right.m31;
698 result.m32 = right.m32;
699 result.m33 = right.m33;
700 }
701
702 public static Matrix4x4 Multiply(Matrix4x4 left, Matrix2x3 right)
703 {
704 Matrix4x4 result;
705
706 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
707 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
708 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02;
709 result.m03 = left.m03;
710
711 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
712 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
713 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12;
714 result.m13 = left.m13;
715
716 result.m20 = left.m20 * right.m00 + left.m21 * right.m10;
717 result.m21 = left.m20 * right.m01 + left.m21 * right.m11;
718 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22;
719 result.m23 = left.m23;
720
721 result.m30 = left.m30 * right.m00 + left.m31 * right.m10;
722 result.m31 = left.m30 * right.m01 + left.m31 * right.m11;
723 result.m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32;
724 result.m33 = left.m33;
725
726 return result;
727 }
728 public static void Multiply(ref Matrix4x4 left, ref Matrix2x3 right, out Matrix4x4 result)
729 {
730 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10;
731 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11;
732 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02;
733
734 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10;
735 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11;
736 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12;
737
738 Scalar m20 = left.m20 * right.m00 + left.m21 * right.m10;
739 Scalar m21 = left.m20 * right.m01 + left.m21 * right.m11;
740 Scalar m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22;
741
742 Scalar m30 = left.m30 * right.m00 + left.m31 * right.m10;
743 Scalar m31 = left.m30 * right.m01 + left.m31 * right.m11;
744 Scalar m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32;
745
746
747 result.m00 = m00;
748 result.m01 = m01;
749 result.m02 = m02;
750 result.m03 = left.m03;
751
752 result.m10 = m10;
753 result.m11 = m11;
754 result.m12 = m12;
755 result.m13 = left.m13;
756
757 result.m20 = m20;
758 result.m21 = m21;
759 result.m22 = m22;
760 result.m23 = left.m23;
761
762 result.m30 = m30;
763 result.m31 = m31;
764 result.m32 = m32;
765 result.m33 = left.m33;
766 }
767
768 public static Matrix4x4 Multiply(Matrix2x3 left, Matrix4x4 right)
769 {
770 Matrix4x4 result;
771
772 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
773 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
774 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
775 result.m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23;
776
777 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
778 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
779 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
780 result.m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23;
781
782 result.m20 = right.m20;
783 result.m21 = right.m21;
784 result.m22 = right.m22;
785 result.m23 = right.m23;
786
787 result.m30 = right.m30;
788 result.m31 = right.m31;
789 result.m32 = right.m32;
790 result.m33 = right.m33;
791
792 return result;
793 }
794 public static void Multiply(ref Matrix2x3 left, ref Matrix4x4 right, out Matrix4x4 result)
795 {
796 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
797 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
798 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
799 Scalar m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23;
800
801 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
802 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
803 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
804 Scalar m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23;
805
806 result.m00 = m00;
807 result.m01 = m01;
808 result.m02 = m02;
809 result.m03 = m03;
810
811 result.m10 = m10;
812 result.m11 = m11;
813 result.m12 = m12;
814 result.m13 = m13;
815
816 result.m20 = right.m20;
817 result.m21 = right.m21;
818 result.m22 = right.m22;
819 result.m23 = right.m23;
820
821 result.m30 = right.m30;
822 result.m31 = right.m31;
823 result.m32 = right.m32;
824 result.m33 = right.m33;
825 }
826
827 public static Matrix4x4 Multiply(Matrix4x4 left, Matrix2x2 right)
828 {
829 Matrix4x4 result;
830
831 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
832 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
833 result.m02 = left.m02;
834 result.m03 = left.m03;
835
836 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
837 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
838 result.m12 = left.m12;
839 result.m13 = left.m13;
840
841 result.m20 = left.m20 * right.m00 + left.m21 * right.m10;
842 result.m21 = left.m20 * right.m01 + left.m21 * right.m11;
843 result.m22 = left.m22;
844 result.m23 = left.m23;
845
846 result.m30 = left.m30 * right.m00 + left.m31 * right.m10;
847 result.m31 = left.m30 * right.m01 + left.m31 * right.m11;
848 result.m32 = left.m32;
849 result.m33 = left.m33;
850
851 return result;
852 }
853 public static void Multiply(ref Matrix4x4 left, ref Matrix2x2 right, out Matrix4x4 result)
854 {
855 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10;
856 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11;
857
858
859 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10;
860 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11;
861
862
863 Scalar m20 = left.m20 * right.m00 + left.m21 * right.m10;
864 Scalar m21 = left.m20 * right.m01 + left.m21 * right.m11;
865
866
867 Scalar m30 = left.m30 * right.m00 + left.m31 * right.m10;
868 Scalar m31 = left.m30 * right.m01 + left.m31 * right.m11;
869
870
871 result.m00 = m00;
872 result.m01 = m01;
873 result.m02 = left.m02;
874 result.m03 = left.m03;
875
876 result.m10 = m10;
877 result.m11 = m11;
878 result.m12 = left.m12;
879 result.m13 = left.m13;
880
881 result.m20 = m20;
882 result.m21 = m21;
883 result.m22 = left.m22;
884 result.m23 = left.m23;
885
886 result.m30 = m30;
887 result.m31 = m31;
888 result.m32 = left.m32;
889 result.m33 = left.m33;
890
891
892 }
893
894 public static Matrix4x4 Multiply(Matrix2x2 left, Matrix4x4 right)
895 {
896 Matrix4x4 result;
897
898 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
899 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
900 result.m02 = left.m00 * right.m02 + left.m01 * right.m12;
901 result.m03 = left.m00 * right.m03 + left.m01 * right.m13;
902
903 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
904 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
905 result.m12 = left.m10 * right.m02 + left.m11 * right.m12;
906 result.m13 = left.m10 * right.m03 + left.m11 * right.m13;
907
908 result.m20 = right.m20;
909 result.m21 = right.m21;
910 result.m22 = right.m22;
911 result.m23 = right.m23;
912
913 result.m30 = right.m30;
914 result.m31 = right.m31;
915 result.m32 = right.m32;
916 result.m33 = right.m33;
917
918 return result;
919 }
920 public static void Multiply(ref Matrix2x2 left, ref Matrix4x4 right, out Matrix4x4 result)
921 {
922 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10;
923 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11;
924 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12;
925 Scalar m03 = left.m00 * right.m03 + left.m01 * right.m13;
926
927 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10;
928 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11;
929 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12;
930 Scalar m13 = left.m10 * right.m03 + left.m11 * right.m13;
931
932 result.m00 = m00;
933 result.m01 = m01;
934 result.m02 = m02;
935 result.m03 = m03;
936
937 result.m10 = m10;
938 result.m11 = m11;
939 result.m12 = m12;
940 result.m13 = m13;
941
942 result.m20 = right.m20;
943 result.m21 = right.m21;
944 result.m22 = right.m22;
945 result.m23 = right.m23;
946
947 result.m30 = right.m30;
948 result.m31 = right.m31;
949 result.m32 = right.m32;
950 result.m33 = right.m33;
951 }
952
953
954 public static Matrix4x4 Add(Matrix4x4 left, Matrix4x4 right)
955 {
956 Matrix4x4 result;
957
958 result.m00 = left.m00 + right.m00;
959 result.m01 = left.m01 + right.m01;
960 result.m02 = left.m02 + right.m02;
961 result.m03 = left.m03 + right.m03;
962
963 result.m10 = left.m10 + right.m10;
964 result.m11 = left.m11 + right.m11;
965 result.m12 = left.m12 + right.m12;
966 result.m13 = left.m13 + right.m13;
967
968 result.m20 = left.m20 + right.m20;
969 result.m21 = left.m21 + right.m21;
970 result.m22 = left.m22 + right.m22;
971 result.m23 = left.m23 + right.m23;
972
973 result.m30 = left.m30 + right.m30;
974 result.m31 = left.m31 + right.m31;
975 result.m32 = left.m32 + right.m32;
976 result.m33 = left.m33 + right.m33;
977
978 return result;
979 }
980 public static void Add(ref Matrix4x4 left, ref Matrix4x4 right, out Matrix4x4 result)
981 {
982 result.m00 = left.m00 + right.m00;
983 result.m01 = left.m01 + right.m01;
984 result.m02 = left.m02 + right.m02;
985 result.m03 = left.m03 + right.m03;
986
987 result.m10 = left.m10 + right.m10;
988 result.m11 = left.m11 + right.m11;
989 result.m12 = left.m12 + right.m12;
990 result.m13 = left.m13 + right.m13;
991
992 result.m20 = left.m20 + right.m20;
993 result.m21 = left.m21 + right.m21;
994 result.m22 = left.m22 + right.m22;
995 result.m23 = left.m23 + right.m23;
996
997 result.m30 = left.m30 + right.m30;
998 result.m31 = left.m31 + right.m31;
999 result.m32 = left.m32 + right.m32;
1000 result.m33 = left.m33 + right.m33;
1001 }
1002
1003 public static Matrix4x4 Add(Matrix3x3 left, Matrix4x4 right)
1004 {
1005 Matrix4x4 result;
1006 Add(ref left, ref right, out result);
1007 return result;
1008 }
1009 public static void Add(ref Matrix3x3 left, ref Matrix4x4 right, out Matrix4x4 result)
1010 {
1011 result.m00 = left.m00 + right.m00;
1012 result.m01 = left.m01 + right.m01;
1013 result.m02 = left.m02 + right.m02;
1014 result.m03 = right.m03;
1015
1016 result.m10 = left.m10 + right.m10;
1017 result.m11 = left.m11 + right.m11;
1018 result.m12 = left.m12 + right.m12;
1019 result.m13 = right.m13;
1020
1021 result.m20 = left.m20 + right.m20;
1022 result.m21 = left.m21 + right.m21;
1023 result.m22 = left.m22 + right.m22;
1024 result.m23 = right.m23;
1025
1026 result.m30 = right.m30;
1027 result.m31 = right.m31;
1028 result.m32 = right.m32;
1029 result.m33 = 1 + right.m33;
1030 }
1031 public static Matrix4x4 Add(Matrix4x4 left, Matrix3x3 right)
1032 {
1033 Matrix4x4 result;
1034 Add(ref left, ref right, out result);
1035 return result;
1036 }
1037 public static void Add(ref Matrix4x4 left, ref Matrix3x3 right, out Matrix4x4 result)
1038 {
1039 result.m00 = left.m00 + right.m00;
1040 result.m01 = left.m01 + right.m01;
1041 result.m02 = left.m02 + right.m02;
1042 result.m03 = left.m03;
1043
1044 result.m10 = left.m10 + right.m10;
1045 result.m11 = left.m11 + right.m11;
1046 result.m12 = left.m12 + right.m12;
1047 result.m13 = left.m13;
1048
1049 result.m20 = left.m20 + right.m20;
1050 result.m21 = left.m21 + right.m21;
1051 result.m22 = left.m22 + right.m22;
1052 result.m23 = left.m23;
1053
1054 result.m30 = left.m30;
1055 result.m31 = left.m31;
1056 result.m32 = left.m32;
1057 result.m33 = left.m33 + 1;
1058 }
1059
1060 public static Matrix4x4 Add(Matrix2x3 left, Matrix4x4 right)
1061 {
1062 Matrix4x4 result;
1063 Add(ref left, ref right, out result);
1064 return result;
1065 }
1066 public static void Add(ref Matrix2x3 left, ref Matrix4x4 right, out Matrix4x4 result)
1067 {
1068 result.m00 = left.m00 + right.m00;
1069 result.m01 = left.m01 + right.m01;
1070 result.m02 = left.m02 + right.m02;
1071 result.m03 = right.m03;
1072
1073 result.m10 = left.m10 + right.m10;
1074 result.m11 = left.m11 + right.m11;
1075 result.m12 = left.m12 + right.m12;
1076 result.m13 = right.m13;
1077
1078 result.m20 = right.m20;
1079 result.m21 = right.m21;
1080 result.m22 = 1 + right.m22;
1081 result.m23 = right.m23;
1082
1083 result.m30 = right.m30;
1084 result.m31 = right.m31;
1085 result.m32 = right.m32;
1086 result.m33 = 1 + right.m33;
1087 }
1088 public static Matrix4x4 Add(Matrix4x4 left, Matrix2x3 right)
1089 {
1090 Matrix4x4 result;
1091 Add(ref left, ref right, out result);
1092 return result;
1093 }
1094 public static void Add(ref Matrix4x4 left, ref Matrix2x3 right, out Matrix4x4 result)
1095 {
1096 result.m00 = left.m00 + right.m00;
1097 result.m01 = left.m01 + right.m01;
1098 result.m02 = left.m02 + right.m02;
1099 result.m03 = left.m03;
1100
1101 result.m10 = left.m10 + right.m10;
1102 result.m11 = left.m11 + right.m11;
1103 result.m12 = left.m12 + right.m12;
1104 result.m13 = left.m13;
1105
1106 result.m20 = left.m20;
1107 result.m21 = left.m21;
1108 result.m22 = left.m22 + 1;
1109 result.m23 = left.m23;
1110
1111 result.m30 = left.m30;
1112 result.m31 = left.m31;
1113 result.m32 = left.m32;
1114 result.m33 = left.m33 + 1;
1115 }
1116
1117 public static Matrix4x4 Add(Matrix2x2 left, Matrix4x4 right)
1118 {
1119 Matrix4x4 result;
1120 Add(ref left, ref right, out result);
1121 return result;
1122 }
1123 public static void Add(ref Matrix2x2 left, ref Matrix4x4 right, out Matrix4x4 result)
1124 {
1125 result.m00 = left.m00 + right.m00;
1126 result.m01 = left.m01 + right.m01;
1127 result.m02 = right.m02;
1128 result.m03 = right.m03;
1129
1130 result.m10 = left.m10 + right.m10;
1131 result.m11 = left.m11 + right.m11;
1132 result.m12 = right.m12;
1133 result.m13 = right.m13;
1134
1135 result.m20 = right.m20;
1136 result.m21 = right.m21;
1137 result.m22 = 1 + right.m22;
1138 result.m23 = right.m23;
1139
1140 result.m30 = right.m30;
1141 result.m31 = right.m31;
1142 result.m32 = right.m32;
1143 result.m33 = 1 + right.m33;
1144 }
1145 public static Matrix4x4 Add(Matrix4x4 left, Matrix2x2 right)
1146 {
1147 Matrix4x4 result;
1148 Add(ref left, ref right, out result);
1149 return result;
1150 }
1151 public static void Add(ref Matrix4x4 left, ref Matrix2x2 right, out Matrix4x4 result)
1152 {
1153 result.m00 = left.m00 + right.m00;
1154 result.m01 = left.m01 + right.m01;
1155 result.m02 = left.m02;
1156 result.m03 = left.m03;
1157
1158 result.m10 = left.m10 + right.m10;
1159 result.m11 = left.m11 + right.m11;
1160 result.m12 = left.m12;
1161 result.m13 = left.m13;
1162
1163 result.m20 = left.m20;
1164 result.m21 = left.m21;
1165 result.m22 = left.m22 + 1;
1166 result.m23 = left.m23;
1167
1168 result.m30 = left.m30;
1169 result.m31 = left.m31;
1170 result.m32 = left.m32;
1171 result.m33 = left.m33 + 1;
1172 }
1173
1174
1175 public static Matrix4x4 Subtract(Matrix4x4 left, Matrix4x4 right)
1176 {
1177 Matrix4x4 result;
1178
1179 result.m00 = left.m00 - right.m00;
1180 result.m01 = left.m01 - right.m01;
1181 result.m02 = left.m02 - right.m02;
1182 result.m03 = left.m03 - right.m03;
1183
1184 result.m10 = left.m10 - right.m10;
1185 result.m11 = left.m11 - right.m11;
1186 result.m12 = left.m12 - right.m12;
1187 result.m13 = left.m13 - right.m13;
1188
1189 result.m20 = left.m20 - right.m20;
1190 result.m21 = left.m21 - right.m21;
1191 result.m22 = left.m22 - right.m22;
1192 result.m23 = left.m23 - right.m23;
1193
1194 result.m30 = left.m30 - right.m30;
1195 result.m31 = left.m31 - right.m31;
1196 result.m32 = left.m32 - right.m32;
1197 result.m33 = left.m33 - right.m33;
1198
1199 return result;
1200 }
1201 public static void Subtract(ref Matrix4x4 left, ref Matrix4x4 right, out Matrix4x4 result)
1202 {
1203 result.m00 = left.m00 - right.m00;
1204 result.m01 = left.m01 - right.m01;
1205 result.m02 = left.m02 - right.m02;
1206 result.m03 = left.m03 - right.m03;
1207
1208 result.m10 = left.m10 - right.m10;
1209 result.m11 = left.m11 - right.m11;
1210 result.m12 = left.m12 - right.m12;
1211 result.m13 = left.m13 - right.m13;
1212
1213 result.m20 = left.m20 - right.m20;
1214 result.m21 = left.m21 - right.m21;
1215 result.m22 = left.m22 - right.m22;
1216 result.m23 = left.m23 - right.m23;
1217
1218 result.m30 = left.m30 - right.m30;
1219 result.m31 = left.m31 - right.m31;
1220 result.m32 = left.m32 - right.m32;
1221 result.m33 = left.m33 - right.m33;
1222 }
1223
1224 public static Matrix4x4 Subtract(Matrix3x3 left, Matrix4x4 right)
1225 {
1226 Matrix4x4 result;
1227 Subtract(ref left, ref right, out result);
1228 return result;
1229 }
1230 public static void Subtract(ref Matrix3x3 left, ref Matrix4x4 right, out Matrix4x4 result)
1231 {
1232 result.m00 = left.m00 - right.m00;
1233 result.m01 = left.m01 - right.m01;
1234 result.m02 = left.m02 - right.m02;
1235 result.m03 = -right.m03;
1236
1237 result.m10 = left.m10 - right.m10;
1238 result.m11 = left.m11 - right.m11;
1239 result.m12 = left.m12 - right.m12;
1240 result.m13 = -right.m13;
1241
1242 result.m20 = left.m20 - right.m20;
1243 result.m21 = left.m21 - right.m21;
1244 result.m22 = left.m22 - right.m22;
1245 result.m23 = -right.m23;
1246
1247 result.m30 = -right.m30;
1248 result.m31 = -right.m31;
1249 result.m32 = -right.m32;
1250 result.m33 = 1 - right.m33;
1251 }
1252 public static Matrix4x4 Subtract(Matrix4x4 left, Matrix3x3 right)
1253 {
1254 Matrix4x4 result;
1255 Subtract(ref left, ref right, out result);
1256 return result;
1257 }
1258 public static void Subtract(ref Matrix4x4 left, ref Matrix3x3 right, out Matrix4x4 result)
1259 {
1260 result.m00 = left.m00 - right.m00;
1261 result.m01 = left.m01 - right.m01;
1262 result.m02 = left.m02 - right.m02;
1263 result.m03 = left.m03;
1264
1265 result.m10 = left.m10 - right.m10;
1266 result.m11 = left.m11 - right.m11;
1267 result.m12 = left.m12 - right.m12;
1268 result.m13 = left.m13;
1269
1270 result.m20 = left.m20 - right.m20;
1271 result.m21 = left.m21 - right.m21;
1272 result.m22 = left.m22 - right.m22;
1273 result.m23 = left.m23;
1274
1275 result.m30 = left.m30;
1276 result.m31 = left.m31;
1277 result.m32 = left.m32;
1278 result.m33 = left.m33 - 1;
1279 }
1280
1281 public static Matrix4x4 Subtract(Matrix2x3 left, Matrix4x4 right)
1282 {
1283 Matrix4x4 result;
1284 Subtract(ref left, ref right, out result);
1285 return result;
1286 }
1287 public static void Subtract(ref Matrix2x3 left, ref Matrix4x4 right, out Matrix4x4 result)
1288 {
1289 result.m00 = left.m00 - right.m00;
1290 result.m01 = left.m01 - right.m01;
1291 result.m02 = left.m02 - right.m02;
1292 result.m03 = -right.m03;
1293
1294 result.m10 = left.m10 - right.m10;
1295 result.m11 = left.m11 - right.m11;
1296 result.m12 = left.m12 - right.m12;
1297 result.m13 = -right.m13;
1298
1299 result.m20 = -right.m20;
1300 result.m21 = -right.m21;
1301 result.m22 = 1 - right.m22;
1302 result.m23 = -right.m23;
1303
1304 result.m30 = -right.m30;
1305 result.m31 = -right.m31;
1306 result.m32 = -right.m32;
1307 result.m33 = 1 - right.m33;
1308 }
1309 public static Matrix4x4 Subtract(Matrix4x4 left, Matrix2x3 right)
1310 {
1311 Matrix4x4 result;
1312 Subtract(ref left, ref right, out result);
1313 return result;
1314 }
1315 public static void Subtract(ref Matrix4x4 left, ref Matrix2x3 right, out Matrix4x4 result)
1316 {
1317 result.m00 = left.m00 - right.m00;
1318 result.m01 = left.m01 - right.m01;
1319 result.m02 = left.m02 - right.m02;
1320 result.m03 = left.m03;
1321
1322 result.m10 = left.m10 - right.m10;
1323 result.m11 = left.m11 - right.m11;
1324 result.m12 = left.m12 - right.m12;
1325 result.m13 = left.m13;
1326
1327 result.m20 = left.m20;
1328 result.m21 = left.m21;
1329 result.m22 = left.m22 - 1;
1330 result.m23 = left.m23;
1331
1332 result.m30 = left.m30;
1333 result.m31 = left.m31;
1334 result.m32 = left.m32;
1335 result.m33 = left.m33 - 1;
1336 }
1337
1338 public static Matrix4x4 Subtract(Matrix2x2 left, Matrix4x4 right)
1339 {
1340 Matrix4x4 result;
1341 Subtract(ref left, ref right, out result);
1342 return result;
1343 }
1344 public static void Subtract(ref Matrix2x2 left, ref Matrix4x4 right, out Matrix4x4 result)
1345 {
1346 result.m00 = left.m00 - right.m00;
1347 result.m01 = left.m01 - right.m01;
1348 result.m02 = -right.m02;
1349 result.m03 = -right.m03;
1350
1351 result.m10 = left.m10 - right.m10;
1352 result.m11 = left.m11 - right.m11;
1353 result.m12 = -right.m12;
1354 result.m13 = -right.m13;
1355
1356 result.m20 = -right.m20;
1357 result.m21 = -right.m21;
1358 result.m22 = 1 - right.m22;
1359 result.m23 = -right.m23;
1360
1361 result.m30 = -right.m30;
1362 result.m31 = -right.m31;
1363 result.m32 = -right.m32;
1364 result.m33 = 1 - right.m33;
1365 }
1366 public static Matrix4x4 Subtract(Matrix4x4 left, Matrix2x2 right)
1367 {
1368 Matrix4x4 result;
1369 Subtract(ref left, ref right, out result);
1370 return result;
1371 }
1372 public static void Subtract(ref Matrix4x4 left, ref Matrix2x2 right, out Matrix4x4 result)
1373 {
1374 result.m00 = left.m00 - right.m00;
1375 result.m01 = left.m01 - right.m01;
1376 result.m02 = left.m02;
1377 result.m03 = left.m03;
1378
1379 result.m10 = left.m10 - right.m10;
1380 result.m11 = left.m11 - right.m11;
1381 result.m12 = left.m12;
1382 result.m13 = left.m13;
1383
1384 result.m20 = left.m20;
1385 result.m21 = left.m21;
1386 result.m22 = left.m22 - 1;
1387 result.m23 = left.m23;
1388
1389 result.m30 = left.m30;
1390 result.m31 = left.m31;
1391 result.m32 = left.m32;
1392 result.m33 = left.m33 - 1;
1393 }
1394
1395 public static Matrix4x4 Negate(Matrix4x4 source)
1396 {
1397 Matrix4x4 result;
1398
1399 result.m00 = -source.m00;
1400 result.m01 = -source.m01;
1401 result.m02 = -source.m02;
1402 result.m03 = -source.m03;
1403
1404 result.m10 = -source.m10;
1405 result.m11 = -source.m11;
1406 result.m12 = -source.m12;
1407 result.m13 = -source.m13;
1408
1409 result.m20 = -source.m20;
1410 result.m21 = -source.m21;
1411 result.m22 = -source.m22;
1412 result.m23 = -source.m23;
1413
1414 result.m30 = -source.m30;
1415 result.m31 = -source.m31;
1416 result.m32 = -source.m32;
1417 result.m33 = -source.m33;
1418
1419 return result;
1420 }
1421 public static void Negate(ref Matrix4x4 source)
1422 {
1423 Negate(ref source, out source);
1424 }
1425 public static void Negate(ref Matrix4x4 source, out Matrix4x4 result)
1426 {
1427 result.m00 = -source.m00;
1428 result.m01 = -source.m01;
1429 result.m02 = -source.m02;
1430 result.m03 = -source.m03;
1431
1432 result.m10 = -source.m10;
1433 result.m11 = -source.m11;
1434 result.m12 = -source.m12;
1435 result.m13 = -source.m13;
1436
1437 result.m20 = -source.m20;
1438 result.m21 = -source.m21;
1439 result.m22 = -source.m22;
1440 result.m23 = -source.m23;
1441
1442 result.m30 = -source.m30;
1443 result.m31 = -source.m31;
1444 result.m32 = -source.m32;
1445 result.m33 = -source.m33;
1446 }
1447
1448 public static Matrix4x4 Invert(Matrix4x4 source)
1449 {
1450 Matrix4x4 result;
1451 Invert(ref source, out result);
1452 return result;
1453 }
1454 public static void Invert(ref Matrix4x4 source, out Matrix4x4 result)
1455 {
1456 Scalar m00 = source.m00;
1457 Scalar m01 = source.m01;
1458 Scalar m02 = source.m02;
1459 Scalar m03 = source.m03;
1460
1461 Scalar m10 = source.m10;
1462 Scalar m11 = source.m11;
1463 Scalar m12 = source.m12;
1464 Scalar m13 = source.m13;
1465
1466 Scalar m22m33m32m23 = (source.m22 * source.m33 - source.m32 * source.m23);
1467 Scalar m21m33m31m23 = (source.m21 * source.m33 - source.m31 * source.m23);
1468 Scalar m21m32m31m22 = (source.m21 * source.m32 - source.m31 * source.m22);
1469
1470 Scalar m12m33m32m13 = (m12 * source.m33 - source.m32 * m13);
1471 Scalar m11m33m31m13 = (m11 * source.m33 - source.m31 * m13);
1472 Scalar m11m32m31m12 = (m11 * source.m32 - source.m31 * m12);
1473
1474 Scalar m12m23m22m13 = (m12 * source.m23 - source.m22 * m13);
1475 Scalar m11m23m21m13 = (m11 * source.m23 - source.m21 * m13);
1476 Scalar m11m22m21m12 = (m11 * source.m22 - source.m21 * m12);
1477
1478 Scalar m20m33m30m23 = (source.m20 * source.m33 - source.m30 * source.m23);
1479 Scalar m20m32m30m22 = (source.m20 * source.m32 - source.m30 * source.m22);
1480 Scalar m10m33m30m13 = (m10 * source.m33 - source.m30 * m13);
1481
1482 Scalar m10m32m30m12 = (m10 * source.m32 - source.m30 * m12);
1483 Scalar m10m23m20m13 = (m10 * source.m23 - source.m20 * m13);
1484 Scalar m10m22m20m12 = (m10 * source.m22 - source.m20 * m12);
1485
1486 Scalar m20m31m30m21 = (source.m20 * source.m31 - source.m30 * source.m21);
1487 Scalar m10m31m30m11 = (m10 * source.m31 - source.m30 * m11);
1488 Scalar m10m21m20m11 = (m10 * source.m21 - source.m20 * m11);
1489
1490
1491 Scalar detInv = 1 /
1492 (m00 * (m11 * m22m33m32m23 - m12 * m21m33m31m23 + m13 * m21m32m31m22) -
1493 m01 * (m10 * m22m33m32m23 - m12 * m20m33m30m23 + m13 * m20m32m30m22) +
1494 m02 * (m10 * m21m33m31m23 - m11 * m20m33m30m23 + m13 * m20m31m30m21) -
1495 m03 * (m10 * m21m32m31m22 - m11 * m20m32m30m22 + m12 * m20m31m30m21));
1496
1497
1498 result.m00 = detInv * (m11 * m22m33m32m23 - m12 * m21m33m31m23 + m13 * m21m32m31m22);
1499 result.m01 = detInv * (-(m01 * m22m33m32m23 - m02 * m21m33m31m23 + m03 * m21m32m31m22));
1500 result.m02 = detInv * (m01 * m12m33m32m13 - m02 * m11m33m31m13 + m03 * m11m32m31m12);
1501 result.m03 = detInv * (-(m01 * m12m23m22m13 - m02 * m11m23m21m13 + m03 * m11m22m21m12));
1502
1503 result.m10 = detInv * (-(m10 * m22m33m32m23 - m12 * m20m33m30m23 + m13 * m20m32m30m22));
1504 result.m11 = detInv * (m00 * m22m33m32m23 - m02 * m20m33m30m23 + m03 * m20m32m30m22);
1505 result.m12 = detInv * (-(m00 * m12m33m32m13 - m02 * m10m33m30m13 + m03 * m10m32m30m12));
1506 result.m13 = detInv * (m00 * m12m23m22m13 - m02 * m10m23m20m13 + m03 * m10m22m20m12);
1507
1508 result.m20 = detInv * (m10 * m21m33m31m23 - m11 * m20m33m30m23 + m13 * m20m31m30m21);
1509 result.m21 = detInv * (-(m00 * m21m33m31m23 - m01 * m20m33m30m23 + m03 * m20m31m30m21));
1510 result.m22 = detInv * (m00 * m11m33m31m13 - m01 * m10m33m30m13 + m03 * m20m31m30m21);
1511 result.m23 = detInv * (-(m00 * m11m23m21m13 - m01 * m10m23m20m13 + m03 * m10m21m20m11));
1512
1513 result.m30 = detInv * (-(m10 * m21m32m31m22 - m11 * m20m32m30m22 + m12 * m20m31m30m21));
1514 result.m31 = detInv * (m00 * m21m32m31m22 - m01 * m20m32m30m22 + m02 * m20m31m30m21);
1515 result.m32 = detInv * (-(m00 * m11m32m31m12 - m01 * m10m32m30m12 + m02 * m10m31m30m11));
1516 result.m33 = detInv * (m00 * m11m22m21m12 - m01 * m10m22m20m12 + m02 * m10m21m20m11);
1517
1518 }
1519
1520 public static Scalar GetDeterminant(Matrix4x4 source)
1521 {
1522 Scalar result;
1523 GetDeterminant(ref source, out result);
1524 return result;
1525 }
1526 public static void GetDeterminant(ref Matrix4x4 source, out Scalar result)
1527 {
1528 Scalar m22m33m32m23 = (source.m22 * source.m33 - source.m32 * source.m23);
1529 Scalar m21m33m31m23 = (source.m21 * source.m33 - source.m31 * source.m23);
1530 Scalar m21m32m31m22 = (source.m21 * source.m32 - source.m31 * source.m22);
1531
1532 Scalar m20m33m30m23 = (source.m20 * source.m33 - source.m30 * source.m23);
1533 Scalar m20m32m30m22 = (source.m20 * source.m32 - source.m30 * source.m22);
1534 Scalar m20m31m30m21 = (source.m20 * source.m31 - source.m30 * source.m21);
1535
1536 result =
1537 source.m00 * (source.m11 * m22m33m32m23 - source.m12 * m21m33m31m23 + source.m13 * m21m32m31m22) -
1538 source.m01 * (source.m10 * m22m33m32m23 - source.m12 * m20m33m30m23 + source.m13 * m20m32m30m22) +
1539 source.m02 * (source.m10 * m21m33m31m23 - source.m11 * m20m33m30m23 + source.m13 * m20m31m30m21) -
1540 source.m03 * (source.m10 * m21m32m31m22 - source.m11 * m20m32m30m22 + source.m12 * m20m31m30m21);
1541 }
1542
1543 public static Matrix4x4 Transpose(Matrix4x4 source)
1544 {
1545 Matrix4x4 result;
1546 Transpose(ref source, out result);
1547 return result;
1548 }
1549 public static void Transpose(ref Matrix4x4 source, out Matrix4x4 result)
1550 {
1551 Scalar m01 = source.m01;
1552 Scalar m02 = source.m02;
1553 Scalar m03 = source.m03;
1554
1555 Scalar m12 = source.m12;
1556 Scalar m13 = source.m13;
1557 Scalar m23 = source.m23;
1558
1559 result.m00 = source.m00;
1560 result.m01 = source.m10;
1561 result.m02 = source.m20;
1562 result.m03 = source.m30;
1563
1564 result.m10 = m01;
1565 result.m11 = source.m11;
1566 result.m12 = source.m21;
1567 result.m13 = source.m31;
1568
1569 result.m20 = m02;
1570 result.m21 = m12;
1571 result.m22 = source.m22;
1572 result.m23 = source.m32;
1573
1574 result.m30 = m03;
1575 result.m31 = m13;
1576 result.m32 = m23;
1577 result.m33 = source.m33;
1578
1579 }
1580
1581 public static Matrix4x4 GetAdjoint(Matrix4x4 source)
1582 {
1583 Matrix4x4 result;
1584 GetAdjoint(ref source, out result);
1585 return result;
1586 }
1587 public static void GetAdjoint(ref Matrix4x4 source, out Matrix4x4 result)
1588 {
1589 Scalar m00 = source.m00;
1590 Scalar m01 = source.m01;
1591 Scalar m02 = source.m02;
1592 Scalar m03 = source.m03;
1593
1594 Scalar m10 = source.m10;
1595 Scalar m11 = source.m11;
1596 Scalar m12 = source.m12;
1597 Scalar m13 = source.m13;
1598
1599 //even further expanded to give even better performance. Generated using a keyboard and mouse
1600 Scalar m22m33m32m23 = (source.m22 * source.m33 - source.m32 * source.m23);
1601 Scalar m21m33m31m23 = (source.m21 * source.m33 - source.m31 * source.m23);
1602 Scalar m21m32m31m22 = (source.m21 * source.m32 - source.m31 * source.m22);
1603
1604 Scalar m12m33m32m13 = (m12 * source.m33 - source.m32 * m13);
1605 Scalar m11m33m31m13 = (m11 * source.m33 - source.m31 * m13);
1606 Scalar m11m32m31m12 = (m11 * source.m32 - source.m31 * m12);
1607
1608 Scalar m12m23m22m13 = (m12 * source.m23 - source.m22 * m13);
1609 Scalar m11m23m21m13 = (m11 * source.m23 - source.m21 * m13);
1610 Scalar m11m22m21m12 = (m11 * source.m22 - source.m21 * m12);
1611
1612 Scalar m20m33m30m23 = (source.m20 * source.m33 - source.m30 * source.m23);
1613 Scalar m20m32m30m22 = (source.m20 * source.m32 - source.m30 * source.m22);
1614 Scalar m10m33m30m13 = (m10 * source.m33 - source.m30 * m13);
1615
1616 Scalar m10m32m30m12 = (m10 * source.m32 - source.m30 * m12);
1617 Scalar m10m23m20m13 = (m10 * source.m23 - source.m20 * m13);
1618 Scalar m10m22m20m12 = (m10 * source.m22 - source.m20 * m12);
1619
1620 Scalar m20m31m30m21 = (source.m20 * source.m31 - source.m30 * source.m21);
1621 Scalar m10m31m30m11 = (m10 * source.m31 - source.m30 * m11);
1622 Scalar m10m21m20m11 = (m10 * source.m21 - source.m20 * m11);
1623
1624
1625
1626
1627 // note: this is an expanded version of the Ogre adjoint() method, to give better performance in C#. Generated using a script
1628
1629 result.m00 = (m11 * m22m33m32m23 - m12 * m21m33m31m23 + m13 * m21m32m31m22);
1630 result.m01 = (-(m01 * m22m33m32m23 - m02 * m21m33m31m23 + m03 * m21m32m31m22));
1631 result.m02 = (m01 * m12m33m32m13 - m02 * m11m33m31m13 + m03 * m11m32m31m12);
1632 result.m03 = (-(m01 * m12m23m22m13 - m02 * m11m23m21m13 + m03 * m11m22m21m12));
1633
1634 result.m10 = (-(m10 * m22m33m32m23 - m12 * m20m33m30m23 + m13 * m20m32m30m22));
1635 result.m11 = (m00 * m22m33m32m23 - m02 * m20m33m30m23 + m03 * m20m32m30m22);
1636 result.m12 = (-(m00 * m12m33m32m13 - m02 * m10m33m30m13 + m03 * m10m32m30m12));
1637 result.m13 = (m00 * m12m23m22m13 - m02 * m10m23m20m13 + m03 * m10m22m20m12);
1638
1639 result.m20 = (m10 * m21m33m31m23 - m11 * m20m33m30m23 + m13 * m20m31m30m21);
1640 result.m21 = (-(m00 * m21m33m31m23 - m01 * m20m33m30m23 + m03 * m20m31m30m21));
1641 result.m22 = (m00 * m11m33m31m13 - m01 * m10m33m30m13 + m03 * m20m31m30m21);
1642 result.m23 = (-(m00 * m11m23m21m13 - m01 * m10m23m20m13 + m03 * m10m21m20m11));
1643
1644 result.m30 = (-(m10 * m21m32m31m22 - m11 * m20m32m30m22 + m12 * m20m31m30m21));
1645 result.m31 = (m00 * m21m32m31m22 - m01 * m20m32m30m22 + m02 * m20m31m30m21);
1646 result.m32 = (-(m00 * m11m32m31m12 - m01 * m10m32m30m12 + m02 * m10m31m30m11));
1647 result.m33 = (m00 * m11m22m21m12 - m01 * m10m22m20m12 + m02 * m10m21m20m11);
1648
1649 }
1650
1651 public static Matrix4x4 GetCofactor(Matrix4x4 source)
1652 {
1653 Matrix4x4 result;
1654 GetCofactor(ref source, out result);
1655 return result;
1656 }
1657 public static void GetCofactor(ref Matrix4x4 source, out Matrix4x4 result)
1658 {
1659 Scalar m00 = source.m00;
1660 Scalar m01 = source.m01;
1661 Scalar m02 = source.m02;
1662 Scalar m03 = source.m03;
1663
1664 Scalar m10 = source.m10;
1665 Scalar m11 = source.m11;
1666 Scalar m12 = source.m12;
1667 Scalar m13 = source.m13;
1668
1669 //even further expanded to give even better performance. Generated using a keyboard and mouse
1670 Scalar m22m33m32m23 = (source.m22 * source.m33 - source.m32 * source.m23);
1671 Scalar m21m33m31m23 = (source.m21 * source.m33 - source.m31 * source.m23);
1672 Scalar m21m32m31m22 = (source.m21 * source.m32 - source.m31 * source.m22);
1673 Scalar m12m33m32m13 = (m12 * source.m33 - source.m32 * m13);
1674
1675 Scalar m11m33m31m13 = (m11 * source.m33 - source.m31 * m13);
1676 Scalar m11m32m31m12 = (m11 * source.m32 - source.m31 * m12);
1677 Scalar m12m23m22m13 = (m12 * source.m23 - source.m22 * m13);
1678 Scalar m11m23m21m13 = (m11 * source.m23 - source.m21 * m13);
1679
1680 Scalar m11m22m21m12 = (m11 * source.m22 - source.m21 * m12);
1681 Scalar m20m33m30m23 = (source.m20 * source.m33 - source.m30 * source.m23);
1682 Scalar m20m32m30m22 = (source.m20 * source.m32 - source.m30 * source.m22);
1683 Scalar m10m33m30m13 = (m10 * source.m33 - source.m30 * m13);
1684
1685 Scalar m10m32m30m12 = (m10 * source.m32 - source.m30 * m12);
1686 Scalar m10m23m20m13 = (m10 * source.m23 - source.m20 * m13);
1687 Scalar m10m22m20m12 = (m10 * source.m22 - source.m20 * m12);
1688 Scalar m20m31m30m21 = (source.m20 * source.m31 - source.m30 * source.m21);
1689
1690 Scalar m10m31m30m11 = (m10 * source.m31 - source.m30 * m11);
1691 Scalar m10m21m20m11 = (m10 * source.m21 - source.m20 * m11);
1692
1693
1694
1695
1696
1697 result.m00 = (-(m11 * m22m33m32m23 - m12 * m21m33m31m23 + m13 * m21m32m31m22));
1698 result.m01 = ((m01 * m22m33m32m23 - m02 * m21m33m31m23 + m03 * m21m32m31m22));
1699 result.m02 = (-(m01 * m12m33m32m13 - m02 * m11m33m31m13 + m03 * m11m32m31m12));
1700 result.m03 = ((m01 * m12m23m22m13 - m02 * m11m23m21m13 + m03 * m11m22m21m12));
1701
1702 result.m10 = ((m10 * m22m33m32m23 - m12 * m20m33m30m23 + m13 * m20m32m30m22));
1703 result.m11 = (-(m00 * m22m33m32m23 - m02 * m20m33m30m23 + m03 * m20m32m30m22));
1704 result.m12 = ((m00 * m12m33m32m13 - m02 * m10m33m30m13 + m03 * m10m32m30m12));
1705 result.m13 = (-(m00 * m12m23m22m13 - m02 * m10m23m20m13 + m03 * m10m22m20m12));
1706
1707 result.m20 = (-(m10 * m21m33m31m23 - m11 * m20m33m30m23 + m13 * m20m31m30m21));
1708 result.m21 = ((m00 * m21m33m31m23 - m01 * m20m33m30m23 + m03 * m20m31m30m21));
1709 result.m22 = (-(m00 * m11m33m31m13 - m01 * m10m33m30m13 + m03 * m20m31m30m21));
1710 result.m23 = ((m00 * m11m23m21m13 - m01 * m10m23m20m13 + m03 * m10m21m20m11));
1711
1712 result.m30 = ((m10 * m21m32m31m22 - m11 * m20m32m30m22 + m12 * m20m31m30m21));
1713 result.m31 = (-(m00 * m21m32m31m22 - m01 * m20m32m30m22 + m02 * m20m31m30m21));
1714 result.m32 = ((m00 * m11m32m31m12 - m01 * m10m32m30m12 + m02 * m10m31m30m11));
1715 result.m33 = (-(m00 * m11m22m21m12 - m01 * m10m22m20m12 + m02 * m10m21m20m11));
1716
1717 }
1718
1719
1720 [ParseMethod]
1721 public static Matrix4x4 Parse(string s)
1722 {
1723 Matrix4x4 rv = Zero;
1724 ParseHelper.ParseMatrix<Matrix4x4>(s, ref rv);
1725 return rv;
1726 }
1727#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
1728 public static bool TryParse(string s, out Matrix4x4 result)
1729 {
1730 result = Zero;
1731 return ParseHelper.TryParseMatrix<Matrix4x4>(s, ref result);
1732 }
1733#endif
1734
1735 public static bool Equals(Matrix4x4 left, Matrix4x4 right)
1736 {
1737 return
1738 left.m00 == right.m00 && left.m01 == right.m01 && left.m02 == right.m02 && left.m03 == right.m03 &&
1739 left.m10 == right.m10 && left.m11 == right.m11 && left.m12 == right.m12 && left.m13 == right.m13 &&
1740 left.m20 == right.m20 && left.m21 == right.m21 && left.m22 == right.m22 && left.m23 == right.m23 &&
1741 left.m30 == right.m30 && left.m31 == right.m31 && left.m32 == right.m32 && left.m33 == right.m33;
1742 }
1743 public static bool Equals(ref Matrix4x4 left, ref Matrix4x4 right)
1744 {
1745 return
1746 left.m00 == right.m00 && left.m01 == right.m01 && left.m02 == right.m02 && left.m03 == right.m03 &&
1747 left.m10 == right.m10 && left.m11 == right.m11 && left.m12 == right.m12 && left.m13 == right.m13 &&
1748 left.m20 == right.m20 && left.m21 == right.m21 && left.m22 == right.m22 && left.m23 == right.m23 &&
1749 left.m30 == right.m30 && left.m31 == right.m31 && left.m32 == right.m32 && left.m33 == right.m33;
1750 }
1751 #endregion
1752 #region fields
1753
1754 [XmlIgnore]
1755 public Scalar m00, m01, m02, m03;
1756 [XmlIgnore]
1757 public Scalar m10, m11, m12, m13;
1758 [XmlIgnore]
1759 public Scalar m20, m21, m22, m23;
1760 [XmlIgnore]
1761 public Scalar m30, m31, m32, m33;
1762
1763 #endregion
1764 #region Constructors
1765
1771 {
1772 this.m00 = m00; this.m01 = m01; this.m02 = m02; this.m03 = m03;
1773 this.m10 = m10; this.m11 = m11; this.m12 = m12; this.m13 = m13;
1774 this.m20 = m20; this.m21 = m21; this.m22 = m22; this.m23 = m23;
1775 this.m30 = m30; this.m31 = m31; this.m32 = m32; this.m33 = m33;
1776 }
1777 [InstanceConstructor("Rx,Ry,Rz,Rw")]
1778 public Matrix4x4(Vector4D xAxis, Vector4D yAxis, Vector4D zAxis, Vector4D wAxis)
1779 {
1780 m00 = xAxis.X; m01 = xAxis.Y; m02 = xAxis.Z; m03 = xAxis.W;
1781 m10 = yAxis.X; m11 = yAxis.Y; m12 = yAxis.Z; m13 = yAxis.W;
1782 m20 = zAxis.X; m21 = zAxis.Y; m22 = zAxis.Z; m23 = zAxis.W;
1783 m30 = wAxis.X; m31 = wAxis.Y; m32 = wAxis.Z; m33 = wAxis.W;
1784 }
1785 public Matrix4x4(Scalar[] values) : this(values, 0) { }
1786 public Matrix4x4(Scalar[] values, int index) { Copy(values, index, out this); }
1787 #endregion
1788 #region Properties
1789 [AdvBrowsable]
1790#if !WINDOWS_STOREAPP
1791 [System.ComponentModel.Description("The First row of the Matrix4x4")]
1792#endif
1794 {
1795 get
1796 {
1797 Vector4D value;
1798 value.X = m00;
1799 value.Y = m01;
1800 value.Z = m02;
1801 value.W = m03;
1802 return value;
1803 }
1804 set
1805 {
1806 m00 = value.X;
1807 m01 = value.Y;
1808 m02 = value.Z;
1809 m03 = value.W;
1810 }
1811 }
1812 [AdvBrowsable]
1813#if !WINDOWS_STOREAPP
1814 [System.ComponentModel.Description("The Second row of the Matrix4x4")]
1815#endif
1817 {
1818 get
1819 {
1820 Vector4D value;
1821 value.X = m10;
1822 value.Y = m11;
1823 value.Z = m12;
1824 value.W = m13;
1825 return value;
1826 }
1827 set
1828 {
1829 m10 = value.X;
1830 m11 = value.Y;
1831 m12 = value.Z;
1832 m13 = value.W;
1833 }
1834 }
1835 [AdvBrowsable]
1836#if !WINDOWS_STOREAPP
1837 [System.ComponentModel.Description("The Third row of the Matrix4x4")]
1838#endif
1840 {
1841 get
1842 {
1843 Vector4D value;
1844 value.X = m20;
1845 value.Y = m21;
1846 value.Z = m22;
1847 value.W = m23;
1848 return value;
1849 }
1850 set
1851 {
1852 m20 = value.X;
1853 m21 = value.Y;
1854 m22 = value.Z;
1855 m23 = value.W;
1856 }
1857 }
1858 [AdvBrowsable]
1859#if !WINDOWS_STOREAPP
1860 [System.ComponentModel.Description("The Forth row of the Matrix4x4")]
1861#endif
1863 {
1864 get
1865 {
1866 Vector4D value;
1867 value.X = m30;
1868 value.Y = m31;
1869 value.Z = m32;
1870 value.W = m33;
1871 return value;
1872 }
1873 set
1874 {
1875 m30 = value.X;
1876 m31 = value.Y;
1877 m32 = value.Z;
1878 m33 = value.W;
1879 }
1880 }
1881 [XmlIgnore]
1883 {
1884 get
1885 {
1886 Vector4D rv;
1887 rv.X = m00;
1888 rv.Y = m10;
1889 rv.Z = m20;
1890 rv.W = m30;
1891 return rv;
1892 }
1893 set
1894 {
1895 this.m00 = value.X;
1896 this.m10 = value.Y;
1897 this.m20 = value.Z;
1898 this.m30 = value.W;
1899 }
1900 }
1901 [XmlIgnore]
1903 {
1904 get
1905 {
1906 Vector4D rv;
1907 rv.X = m01;
1908 rv.Y = m11;
1909 rv.Z = m21;
1910 rv.W = m31;
1911 return rv;
1912 }
1913 set
1914 {
1915 this.m01 = value.X;
1916 this.m11 = value.Y;
1917 this.m21 = value.Z;
1918 this.m31 = value.W;
1919 }
1920 }
1921 [XmlIgnore]
1923 {
1924 get
1925 {
1926 Vector4D rv;
1927 rv.X = m02;
1928 rv.Y = m12;
1929 rv.Z = m22;
1930 rv.W = m32;
1931 return rv;
1932 }
1933 set
1934 {
1935 this.m02 = value.X;
1936 this.m12 = value.Y;
1937 this.m22 = value.Z;
1938 this.m32 = value.W;
1939 }
1940 }
1941 [XmlIgnore]
1943 {
1944 get
1945 {
1946 Vector4D rv;
1947 rv.X = m03;
1948 rv.Y = m13;
1949 rv.Z = m23;
1950 rv.W = m33;
1951 return rv;
1952 }
1953 set
1954 {
1955 this.m03 = value.X;
1956 this.m13 = value.Y;
1957 this.m23 = value.Z;
1958 this.m33 = value.W;
1959 }
1960 }
1961
1962
1967 {
1968 get
1969 {
1970 Scalar result;
1971 GetDeterminant(ref this, out result);
1972
1973 return result;
1974 }
1975 }
1981 {
1982 get
1983 {
1984 return new Matrix4x4(this.m00, this.m10, this.m20, this.m30,
1985 this.m01, this.m11, this.m21, this.m31,
1986 this.m02, this.m12, this.m22, this.m32,
1987 this.m03, this.m13, this.m23, this.m33);
1988 }
1989 }
1995 {
1996 get
1997 {
1998 Matrix4x4 result;
1999 GetCofactor(ref this, out result);
2000 return result;
2001 }
2002 }
2008 {
2009 get
2010 {
2011 Matrix4x4 result;
2012 GetAdjoint(ref this, out result);
2013 return result;
2014 }
2015 }
2019
2025 {
2026 get
2027 {
2028 Matrix4x4 result;
2029 Invert(ref this, out result);
2030 return result;
2031 }
2032 }
2033
2034
2035 int IAdvanceValueType.Count { get { return Count; } }
2036 int IMatrix.RowCount { get { return RowCount; } }
2037 int IMatrix.ColumnCount { get { return ColumnCount; } }
2038 #endregion
2039 #region Methods
2040
2041 public Vector4D GetColumn(int columnIndex)
2042 {
2043 switch (columnIndex)
2044 {
2045 case 0:
2046 return Cx;
2047 case 1:
2048 return Cy;
2049 case 2:
2050 return Cz;
2051 case 3:
2052 return Cw;
2053 }
2054 throw ThrowHelper.GetThrowIndex("columnIndex", ColumnCount);
2055 }
2056 public void SetColumn(int columnIndex, Vector4D value)
2057 {
2058
2059 switch (columnIndex)
2060 {
2061 case 0:
2062 Cx = value;
2063 return;
2064 case 1:
2065 Cy = value;
2066 return;
2067 case 2:
2068 Cz = value;
2069 return;
2070 case 3:
2071 Cw = value;
2072 return;
2073 }
2074 throw ThrowHelper.GetThrowIndex("columnIndex", ColumnCount);
2075 }
2076 public Vector4D GetRow(int rowIndex)
2077 {
2078 switch (rowIndex)
2079 {
2080 case 0:
2081 return Rx;
2082 case 1:
2083 return Ry;
2084 case 2:
2085 return Rz;
2086 case 3:
2087 return Rw;
2088 }
2089 throw ThrowHelper.GetThrowIndex("rowIndex", RowCount);
2090 }
2091 public void SetRow(int rowIndex, Vector4D value)
2092 {
2093 switch (rowIndex)
2094 {
2095 case 0:
2096 Rx = value;
2097 return;
2098 case 1:
2099 Ry = value;
2100 return;
2101 case 2:
2102 Rz = value;
2103 return;
2104 case 3:
2105 Rw = value;
2106 return;
2107 }
2108 throw ThrowHelper.GetThrowIndex("rowIndex", RowCount);
2109 }
2110
2111
2113 {
2114 return new Scalar[RowCount, ColumnCount]
2115{
2116{ m00, m01, m02, m03 },
2117{ m10, m11, m12, m13 },
2118{ m20, m21, m22, m23 },
2119{ m30, m31, m32, m33 }
2120};
2121 }
2122 public Scalar[] ToArray()
2123 {
2124 return new Scalar[Count] { m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33 };
2125 }
2127 {
2128 return new Scalar[Count] { m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33 };
2129 }
2130
2131
2132
2133
2134 public void CopyTo(Scalar[] array, int index)
2135 {
2136 Copy(ref this, array, index);
2137 }
2138 public void CopyTransposedTo(Scalar[] array, int index)
2139 {
2140 CopyTranspose(ref this, array, index);
2141 }
2142 public void CopyFrom(Scalar[] array, int index)
2143 {
2144 Copy(array, index, out this);
2145 }
2146 public void CopyTransposedFrom(Scalar[] array, int index)
2147 {
2148 CopyTranspose(array, index, out this);
2149 }
2150
2151
2152 private string ToStringInternal(string FormatString)
2153 {
2154 return string.Format(FormatString,
2155 m00, m01, m02, m03,
2156 m10, m11, m12, m13,
2157 m20, m21, m22, m23,
2158 m30, m31, m32, m33);
2159 }
2160 public string ToString(string format)
2161 {
2162 return ToStringInternal(string.Format(FormatableString, format));
2163 }
2164 public override string ToString()
2165 {
2167 }
2168
2169 public override int GetHashCode()
2170 {
2171 return
2172 m00.GetHashCode() ^ m01.GetHashCode() ^ m02.GetHashCode() ^ m03.GetHashCode() ^
2173 m10.GetHashCode() ^ m11.GetHashCode() ^ m12.GetHashCode() ^ m13.GetHashCode() ^
2174 m20.GetHashCode() ^ m21.GetHashCode() ^ m22.GetHashCode() ^ m23.GetHashCode() ^
2175 m30.GetHashCode() ^ m31.GetHashCode() ^ m32.GetHashCode() ^ m33.GetHashCode();
2176 }
2177
2178 public override bool Equals(object obj)
2179 {
2180 return
2181 (obj is Matrix4x4) &&
2182 Equals((Matrix4x4)obj);
2183 }
2184 public bool Equals(Matrix4x4 other)
2185 {
2186 return Equals(ref this, ref other);
2187 }
2188
2189 #endregion
2190 #region indexers
2191#if UNSAFE
2199 public Scalar this[int rowIndex, int columnIndex]
2200 {
2201 get
2202 {
2203 ThrowHelper.CheckIndex("rowIndex", rowIndex, RowCount);
2204 ThrowHelper.CheckIndex("columnIndex", columnIndex, ColumnCount);
2205 unsafe
2206 {
2207 fixed (Scalar* pM = &m00)
2208 {
2209 return pM[(ColumnCount * rowIndex) + columnIndex];
2210 }
2211 }
2212 }
2213 set
2214 {
2215 ThrowHelper.CheckIndex("rowIndex", rowIndex, RowCount);
2216 ThrowHelper.CheckIndex("columnIndex", columnIndex, ColumnCount);
2217 unsafe
2218 {
2219 fixed (Scalar* pM = &m00)
2220 {
2221 pM[(ColumnCount * rowIndex) + columnIndex] = value;
2222 }
2223 }
2224 }
2225 }
2233 public Scalar this[int index]
2234 {
2235 get
2236 {
2237 ThrowHelper.CheckIndex("index", index, Count);
2238 unsafe
2239 {
2240 fixed (Scalar* pMatrix = &this.m00)
2241 {
2242 return pMatrix[index];
2243 }
2244 }
2245 }
2246 set
2247 {
2248 ThrowHelper.CheckIndex("index", index, Count);
2249 unsafe
2250 {
2251 fixed (Scalar* pMatrix = &this.m00)
2252 {
2253 pMatrix[index] = value;
2254 }
2255 }
2256 }
2257 }
2258#endif
2259 #endregion
2260 #region Operators
2261
2262 public static Matrix4x4 operator *(Matrix4x4 left, Matrix4x4 right)
2263 {
2264 Matrix4x4 result;
2265
2266 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20 + left.m03 * right.m30;
2267 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21 + left.m03 * right.m31;
2268 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22 + left.m03 * right.m32;
2269 result.m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23 + left.m03 * right.m33;
2270
2271 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20 + left.m13 * right.m30;
2272 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21 + left.m13 * right.m31;
2273 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22 + left.m13 * right.m32;
2274 result.m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23 + left.m13 * right.m33;
2275
2276 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20 + left.m23 * right.m30;
2277 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21 + left.m23 * right.m31;
2278 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22 + left.m23 * right.m32;
2279 result.m23 = left.m20 * right.m03 + left.m21 * right.m13 + left.m22 * right.m23 + left.m23 * right.m33;
2280
2281 result.m30 = left.m30 * right.m00 + left.m31 * right.m10 + left.m32 * right.m20 + left.m33 * right.m30;
2282 result.m31 = left.m30 * right.m01 + left.m31 * right.m11 + left.m32 * right.m21 + left.m33 * right.m31;
2283 result.m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32 * right.m22 + left.m33 * right.m32;
2284 result.m33 = left.m30 * right.m03 + left.m31 * right.m13 + left.m32 * right.m23 + left.m33 * right.m33;
2285
2286 return result;
2287 }
2288
2289 public static Matrix4x4 operator *(Matrix4x4 left, Scalar scalar)
2290 {
2291 Matrix4x4 result;
2292
2293 result.m00 = left.m00 * scalar;
2294 result.m01 = left.m01 * scalar;
2295 result.m02 = left.m02 * scalar;
2296 result.m03 = left.m03 * scalar;
2297
2298 result.m10 = left.m10 * scalar;
2299 result.m11 = left.m11 * scalar;
2300 result.m12 = left.m12 * scalar;
2301 result.m13 = left.m13 * scalar;
2302
2303 result.m20 = left.m20 * scalar;
2304 result.m21 = left.m21 * scalar;
2305 result.m22 = left.m22 * scalar;
2306 result.m23 = left.m23 * scalar;
2307
2308 result.m30 = left.m30 * scalar;
2309 result.m31 = left.m31 * scalar;
2310 result.m32 = left.m32 * scalar;
2311 result.m33 = left.m33 * scalar;
2312
2313 return result;
2314 }
2315
2316 public static Matrix4x4 operator *(Matrix4x4 left, Matrix3x3 right)
2317 {
2318 Matrix4x4 result;
2319
2320 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
2321 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
2322 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
2323 result.m03 = left.m03;
2324
2325 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
2326 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
2327 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
2328 result.m13 = left.m13;
2329
2330 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
2331 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
2332 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
2333 result.m23 = left.m23;
2334
2335 result.m30 = left.m30 * right.m00 + left.m31 * right.m10 + left.m32 * right.m20;
2336 result.m31 = left.m30 * right.m01 + left.m31 * right.m11 + left.m32 * right.m21;
2337 result.m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32 * right.m22;
2338 result.m33 = left.m33;
2339
2340 return result;
2341 }
2342
2343 public static Matrix4x4 operator *(Matrix3x3 left, Matrix4x4 right)
2344 {
2345 Matrix4x4 result;
2346
2347 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
2348 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
2349 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
2350 result.m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23;
2351
2352 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
2353 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
2354 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
2355 result.m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23;
2356
2357 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
2358 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
2359 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
2360 result.m23 = left.m20 * right.m03 + left.m21 * right.m13 + left.m22 * right.m23;
2361
2362 result.m30 = right.m30;
2363 result.m31 = right.m31;
2364 result.m32 = right.m32;
2365 result.m33 = right.m33;
2366
2367 return result;
2368 }
2369
2370 public static Matrix4x4 operator *(Matrix4x4 left, Matrix2x3 right)
2371 {
2372 Matrix4x4 result;
2373
2374 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
2375 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
2376 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02;
2377 result.m03 = left.m03;
2378
2379 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
2380 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
2381 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12;
2382 result.m13 = left.m13;
2383
2384 result.m20 = left.m20 * right.m00 + left.m21 * right.m10;
2385 result.m21 = left.m20 * right.m01 + left.m21 * right.m11;
2386 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22;
2387 result.m23 = left.m23;
2388
2389 result.m30 = left.m30 * right.m00 + left.m31 * right.m10;
2390 result.m31 = left.m30 * right.m01 + left.m31 * right.m11;
2391 result.m32 = left.m30 * right.m02 + left.m31 * right.m12 + left.m32;
2392 result.m33 = left.m33;
2393
2394 return result;
2395 }
2396
2397 public static Matrix4x4 operator *(Matrix2x3 left, Matrix4x4 right)
2398 {
2399 Matrix4x4 result;
2400
2401 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
2402 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
2403 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
2404 result.m03 = left.m00 * right.m03 + left.m01 * right.m13 + left.m02 * right.m23;
2405
2406 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
2407 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
2408 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
2409 result.m13 = left.m10 * right.m03 + left.m11 * right.m13 + left.m12 * right.m23;
2410
2411 result.m20 = right.m20;
2412 result.m21 = right.m21;
2413 result.m22 = right.m22;
2414 result.m23 = right.m23;
2415
2416 result.m30 = right.m30;
2417 result.m31 = right.m31;
2418 result.m32 = right.m32;
2419 result.m33 = right.m33;
2420
2421 return result;
2422 }
2423
2424 public static Matrix4x4 operator *(Matrix4x4 left, Matrix2x2 right)
2425 {
2426 Matrix4x4 result;
2427
2428 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
2429 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
2430 result.m02 = left.m02;
2431 result.m03 = left.m03;
2432
2433 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
2434 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
2435 result.m12 = left.m12;
2436 result.m13 = left.m13;
2437
2438 result.m20 = left.m20 * right.m00 + left.m21 * right.m10;
2439 result.m21 = left.m20 * right.m01 + left.m21 * right.m11;
2440 result.m22 = left.m22;
2441 result.m23 = left.m23;
2442
2443 result.m30 = left.m30 * right.m00 + left.m31 * right.m10;
2444 result.m31 = left.m30 * right.m01 + left.m31 * right.m11;
2445 result.m32 = left.m32;
2446 result.m33 = left.m33;
2447
2448 return result;
2449 }
2450
2451 public static Matrix4x4 operator *(Matrix2x2 left, Matrix4x4 right)
2452 {
2453 Matrix4x4 result;
2454
2455 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
2456 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
2457 result.m02 = left.m00 * right.m02 + left.m01 * right.m12;
2458 result.m03 = left.m00 * right.m03 + left.m01 * right.m13;
2459
2460 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
2461 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
2462 result.m12 = left.m10 * right.m02 + left.m11 * right.m12;
2463 result.m13 = left.m10 * right.m03 + left.m11 * right.m13;
2464
2465 result.m20 = right.m20;
2466 result.m21 = right.m21;
2467 result.m22 = right.m22;
2468 result.m23 = right.m23;
2469
2470 result.m30 = right.m30;
2471 result.m31 = right.m31;
2472 result.m32 = right.m32;
2473 result.m33 = right.m33;
2474
2475 return result;
2476 }
2477
2478 public static Matrix4x4 operator +(Matrix4x4 left, Matrix4x4 right)
2479 {
2480 Matrix4x4 result;
2481
2482 result.m00 = left.m00 + right.m00;
2483 result.m01 = left.m01 + right.m01;
2484 result.m02 = left.m02 + right.m02;
2485 result.m03 = left.m03 + right.m03;
2486
2487 result.m10 = left.m10 + right.m10;
2488 result.m11 = left.m11 + right.m11;
2489 result.m12 = left.m12 + right.m12;
2490 result.m13 = left.m13 + right.m13;
2491
2492 result.m20 = left.m20 + right.m20;
2493 result.m21 = left.m21 + right.m21;
2494 result.m22 = left.m22 + right.m22;
2495 result.m23 = left.m23 + right.m23;
2496
2497 result.m30 = left.m30 + right.m30;
2498 result.m31 = left.m31 + right.m31;
2499 result.m32 = left.m32 + right.m32;
2500 result.m33 = left.m33 + right.m33;
2501
2502 return result;
2503 }
2504 public static Matrix4x4 operator +(Matrix3x3 left, Matrix4x4 right)
2505 {
2506 Matrix4x4 result;
2507 Add(ref left, ref right, out result);
2508 return result;
2509 }
2510 public static Matrix4x4 operator +(Matrix4x4 left, Matrix3x3 right)
2511 {
2512 Matrix4x4 result;
2513 Add(ref left, ref right, out result);
2514 return result;
2515 }
2516 public static Matrix4x4 operator +(Matrix2x3 left, Matrix4x4 right)
2517 {
2518 Matrix4x4 result;
2519 Add(ref left, ref right, out result);
2520 return result;
2521 }
2522 public static Matrix4x4 operator +(Matrix4x4 left, Matrix2x3 right)
2523 {
2524 Matrix4x4 result;
2525 Add(ref left, ref right, out result);
2526 return result;
2527 }
2528 public static Matrix4x4 operator +(Matrix2x2 left, Matrix4x4 right)
2529 {
2530 Matrix4x4 result;
2531 Add(ref left, ref right, out result);
2532 return result;
2533 }
2534 public static Matrix4x4 operator +(Matrix4x4 left, Matrix2x2 right)
2535 {
2536 Matrix4x4 result;
2537 Add(ref left, ref right, out result);
2538 return result;
2539 }
2540
2541 public static Matrix4x4 operator -(Matrix4x4 left, Matrix4x4 right)
2542 {
2543 Matrix4x4 result;
2544
2545 result.m00 = left.m00 - right.m00;
2546 result.m01 = left.m01 - right.m01;
2547 result.m02 = left.m02 - right.m02;
2548 result.m03 = left.m03 - right.m03;
2549
2550 result.m10 = left.m10 - right.m10;
2551 result.m11 = left.m11 - right.m11;
2552 result.m12 = left.m12 - right.m12;
2553 result.m13 = left.m13 - right.m13;
2554
2555 result.m20 = left.m20 - right.m20;
2556 result.m21 = left.m21 - right.m21;
2557 result.m22 = left.m22 - right.m22;
2558 result.m23 = left.m23 - right.m23;
2559
2560 result.m30 = left.m30 - right.m30;
2561 result.m31 = left.m31 - right.m31;
2562 result.m32 = left.m32 - right.m32;
2563 result.m33 = left.m33 - right.m33;
2564
2565 return result;
2566 }
2567 public static Matrix4x4 operator -(Matrix3x3 left, Matrix4x4 right)
2568 {
2569 Matrix4x4 result;
2570 Subtract(ref left, ref right, out result);
2571 return result;
2572 }
2573 public static Matrix4x4 operator -(Matrix4x4 left, Matrix3x3 right)
2574 {
2575 Matrix4x4 result;
2576 Subtract(ref left, ref right, out result);
2577 return result;
2578 }
2579 public static Matrix4x4 operator -(Matrix2x3 left, Matrix4x4 right)
2580 {
2581 Matrix4x4 result;
2582 Subtract(ref left, ref right, out result);
2583 return result;
2584 }
2585 public static Matrix4x4 operator -(Matrix4x4 left, Matrix2x3 right)
2586 {
2587 Matrix4x4 result;
2588 Subtract(ref left, ref right, out result);
2589 return result;
2590 }
2591 public static Matrix4x4 operator -(Matrix2x2 left, Matrix4x4 right)
2592 {
2593 Matrix4x4 result;
2594 Subtract(ref left, ref right, out result);
2595 return result;
2596 }
2597 public static Matrix4x4 operator -(Matrix4x4 left, Matrix2x2 right)
2598 {
2599 Matrix4x4 result;
2600 Subtract(ref left, ref right, out result);
2601 return result;
2602 }
2603
2604
2605 public static Matrix4x4 operator -(Matrix4x4 source)
2606 {
2607 Matrix4x4 result;
2608
2609 result.m00 = -source.m00;
2610 result.m01 = -source.m01;
2611 result.m02 = -source.m02;
2612 result.m03 = -source.m03;
2613
2614 result.m10 = -source.m10;
2615 result.m11 = -source.m11;
2616 result.m12 = -source.m12;
2617 result.m13 = -source.m13;
2618
2619 result.m20 = -source.m20;
2620 result.m21 = -source.m21;
2621 result.m22 = -source.m22;
2622 result.m23 = -source.m23;
2623
2624 result.m30 = -source.m30;
2625 result.m31 = -source.m31;
2626 result.m32 = -source.m32;
2627 result.m33 = -source.m33;
2628
2629 return result;
2630 }
2631
2632 public static bool operator ==(Matrix4x4 left, Matrix4x4 right)
2633 {
2634 return
2635 left.m00 == right.m00 && left.m01 == right.m01 && left.m02 == right.m02 && left.m03 == right.m03 &&
2636 left.m10 == right.m10 && left.m11 == right.m11 && left.m12 == right.m12 && left.m13 == right.m13 &&
2637 left.m20 == right.m20 && left.m21 == right.m21 && left.m22 == right.m22 && left.m23 == right.m23 &&
2638 left.m30 == right.m30 && left.m31 == right.m31 && left.m32 == right.m32 && left.m33 == right.m33;
2639 }
2640
2641 public static bool operator !=(Matrix4x4 left, Matrix4x4 right)
2642 {
2643 return !(left == right);
2644 }
2645
2646 public static explicit operator Matrix4x4(Matrix3x3 source)
2647 {
2648 Matrix4x4 result;
2649
2650 result.m00 = source.m00;
2651 result.m01 = source.m01;
2652 result.m02 = source.m02;
2653 result.m03 = 0;
2654
2655 result.m10 = source.m10;
2656 result.m11 = source.m11;
2657 result.m12 = source.m12;
2658 result.m13 = 0;
2659
2660 result.m20 = source.m20;
2661 result.m21 = source.m21;
2662 result.m22 = source.m22;
2663 result.m23 = 0;
2664
2665 result.m30 = 0;
2666 result.m31 = 0;
2667 result.m32 = 0;
2668 result.m33 = 1;
2669
2670 return result;
2671 }
2672 public static explicit operator Matrix4x4(Matrix2x2 source)
2673 {
2674 Matrix4x4 result;
2675
2676 result.m00 = source.m00;
2677 result.m01 = source.m01;
2678 result.m02 = 0;
2679 result.m03 = 0;
2680
2681 result.m10 = source.m10;
2682 result.m11 = source.m11;
2683 result.m12 = 0;
2684 result.m13 = 0;
2685
2686 result.m20 = 0;
2687 result.m21 = 0;
2688 result.m22 = 1;
2689 result.m23 = 0;
2690
2691 result.m30 = 0;
2692 result.m31 = 0;
2693 result.m32 = 0;
2694 result.m33 = 1;
2695
2696 return result;
2697 }
2698 #endregion
2699 }
2700}
System.Single Scalar
Definition: Clamped.cs:29
System.Single Scalar
Definition: Matrix4x4.cs:29
static string CreateMatrixFormatableString(int RowCount, int ColumnCount)
Definition: MatrixHelper.cs:43
static string CreateMatrixFormatString(int RowCount, int ColumnCount)
Definition: MatrixHelper.cs:39
static Exception GetThrowIndex(string name, int count)
Definition: ThrowHelper.cs:50
static void CheckCopy(Scalar[] array, int index, int count)
Definition: ThrowHelper.cs:35
int Count
Gets a 32-bit integer that represents the total number of elements in all the dimensions of IAdvanceV...
Definition: Interfaces.cs:41
int RowCount
Gets a 32-bit integer that represents the total number of Rows in the IMatrix.
Definition: Interfaces.cs:98
int ColumnCount
Gets a 32-bit integer that represents the total number of Columns in the IMatrix.
Definition: Interfaces.cs:102
A 2x2 matrix which can represent rotations for 2D vectors.
Definition: Matrix2x2.cs:58
A 2x3 matrix which can represent rotations around axes.
Definition: Matrix2x3.cs:62
A 3x3 matrix which can represent rotations around axes.
Definition: Matrix3x3.cs:62
static Matrix3x3 FromLookAt(Vector3D origin, Vector3D positiveZAxis, Vector3D onPositiveY)
Definition: Matrix3x3.cs:970
static Matrix4x4 operator-(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:2541
static Matrix4x4 FromScale(Vector3D scale)
Definition: Matrix4x4.cs:310
static Matrix4x4 Subtract(Matrix4x4 left, Matrix3x3 right)
Definition: Matrix4x4.cs:1252
static Matrix4x4 Add(Matrix4x4 left, Matrix2x2 right)
Definition: Matrix4x4.cs:1145
static Matrix4x4 Add(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:954
static Matrix4x4 operator+(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:2478
static void Subtract(ref Matrix4x4 left, ref Matrix3x3 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1258
static Matrix4x4 FromTranslation(Vector3D translation)
Definition: Matrix4x4.cs:262
Matrix4x4 Cofactor
Used to generate the Cofactor of this matrix.
Definition: Matrix4x4.cs:1995
static Matrix4x4 Lerp(Matrix4x4 left, Matrix4x4 right, Scalar amount)
Definition: Matrix4x4.cs:218
static void Add(ref Matrix4x4 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:980
static void Copy(ref Matrix4x4 matrix, Scalar[] destArray, int index)
Definition: Matrix4x4.cs:87
static void CopyTranspose(Scalar[] sourceArray, int index, out Matrix4x4 result)
Definition: Matrix4x4.cs:171
static Matrix4x4 From2DMatrix(Matrix2x3 source)
Definition: Matrix4x4.cs:419
static Matrix4x4 Subtract(Matrix4x4 left, Matrix2x3 right)
Definition: Matrix4x4.cs:1309
static void Subtract(ref Matrix2x3 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1287
static Matrix4x4 Subtract(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1175
static Matrix4x4 FromTransposedArray(Scalar[] array)
Definition: Matrix4x4.cs:255
const int ColumnCount
The number of columns.
Definition: Matrix4x4.cs:55
static Matrix4x4 FromOrthographic(Scalar left, Scalar right, Scalar bottom, Scalar top, Scalar near, Scalar far)
Definition: Matrix4x4.cs:361
static void GetAdjoint(ref Matrix4x4 source, out Matrix4x4 result)
Definition: Matrix4x4.cs:1587
static Matrix4x4 Subtract(Matrix3x3 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1224
static Matrix4x4 Add(Matrix4x4 left, Matrix2x3 right)
Definition: Matrix4x4.cs:1088
Vector4D GetRow(int rowIndex)
Definition: Matrix4x4.cs:2076
static void GetDeterminant(ref Matrix4x4 source, out Scalar result)
Definition: Matrix4x4.cs:1526
int IMatrix. RowCount
Definition: Matrix4x4.cs:2036
static bool TryParse(string s, out Matrix4x4 result)
Definition: Matrix4x4.cs:1728
static Matrix4x4 Multiply(Matrix2x2 left, Matrix4x4 right)
Definition: Matrix4x4.cs:894
static void Subtract(ref Matrix4x4 left, ref Matrix2x3 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1315
Scalar[] ToArray()
Copies the elements of the IAdvanceValueType to a new array of Scalar .
Definition: Matrix4x4.cs:2122
static void Subtract(ref Matrix3x3 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1230
static bool operator==(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:2632
static void Transpose(ref Matrix4x4 source, out Matrix4x4 result)
Definition: Matrix4x4.cs:1549
static Matrix4x4 Add(Matrix2x2 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1117
static void Multiply(ref Matrix4x4 left, ref Matrix2x2 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:853
static readonly string FormatString
Definition: Matrix4x4.cs:78
static Matrix4x4 Multiply(Matrix4x4 left, Matrix2x2 right)
Definition: Matrix4x4.cs:827
string ToStringInternal(string FormatString)
Definition: Matrix4x4.cs:2152
static void Add(ref Matrix2x3 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1066
static void Add(ref Matrix4x4 left, ref Matrix2x2 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1151
static readonly Matrix4x4 Identity
Definition: Matrix4x4.cs:72
static Matrix4x4 Add(Matrix4x4 left, Matrix3x3 right)
Definition: Matrix4x4.cs:1031
static void Subtract(ref Matrix4x4 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1201
override int GetHashCode()
Definition: Matrix4x4.cs:2169
static void CopyTranspose(Scalar[] sourceArray, out Matrix4x4 result)
Definition: Matrix4x4.cs:167
static void Add(ref Matrix4x4 left, ref Matrix3x3 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1037
void CopyTransposedTo(Scalar[] array, int index)
Definition: Matrix4x4.cs:2138
override bool Equals(object obj)
Definition: Matrix4x4.cs:2178
static void FromTranslation(ref Vector3D translation, out Matrix4x4 result)
Definition: Matrix4x4.cs:288
static Matrix4x4 Subtract(Matrix2x3 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1281
Scalar[] ToTransposedArray()
Definition: Matrix4x4.cs:2126
static Matrix4x4 Negate(Matrix4x4 source)
Definition: Matrix4x4.cs:1395
static void Add(ref Matrix2x2 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1123
static Matrix4x4 GetAdjoint(Matrix4x4 source)
Definition: Matrix4x4.cs:1581
static bool Equals(ref Matrix4x4 left, ref Matrix4x4 right)
Definition: Matrix4x4.cs:1743
static Matrix4x4 Multiply(Matrix2x3 left, Matrix4x4 right)
Definition: Matrix4x4.cs:768
void CopyTo(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType to the specified one-dimensional Array of Scalar.
Definition: Matrix4x4.cs:2134
void SetColumn(int columnIndex, Vector4D value)
Definition: Matrix4x4.cs:2056
static bool Equals(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1735
static Matrix4x4 FromLookAt(Vector3D origin, Vector3D positiveZAxis, Vector3D onPositiveY)
Definition: Matrix4x4.cs:356
static Matrix4x4 Invert(Matrix4x4 source)
Definition: Matrix4x4.cs:1448
static readonly Matrix4x4 Zero
Definition: Matrix4x4.cs:66
const int Size
The Size of the class in bytes;
Definition: Matrix4x4.cs:63
Matrix4x4 Transposed
Swap the rows of the matrix with the columns.
Definition: Matrix4x4.cs:1981
Matrix4x4(Scalar[] values, int index)
Definition: Matrix4x4.cs:1786
static Scalar GetDeterminant(Matrix4x4 source)
Definition: Matrix4x4.cs:1520
static void Multiply(ref Matrix3x3 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:664
static Matrix4x4 Subtract(Matrix4x4 left, Matrix2x2 right)
Definition: Matrix4x4.cs:1366
const int Count
The number of Scalar values in the class.
Definition: Matrix4x4.cs:59
Matrix4x4 Inverted
written to test out a theory. a very wasteful implimentation. but works.
Definition: Matrix4x4.cs:2025
static Matrix4x4 operator*(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:2262
static void Copy(ref Matrix4x4 matrix, Scalar[] destArray)
Definition: Matrix4x4.cs:83
static void Copy(ref Matrix3x3 source, ref Matrix4x4 dest)
Definition: Matrix4x4.cs:195
static void Multiply(ref Matrix2x2 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:920
static void Lerp(ref Matrix4x4 left, ref Matrix4x4 right, ref Scalar amount, out Matrix4x4 result)
Definition: Matrix4x4.cs:224
static Matrix4x4 Multiply(Matrix3x3 left, Matrix4x4 right)
Definition: Matrix4x4.cs:638
int IAdvanceValueType. Count
Definition: Matrix4x4.cs:2035
static void Add(ref Matrix4x4 left, ref Matrix2x3 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1094
string ToString(string format)
turns the object into a string representation of itself with a special format for each Scaler in it.
Definition: Matrix4x4.cs:2160
Matrix4x4 Adjoint
Used to generate the adjoint of this matrix..
Definition: Matrix4x4.cs:2008
static void FromScale(ref Vector3D scale, out Matrix4x4 result)
Definition: Matrix4x4.cs:334
static Matrix4x4 Multiply(Matrix4x4 left, Matrix2x3 right)
Definition: Matrix4x4.cs:702
Scalar Determinant
Gets the determinant of this matrix.
Definition: Matrix4x4.cs:1967
static void Multiply(ref Matrix4x4 left, ref Matrix2x3 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:728
static void Multiply(ref Matrix4x4 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:474
static Matrix4x4 GetCofactor(Matrix4x4 source)
Definition: Matrix4x4.cs:1651
static Matrix4x4 Parse(string s)
Definition: Matrix4x4.cs:1721
override string ToString()
Definition: Matrix4x4.cs:2164
void CopyFrom(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType, of the specified one-dimensional Array to the IAdva...
Definition: Matrix4x4.cs:2142
static void Copy(Scalar[] sourceArray, int index, out Matrix4x4 result)
Definition: Matrix4x4.cs:115
int IMatrix. ColumnCount
Definition: Matrix4x4.cs:2037
static Matrix4x4 Subtract(Matrix2x2 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1338
static void Add(ref Matrix3x3 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1009
static void Negate(ref Matrix4x4 source, out Matrix4x4 result)
Definition: Matrix4x4.cs:1425
const int RowCount
The number of rows.
Definition: Matrix4x4.cs:51
static Matrix4x4 Multiply(Matrix4x4 left, Scalar scalar)
Definition: Matrix4x4.cs:522
static void From2DMatrix(ref Matrix2x3 source, out Matrix4x4 result)
Definition: Matrix4x4.cs:425
static void Subtract(ref Matrix2x2 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1344
static Matrix4x4 Add(Matrix2x3 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1060
static void Invert(ref Matrix4x4 source, out Matrix4x4 result)
Definition: Matrix4x4.cs:1454
void CopyTransposedFrom(Scalar[] array, int index)
Definition: Matrix4x4.cs:2146
static void Negate(ref Matrix4x4 source)
Definition: Matrix4x4.cs:1421
static Matrix4x4 Multiply(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:448
Matrix4x4(Scalar m00, Scalar m01, Scalar m02, Scalar m03, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m20, Scalar m21, Scalar m22, Scalar m23, Scalar m30, Scalar m31, Scalar m32, Scalar m33)
Definition: Matrix4x4.cs:1766
Matrix4x4(Scalar[] values)
Definition: Matrix4x4.cs:1785
static Matrix4x4 Transpose(Matrix4x4 source)
Definition: Matrix4x4.cs:1543
static bool operator!=(Matrix4x4 left, Matrix4x4 right)
Definition: Matrix4x4.cs:2641
static void Copy(Scalar[] sourceArray, out Matrix4x4 result)
Definition: Matrix4x4.cs:111
static void Multiply(ref Matrix4x4 left, ref Scalar scalar, out Matrix4x4 result)
Definition: Matrix4x4.cs:548
static void GetCofactor(ref Matrix4x4 source, out Matrix4x4 result)
Definition: Matrix4x4.cs:1657
static Matrix4x4 Multiply(Matrix4x4 left, Matrix3x3 right)
Definition: Matrix4x4.cs:572
static readonly string FormatableString
Definition: Matrix4x4.cs:79
static void From2DMatrix(ref Matrix3x3 source, out Matrix4x4 result)
Definition: Matrix4x4.cs:396
static void Multiply(ref Matrix4x4 left, ref Matrix3x3 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:598
static void CopyTranspose(ref Matrix4x4 matrix, Scalar[] destArray)
Definition: Matrix4x4.cs:139
static void Copy(ref Matrix2x2 source, ref Matrix4x4 dest)
Definition: Matrix4x4.cs:209
static void CopyTranspose(ref Matrix4x4 matrix, Scalar[] destArray, int index)
Definition: Matrix4x4.cs:143
static Matrix4x4 FromArray(Scalar[] array)
Definition: Matrix4x4.cs:249
static Matrix4x4 Add(Matrix3x3 left, Matrix4x4 right)
Definition: Matrix4x4.cs:1003
Matrix4x4(Vector4D xAxis, Vector4D yAxis, Vector4D zAxis, Vector4D wAxis)
Definition: Matrix4x4.cs:1778
Vector4D GetColumn(int columnIndex)
Definition: Matrix4x4.cs:2041
Scalar[,] ToMatrixArray()
Definition: Matrix4x4.cs:2112
static Matrix4x4 From2DMatrix(Matrix3x3 source)
Definition: Matrix4x4.cs:390
void SetRow(int rowIndex, Vector4D value)
Definition: Matrix4x4.cs:2091
static void Subtract(ref Matrix4x4 left, ref Matrix2x2 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:1372
static void Multiply(ref Matrix2x3 left, ref Matrix4x4 right, out Matrix4x4 result)
Definition: Matrix4x4.cs:794
bool Equals(Matrix4x4 other)
Definition: Matrix4x4.cs:2184
A Vector with 3 dimensions.
Definition: Vector3D.cs:47
Scalar X
This is the X value.
Definition: Vector3D.cs:692
Scalar Y
This is the Y value.
Definition: Vector3D.cs:701
Scalar Z
This is the Z value.
Definition: Vector3D.cs:710
A Vector with 4 dimensions.
Definition: Vector4D.cs:48
Scalar X
This is the X value.
Definition: Vector4D.cs:710
Scalar Y
This is the Y value.
Definition: Vector4D.cs:719
Scalar Z
This is the Z value.
Definition: Vector4D.cs:728
Scalar W
This is the W value.
Definition: Vector4D.cs:737