Jypeli 10
The simple game programming library
Matrix3x3.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 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights to
7 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 * the Software, and to permit persons to whom the Software is furnished to do so,
9 * subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
17 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19 * OTHER DEALINGS IN THE SOFTWARE.
20 */
21#endregion
22
23
24#if UseDouble
25using Scalar = System.Double;
26#else
27using Scalar = System.Single;
28#endif
29using System;
30using System.Runtime.InteropServices;
32using System.Xml.Serialization;
33
34
35// NOTE. The (x,y,z) coordinate system is assumed to be right-handed.
36// Coordinate axis rotation matrices are of the form
37// RX = 1 0 0
38// 0 cos(t) -sin(t)
39// 0 sin(t) cos(t)
40// where t > 0 indicates a counterclockwise rotation in the yz-plane
41// RY = cos(t) 0 sin(t)
42// 0 1 0
43// -sin(t) 0 cos(t)
44// where t > 0 indicates a counterclockwise rotation in the zx-plane
45// RZ = cos(t) -sin(t) 0
46// sin(t) cos(t) 0
47// 0 0 1
48// where t > 0 indicates a counterclockwise rotation in the xy-plane.
49
50namespace AdvanceMath
51{
55 [StructLayout(LayoutKind.Sequential, Size = Matrix3x3.Size)]
56 [AdvBrowsableOrder("Rx,Ry,Rz")]
57#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE
58 [Serializable]
59 [System.ComponentModel.TypeConverter(typeof(AdvTypeConverter<Matrix3x3>))]
60#endif
61 public struct Matrix3x3 : IMatrix<Matrix3x3, Vector3D, Vector3D>
62 {
63 #region const fields
67 public const int RowCount = 3;
71 public const int ColumnCount = 3;
75 public const int Count = RowCount * ColumnCount;
79 public const int Size = sizeof(Scalar) * Count;
80 #endregion
81 #region static fields
84
85 public static readonly Matrix3x3 Identity = new Matrix3x3(
86 1, 0, 0,
87 0, 1, 0,
88 0, 0, 1);
89 public static readonly Matrix3x3 Zero = new Matrix3x3(
90 0, 0, 0,
91 0, 0, 0,
92 0, 0, 0);
93 #endregion
94 #region static methods
95
96 public static void Copy(ref Matrix3x3 matrix, Scalar[] destArray)
97 {
98 Copy(ref matrix, destArray, 0);
99 }
100 public static void Copy(ref Matrix3x3 matrix, Scalar[] destArray, int index)
101 {
102 ThrowHelper.CheckCopy(destArray, index, Count);
103
104 destArray[index] = matrix.m00;
105 destArray[++index] = matrix.m01;
106 destArray[++index] = matrix.m02;
107
108 destArray[++index] = matrix.m10;
109 destArray[++index] = matrix.m11;
110 destArray[++index] = matrix.m12;
111
112 destArray[++index] = matrix.m20;
113 destArray[++index] = matrix.m21;
114 destArray[++index] = matrix.m22;
115 }
116 public static void Copy(Scalar[] sourceArray, out Matrix3x3 result)
117 {
118 Copy(sourceArray, 0, out result);
119 }
120 public static void Copy(Scalar[] sourceArray, int index, out Matrix3x3 result)
121 {
122 ThrowHelper.CheckCopy(sourceArray, index, Count);
123
124 result.m00 = sourceArray[index];
125 result.m01 = sourceArray[++index];
126 result.m02 = sourceArray[++index];
127
128 result.m10 = sourceArray[++index];
129 result.m11 = sourceArray[++index];
130 result.m12 = sourceArray[++index];
131
132 result.m20 = sourceArray[++index];
133 result.m21 = sourceArray[++index];
134 result.m22 = sourceArray[++index];
135 }
136
137 public static void CopyTranspose(ref Matrix3x3 matrix, Scalar[] destArray)
138 {
139 CopyTranspose(ref matrix, destArray, 0);
140 }
141 public static void CopyTranspose(ref Matrix3x3 matrix, Scalar[] destArray, int index)
142 {
143 ThrowHelper.CheckCopy(destArray, index, Count);
144
145 destArray[index] = matrix.m00;
146 destArray[++index] = matrix.m10;
147 destArray[++index] = matrix.m20;
148
149 destArray[++index] = matrix.m01;
150 destArray[++index] = matrix.m11;
151 destArray[++index] = matrix.m21;
152
153 destArray[++index] = matrix.m02;
154 destArray[++index] = matrix.m12;
155 destArray[++index] = matrix.m22;
156 }
157 public static void CopyTranspose(Scalar[] sourceArray, out Matrix3x3 result)
158 {
159 CopyTranspose(sourceArray, 0, out result);
160 }
161 public static void CopyTranspose(Scalar[] sourceArray, int index, out Matrix3x3 result)
162 {
163 ThrowHelper.CheckCopy(sourceArray, index, Count);
164
165 result.m00 = sourceArray[index];
166 result.m10 = sourceArray[++index];
167 result.m20 = sourceArray[++index];
168
169 result.m01 = sourceArray[++index];
170 result.m11 = sourceArray[++index];
171 result.m21 = sourceArray[++index];
172
173 result.m02 = sourceArray[++index];
174 result.m12 = sourceArray[++index];
175 result.m22 = sourceArray[++index];
176 }
177
178 public static void Copy(ref Matrix4x4 source, out Matrix3x3 dest)
179 {
180 dest.m00 = source.m00;
181 dest.m01 = source.m01;
182 dest.m02 = source.m02;
183
184 dest.m10 = source.m10;
185 dest.m11 = source.m11;
186 dest.m12 = source.m12;
187
188 dest.m20 = source.m20;
189 dest.m21 = source.m21;
190 dest.m22 = source.m22;
191 }
192 public static void Copy(ref Matrix2x2 source, ref Matrix3x3 dest)
193 {
194 dest.m00 = source.m00;
195 dest.m01 = source.m01;
196
197 dest.m10 = source.m10;
198 dest.m11 = source.m11;
199 }
200
201 public static void Copy2DToOpenGlMatrix(ref Matrix3x3 source, Scalar[] destArray)
202 {
203 destArray[0] = source.m00;
204 destArray[1] = source.m10;
205
206 destArray[3] = source.m20;
207
208 destArray[4] = source.m01;
209 destArray[5] = source.m11;
210
211 destArray[7] = source.m21;
212
213 destArray[12] = source.m02;
214 destArray[13] = source.m12;
215
216 destArray[15] = source.m22;
217 }
218
219
220 public static Matrix3x3 Lerp(Matrix3x3 left, Matrix3x3 right, Scalar amount)
221 {
222 Matrix3x3 result;
223 Lerp(ref left, ref right, ref amount, out result);
224 return result;
225 }
226 public static void Lerp(ref Matrix3x3 left, ref Matrix3x3 right, ref Scalar amount, out Matrix3x3 result)
227 {
228 result.m00 = (right.m00 - left.m00) * amount + left.m00;
229 result.m01 = (right.m01 - left.m01) * amount + left.m01;
230 result.m02 = (right.m02 - left.m02) * amount + left.m02;
231
232 result.m10 = (right.m10 - left.m10) * amount + left.m10;
233 result.m11 = (right.m11 - left.m11) * amount + left.m11;
234 result.m12 = (right.m12 - left.m12) * amount + left.m12;
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 }
240
241
248 public static Matrix3x3 Multiply(Matrix3x3 left, Matrix3x3 right)
249 {
250 Matrix3x3 result;
251
252 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
253 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
254 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
255
256 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
257 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
258 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
259
260 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
261 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
262 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
263
264 return result;
265 }
266 public static void Multiply(ref Matrix3x3 left, ref Matrix3x3 right, out Matrix3x3 result)
267 {
268 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
269 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
270 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
271
272 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
273 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
274 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
275
276 Scalar m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
277 Scalar m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
278 Scalar m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
279
280
281 result.m00 = m00;
282 result.m01 = m01;
283 result.m02 = m02;
284
285 result.m10 = m10;
286 result.m11 = m11;
287 result.m12 = m12;
288
289 result.m20 = m20;
290 result.m21 = m21;
291 result.m22 = m22;
292 }
293
300 public static Matrix3x3 Multiply(Matrix3x3 left, Scalar scalar)
301 {
302 Matrix3x3 result;
303
304 result.m00 = left.m00 * scalar;
305 result.m01 = left.m01 * scalar;
306 result.m02 = left.m02 * scalar;
307
308 result.m10 = left.m10 * scalar;
309 result.m11 = left.m11 * scalar;
310 result.m12 = left.m12 * scalar;
311
312 result.m20 = left.m20 * scalar;
313 result.m21 = left.m21 * scalar;
314 result.m22 = left.m22 * scalar;
315
316 return result;
317 }
318 public static void Multiply(ref Matrix3x3 left, ref Scalar scalar, out Matrix3x3 result)
319 {
320
321 result.m00 = left.m00 * scalar;
322 result.m01 = left.m01 * scalar;
323 result.m02 = left.m02 * scalar;
324
325 result.m10 = left.m10 * scalar;
326 result.m11 = left.m11 * scalar;
327 result.m12 = left.m12 * scalar;
328
329 result.m20 = left.m20 * scalar;
330 result.m21 = left.m21 * scalar;
331 result.m22 = left.m22 * scalar;
332 }
333
340 public static Matrix3x3 Multiply(Matrix3x3 left, Matrix2x2 right)
341 {
342 Matrix3x3 result;
343
344 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
345 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
346 result.m02 = left.m02;
347
348 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
349 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
350 result.m12 = left.m12;
351
352 result.m20 = left.m20 * right.m00 + left.m21 * right.m10;
353 result.m21 = left.m20 * right.m01 + left.m21 * right.m11;
354 result.m22 = left.m22;
355
356 return result;
357 }
358 public static void Multiply(ref Matrix3x3 left, ref Matrix2x2 right, out Matrix3x3 result)
359 {
360 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10;
361 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11;
362
363 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10;
364 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11;
365
366 Scalar m20 = left.m20 * right.m00 + left.m21 * right.m10;
367 Scalar m21 = left.m20 * right.m01 + left.m21 * right.m11;
368
369 result.m00 = m00;
370 result.m01 = m01;
371 result.m02 = left.m02;
372
373 result.m10 = m10;
374 result.m11 = m11;
375 result.m12 = left.m12;
376
377 result.m20 = m20;
378 result.m21 = m21;
379 result.m22 = left.m22;
380 }
381
388 public static Matrix3x3 Multiply(Matrix2x2 left, Matrix3x3 right)
389 {
390 Matrix3x3 result;
391
392 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
393 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
394 result.m02 = left.m00 * right.m02 + left.m01 * right.m12;
395
396 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
397 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
398 result.m12 = left.m10 * right.m02 + left.m11 * right.m12;
399
400 result.m20 = right.m20;
401 result.m21 = right.m21;
402 result.m22 = right.m22;
403
404
405
406 return result;
407 }
408 public static void Multiply(ref Matrix2x2 left, ref Matrix3x3 right, out Matrix3x3 result)
409 {
410 Scalar m00 = left.m00 * right.m00 + left.m01 * right.m10;
411 Scalar m01 = left.m00 * right.m01 + left.m01 * right.m11;
412 Scalar m02 = left.m00 * right.m02 + left.m01 * right.m12;
413
414 Scalar m10 = left.m10 * right.m00 + left.m11 * right.m10;
415 Scalar m11 = left.m10 * right.m01 + left.m11 * right.m11;
416 Scalar m12 = left.m10 * right.m02 + left.m11 * right.m12;
417
418 result.m00 = m00;
419 result.m01 = m01;
420 result.m02 = m02;
421
422 result.m10 = m10;
423 result.m11 = m11;
424 result.m12 = m12;
425
426 result.m20 = right.m20;
427 result.m21 = right.m21;
428 result.m22 = right.m22;
429
430
431 }
432
433
440 public static Matrix3x3 Add(Matrix3x3 left, Matrix3x3 right)
441 {
442 Matrix3x3 result;
443
444 result.m00 = left.m00 + right.m00;
445 result.m01 = left.m01 + right.m01;
446 result.m02 = left.m02 + right.m02;
447
448 result.m10 = left.m10 + right.m10;
449 result.m11 = left.m11 + right.m11;
450 result.m12 = left.m12 + right.m12;
451
452 result.m20 = left.m20 + right.m20;
453 result.m21 = left.m21 + right.m21;
454 result.m22 = left.m22 + right.m22;
455
456 return result;
457 }
458 public static void Add(ref Matrix3x3 left, ref Matrix3x3 right, out Matrix3x3 result)
459 {
460 result.m00 = left.m00 + right.m00;
461 result.m01 = left.m01 + right.m01;
462 result.m02 = left.m02 + right.m02;
463
464 result.m10 = left.m10 + right.m10;
465 result.m11 = left.m11 + right.m11;
466 result.m12 = left.m12 + right.m12;
467
468 result.m20 = left.m20 + right.m20;
469 result.m21 = left.m21 + right.m21;
470 result.m22 = left.m22 + right.m22;
471 }
472
473 public static Matrix3x3 Add(Matrix2x2 left, Matrix3x3 right)
474 {
475 Matrix3x3 result;
476 Add(ref left, ref right, out result);
477 return result;
478 }
479 public static void Add(ref Matrix2x2 left, ref Matrix3x3 right, out Matrix3x3 result)
480 {
481 result.m00 = left.m00 + right.m00;
482 result.m01 = left.m01 + right.m01;
483 result.m02 = right.m02;
484
485 result.m10 = left.m10 + right.m10;
486 result.m11 = left.m11 + right.m11;
487 result.m12 = right.m12;
488
489 result.m20 = right.m20;
490 result.m21 = right.m21;
491 result.m22 = 1 + right.m22;
492 }
493 public static Matrix3x3 Add(Matrix3x3 left, Matrix2x2 right)
494 {
495 Matrix3x3 result;
496 Add(ref left, ref right, out result);
497 return result;
498 }
499 public static void Add(ref Matrix3x3 left, ref Matrix2x2 right, out Matrix3x3 result)
500 {
501 result.m00 = left.m00 + right.m00;
502 result.m01 = left.m01 + right.m01;
503 result.m02 = left.m02;
504
505 result.m10 = left.m10 + right.m10;
506 result.m11 = left.m11 + right.m11;
507 result.m12 = left.m12;
508
509 result.m20 = left.m20;
510 result.m21 = left.m21;
511 result.m22 = left.m22 + 1;
512 }
513
514
515
522 public static Matrix3x3 Subtract(Matrix3x3 left, Matrix3x3 right)
523 {
524 Matrix3x3 result;
525
526 result.m00 = left.m00 - right.m00;
527 result.m01 = left.m01 - right.m01;
528 result.m02 = left.m02 - right.m02;
529
530 result.m10 = left.m10 - right.m10;
531 result.m11 = left.m11 - right.m11;
532 result.m12 = left.m12 - right.m12;
533
534 result.m20 = left.m20 - right.m20;
535 result.m21 = left.m21 - right.m21;
536 result.m22 = left.m22 - right.m22;
537
538 return result;
539 }
540 public static void Subtract(ref Matrix3x3 left, ref Matrix3x3 right, out Matrix3x3 result)
541 {
542 result.m00 = left.m00 - right.m00;
543 result.m01 = left.m01 - right.m01;
544 result.m02 = left.m02 - right.m02;
545
546 result.m10 = left.m10 - right.m10;
547 result.m11 = left.m11 - right.m11;
548 result.m12 = left.m12 - right.m12;
549
550 result.m20 = left.m20 - right.m20;
551 result.m21 = left.m21 - right.m21;
552 result.m22 = left.m22 - right.m22;
553
554 }
555
556 public static Matrix3x3 Subtract(Matrix2x2 left, Matrix3x3 right)
557 {
558 Matrix3x3 result;
559 Subtract(ref left, ref right, out result);
560 return result;
561 }
562 public static void Subtract(ref Matrix2x2 left, ref Matrix3x3 right, out Matrix3x3 result)
563 {
564 result.m00 = left.m00 - right.m00;
565 result.m01 = left.m01 - right.m01;
566 result.m02 = -right.m02;
567
568 result.m10 = left.m10 - right.m10;
569 result.m11 = left.m11 - right.m11;
570 result.m12 = -right.m12;
571
572 result.m20 = -right.m20;
573 result.m21 = -right.m21;
574 result.m22 = 1 - right.m22;
575 }
576 public static Matrix3x3 Subtract(Matrix3x3 left, Matrix2x2 right)
577 {
578 Matrix3x3 result;
579 Subtract(ref left, ref right, out result);
580 return result;
581 }
582 public static void Subtract(ref Matrix3x3 left, ref Matrix2x2 right, out Matrix3x3 result)
583 {
584 result.m00 = left.m00 - right.m00;
585 result.m01 = left.m01 - right.m01;
586 result.m02 = left.m02;
587
588 result.m10 = left.m10 - right.m10;
589 result.m11 = left.m11 - right.m11;
590 result.m12 = left.m12;
591
592 result.m20 = left.m20;
593 result.m21 = left.m21;
594 result.m22 = left.m22 - 1;
595 }
596
601 public static Matrix3x3 Negate(Matrix3x3 source)
602 {
603 Matrix3x3 result;
604
605 result.m00 = -source.m00;
606 result.m01 = -source.m01;
607 result.m02 = -source.m02;
608
609 result.m10 = -source.m10;
610 result.m11 = -source.m11;
611 result.m12 = -source.m12;
612
613 result.m20 = -source.m20;
614 result.m21 = -source.m21;
615 result.m22 = -source.m22;
616
617
618 return result;
619 }
620 public static void Negate(ref Matrix3x3 source)
621 {
622 Negate(ref source, out source);
623 }
624 public static void Negate(ref Matrix3x3 source, out Matrix3x3 result)
625 {
626 result.m00 = -source.m00;
627 result.m01 = -source.m01;
628 result.m02 = -source.m02;
629
630 result.m10 = -source.m10;
631 result.m11 = -source.m11;
632 result.m12 = -source.m12;
633
634 result.m20 = -source.m20;
635 result.m21 = -source.m21;
636 result.m22 = -source.m22;
637 }
638
639 public static Matrix3x3 Invert(Matrix3x3 source)
640 {
641 Matrix3x3 result;
642 Invert(ref source, out result);
643 return result;
644 }
645 public static void Invert(ref Matrix3x3 source, out Matrix3x3 result)
646 {
647 Scalar m01 = source.m01;
648 Scalar m02 = source.m02;
649
650 Scalar m11 = source.m11;
651 Scalar m12 = source.m12;
652
653
654
655
656 Scalar m11m22m12m21 = (m11 * source.m22 - m12 * source.m21);
657 Scalar m10m22m12m20 = (source.m10 * source.m22 - m12 * source.m20);
658 Scalar m10m21m11m20 = (source.m10 * source.m21 - m11 * source.m20);
659
660
661
662 Scalar detInv = 1 / (source.m00 * (m11m22m12m21) - m01 * (m10m22m12m20) + m02 * (m10m21m11m20));
663
664
665 result.m01 = detInv * (-(m01 * source.m22 - m02 * source.m21));
666 result.m02 = detInv * (m01 * m12 - m02 * m11);
667
668 result.m11 = detInv * (source.m00 * source.m22 - m02 * source.m20);
669 result.m12 = detInv * (-(source.m00 * m12 - m02 * source.m10));
670
671 result.m21 = detInv * (-(source.m00 * source.m21 - m01 * source.m20));
672 result.m22 = detInv * (source.m00 * m11 - m01 * source.m10);
673
674
675 result.m00 = detInv * (m11m22m12m21);
676 result.m10 = detInv * (-(m10m22m12m20));
677 result.m20 = detInv * (m10m21m11m20);
678
679 }
680
681 public static Scalar GetDeterminant(Matrix3x3 source)
682 {
683 Scalar result;
684 GetDeterminant(ref source, out result);
685 return result;
686 }
687 public static void GetDeterminant(ref Matrix3x3 source, out Scalar result)
688 {
689 // note: this is an expanded version of the Ogre determinant() method, to give better performance in C#. Generated using a script
690 result =
691 source.m00 * (source.m11 * source.m22 - source.m12 * source.m21) -
692 source.m01 * (source.m10 * source.m22 - source.m12 * source.m20) +
693 source.m02 * (source.m10 * source.m21 - source.m11 * source.m20);
694 }
695
696 public static Matrix3x3 Transpose(Matrix3x3 source)
697 {
698 Matrix3x3 result;
699 Transpose(ref source, out result);
700 return result;
701 }
702 public static void Transpose(ref Matrix3x3 source, out Matrix3x3 result)
703 {
704 Scalar m01 = source.m01;
705 Scalar m02 = source.m02;
706 Scalar m12 = source.m12;
707
708 result.m00 = source.m00;
709 result.m01 = source.m10;
710 result.m02 = source.m20;
711
712 result.m10 = m01;
713 result.m11 = source.m11;
714 result.m12 = source.m21;
715
716 result.m20 = m02;
717 result.m21 = m12;
718 result.m22 = source.m22;
719
720
721
722 }
723
724 public static Matrix3x3 GetAdjoint(Matrix3x3 source)
725 {
726 Matrix3x3 result;
727 GetAdjoint(ref source, out result);
728 return result;
729 }
730 public static void GetAdjoint(ref Matrix3x3 source, out Matrix3x3 result)
731 {
732 Scalar m01 = source.m01;
733 Scalar m02 = source.m02;
734 Scalar m11 = source.m11;
735 Scalar m12 = source.m12;
736
737 Scalar m11m22m12m21 = (m11 * source.m22 - m12 * source.m21);
738 Scalar m10m22m12m20 = (source.m10 * source.m22 - m12 * source.m20);
739 Scalar m10m21m11m20 = (source.m10 * source.m21 - m11 * source.m20);
740
741
742 result.m01 = (-(m01 * source.m22 - m02 * source.m21));
743 result.m02 = (m01 * m12 - m02 * m11);
744
745 result.m11 = (source.m00 * source.m22 - m02 * source.m20);
746 result.m12 = (-(source.m00 * m12 - m02 * source.m10));
747
748 result.m21 = (-(source.m00 * source.m21 - m01 * source.m20));
749 result.m22 = (source.m00 * m11 - m01 * source.m10);
750
751
752 result.m00 = (m11m22m12m21);
753 result.m10 = (-(m10m22m12m20));
754 result.m20 = (m10m21m11m20);
755
756 }
757
758 public static Matrix3x3 GetCofactor(Matrix3x3 source)
759 {
760 Matrix3x3 result;
761 GetCofactor(ref source, out result);
762 return result;
763 }
764 public static void GetCofactor(ref Matrix3x3 source, out Matrix3x3 result)
765 {
766 Scalar m01 = source.m01;
767 Scalar m02 = source.m02;
768 Scalar m11 = source.m11;
769 Scalar m12 = source.m12;
770
771 Scalar m11m22m12m21 = (m11 * source.m22 - m12 * source.m21);
772 Scalar m10m22m12m20 = (source.m10 * source.m22 - m12 * source.m20);
773 Scalar m10m21m11m20 = (source.m10 * source.m21 - m11 * source.m20);
774
775
776 result.m01 = ((m01 * source.m22 - m02 * source.m21));
777 result.m02 = (-(m01 * m12 - m02 * m11));
778
779 result.m11 = (-(source.m00 * source.m22 - m02 * source.m20));
780 result.m12 = ((source.m00 * m12 - m02 * source.m10));
781
782 result.m21 = ((source.m00 * source.m21 - m01 * source.m20));
783 result.m22 = (-(source.m00 * m11 - m01 * source.m10));
784
785
786 result.m00 = (-(m11m22m12m21));
787 result.m10 = ((m10m22m12m20));
788 result.m20 = (-(m10m21m11m20));
789
790 }
791
792
793
794 public static Matrix3x3 FromArray(Scalar[] array)
795 {
796 Matrix3x3 result;
797 Copy(array, 0, out result);
798 return result;
799 }
800 public static Matrix3x3 FromTransposedArray(Scalar[] array)
801 {
802 Matrix3x3 result;
803 CopyTranspose(array, 0, out result);
804 return result;
805 }
806
807 public static Matrix3x3 FromTransformation(Scalar rotation, Vector2D translation)
808 {
809 Matrix3x3 result;
810 FromTransformation(ref rotation, ref translation, out result);
811 return result;
812 }
813 public static void FromTransformation(ref Scalar rotation, ref Vector2D translation, out Matrix3x3 result)
814 {
815 result.m00 = MathHelper.Cos(rotation);
816 result.m10 = MathHelper.Sin(rotation);
817 result.m01 = -result.m10;
818 result.m11 = result.m00;
819 result.m02 = translation.X;
820 result.m12 = translation.Y;
821 result.m20 = 0;
822 result.m21 = 0;
823 result.m22 = 1;
824 }
825
826 public static Matrix3x3 FromRotationX(Scalar radianAngle)
827 {
828 Matrix3x3 result;
829
830 result.m21 = MathHelper.Sin(radianAngle);
831
832
833 result.m00 = 1;
834 result.m01 = 0;
835 result.m02 = 0;
836
837 result.m10 = 0;
838 result.m11 = MathHelper.Cos(radianAngle);
839 result.m12 = -result.m21;
840
841 result.m20 = 0;
842 result.m22 = result.m11;
843
844 return result;
845 }
846 public static void FromRotationX(ref Scalar radianAngle, out Matrix3x3 result)
847 {
848 result.m21 = MathHelper.Sin(radianAngle);
849
850
851 result.m00 = 1;
852 result.m01 = 0;
853 result.m02 = 0;
854
855 result.m10 = 0;
856 result.m11 = MathHelper.Cos(radianAngle);
857 result.m12 = -result.m21;
858
859 result.m20 = 0;
860 result.m22 = result.m11;
861 }
862 public static Matrix3x3 FromRotationY(Scalar radianAngle)
863 {
864 Matrix3x3 result;
865
866 result.m20 = MathHelper.Sin(radianAngle);
867
868
869 result.m00 = MathHelper.Cos(radianAngle);
870 result.m01 = 0;
871 result.m02 = -result.m20;
872
873 result.m10 = 0;
874 result.m11 = 1;
875 result.m12 = 0;
876
877 result.m21 = 0;
878 result.m22 = result.m00;
879
880 return result;
881 }
882 public static void FromRotationY(ref Scalar radianAngle, out Matrix3x3 result)
883 {
884 result.m20 = MathHelper.Sin(radianAngle);
885
886
887 result.m00 = MathHelper.Cos(radianAngle);
888 result.m01 = 0;
889 result.m02 = -result.m20;
890
891 result.m10 = 0;
892 result.m11 = 1;
893 result.m12 = 0;
894
895 result.m21 = 0;
896 result.m22 = result.m00;
897
898 }
899 public static Matrix3x3 FromRotationZ(Scalar radianAngle)
900 {
901 Matrix3x3 result;
902
903 result.m10 = MathHelper.Sin(radianAngle);
904
905
906 result.m00 = MathHelper.Cos(radianAngle);
907 result.m01 = -result.m10;
908 result.m02 = 0;
909
910 result.m11 = result.m00;
911 result.m12 = 0;
912
913 result.m20 = 0;
914 result.m21 = 0;
915 result.m22 = 1;
916
917 return result;
918 }
919 public static void FromRotationZ(ref Scalar radianAngle, out Matrix3x3 result)
920 {
921
922 result.m10 = MathHelper.Sin(radianAngle);
923
924
925 result.m00 = MathHelper.Cos(radianAngle);
926 result.m01 = -result.m10;
927 result.m02 = 0;
928
929 result.m11 = result.m00;
930 result.m12 = 0;
931
932 result.m20 = 0;
933 result.m21 = 0;
934 result.m22 = 1;
935
936 }
937 public static Matrix3x3 FromRotationAxisUsingAtan(Scalar radianAngle, Vector3D axis)
938 {
939 Scalar zAngle;
940 Scalar yAngle;
941 if (axis.X == 0)
942 {
943 if (axis.Y == 0)
944 {
945 return FromRotationZ(radianAngle);
946 }
947 else
948 {
949 zAngle = MathHelper.PiOver2;
950 yAngle = (Scalar)Math.Atan(axis.Z / axis.Y);
951 }
952 }
953 else
954 {
955 zAngle = (Scalar)Math.Atan(axis.Y / axis.X);
956 yAngle = (Scalar)Math.Atan(axis.Z / Math.Sqrt(axis.X * axis.X + axis.Y * axis.Y));
957 }
958 return FromRotationZ(-zAngle) *
959 FromRotationY(-yAngle) *
960 FromRotationX(radianAngle) *
961 FromRotationY(yAngle) *
962 FromRotationZ(zAngle);
963 }
964
965 public static Matrix3x3 FromRotationAxis(Scalar radianAngle, Vector3D axis)
966 {
967 Matrix3x3 first = FromLookAt(Vector3D.Zero, axis, new Vector3D(axis.Z, axis.X, axis.Y));
968 return first.Inverted * FromRotationZ(radianAngle) * first;
969 }
970 internal static Matrix3x3 FromLookAt(Vector3D origin, Vector3D positiveZAxis, Vector3D onPositiveY)
971 {
972 Matrix3x3 rv = Identity;
973 rv.Rz = Vector3D.Normalize(positiveZAxis - origin);
974 rv.Rx = Vector3D.Normalize((onPositiveY - origin) ^ rv.Rz);
975 rv.Ry = Vector3D.Normalize(rv.Rz ^ rv.Rx);
976 return rv;
977 }
978
979
980 public static Matrix3x3 FromScale(Vector3D scale)
981 {
982 Matrix3x3 result;
983
984 result.m00 = scale.X;
985 result.m01 = 0;
986 result.m02 = 0;
987
988 result.m10 = 0;
989 result.m11 = scale.Y;
990 result.m12 = 0;
991
992 result.m20 = 0;
993 result.m21 = 0;
994 result.m22 = scale.Z;
995
996 return result;
997 }
998 public static void FromScale(ref Vector3D scale, out Matrix3x3 result)
999 {
1000 result.m00 = scale.X;
1001 result.m01 = 0;
1002 result.m02 = 0;
1003
1004 result.m10 = 0;
1005 result.m11 = scale.Y;
1006 result.m12 = 0;
1007
1008 result.m20 = 0;
1009 result.m21 = 0;
1010 result.m22 = scale.Z;
1011 }
1012 public static Matrix3x3 FromScale(Vector2D scale)
1013 {
1014 Matrix3x3 result;
1015 result.m00 = scale.X;
1016 result.m01 = 0;
1017 result.m02 = 0;
1018
1019 result.m10 = 0;
1020 result.m11 = scale.Y;
1021 result.m12 = 0;
1022
1023 result.m20 = 0;
1024 result.m21 = 0;
1025 result.m22 = 1;
1026 return result;
1027 }
1028 public static void FromScale(ref Vector2D scale, out Matrix3x3 result)
1029 {
1030 result.m00 = scale.X;
1031 result.m01 = 0;
1032 result.m02 = 0;
1033
1034 result.m10 = 0;
1035 result.m11 = scale.Y;
1036 result.m12 = 0;
1037
1038 result.m20 = 0;
1039 result.m21 = 0;
1040 result.m22 = 1;
1041 }
1043 {
1044 Matrix3x3 result;
1045
1046 result.m00 = 1;
1047 result.m01 = 0;
1048 result.m02 = value.X;
1049
1050 result.m10 = 0;
1051 result.m11 = 1;
1052 result.m12 = value.Y;
1053
1054 result.m20 = 0;
1055 result.m21 = 0;
1056 result.m22 = 1;
1057
1058 return result;
1059 }
1060 public static void FromTranslate2D(ref Vector2D value, out Matrix3x3 result)
1061 {
1062 result.m00 = 1;
1063 result.m01 = 0;
1064 result.m02 = value.X;
1065
1066 result.m10 = 0;
1067 result.m11 = 1;
1068 result.m12 = value.Y;
1069
1070 result.m20 = 0;
1071 result.m21 = 0;
1072 result.m22 = 1;
1073 }
1074 public static Matrix3x3 FromShear3D(Vector2D value)
1075 {
1076 Matrix3x3 result;
1077
1078 result.m00 = 1;
1079 result.m01 = 0;
1080 result.m02 = value.X;
1081
1082 result.m10 = 0;
1083 result.m11 = 1;
1084 result.m12 = value.Y;
1085
1086 result.m20 = 0;
1087 result.m21 = 0;
1088 result.m22 = 1;
1089
1090 return result;
1091 }
1092 public static void FromShear3D(ref Vector2D value, out Matrix3x3 result)
1093 {
1094 result.m00 = 1;
1095 result.m01 = 0;
1096 result.m02 = value.X;
1097
1098 result.m10 = 0;
1099 result.m11 = 1;
1100 result.m12 = value.Y;
1101
1102 result.m20 = 0;
1103 result.m21 = 0;
1104 result.m22 = 1;
1105 }
1106
1110 {
1111 Scalar cofactor00 = m11 * m22 - m12 * m21;
1112 Scalar cofactor10 = m12 * m20 - m10 * m22;
1113 Scalar cofactor20 = m10 * m21 - m11 * m20;
1114 Scalar result =
1115 m00 * cofactor00 +
1116 m01 * cofactor10 +
1117 m02 * cofactor20;
1118 return result;
1119 }
1121 {
1122 Scalar cofactor00 = Ry.Y * Rz.Z - Ry.Z * Rz.Y;
1123 Scalar cofactor10 = Ry.Z * Rz.X - Ry.X * Rz.Z;
1124 Scalar cofactor20 = Ry.X * Rz.Y - Ry.Y * Rz.X;
1125 Scalar result =
1126 Rx.X * cofactor00 +
1127 Rx.Y * cofactor10 +
1128 Rx.Z * cofactor20;
1129 return result;
1130 }
1131
1138 public static Matrix3x3 FromEulerAnglesXYZ(Scalar yaw, Scalar pitch, Scalar roll)
1139 {
1140 return FromRotationX(yaw) * (FromRotationY(pitch) * FromRotationZ(roll));
1141 }
1142
1143 [ParseMethod]
1144 public static Matrix3x3 Parse(string s)
1145 {
1146 Matrix3x3 rv = Zero;
1147 ParseHelper.ParseMatrix<Matrix3x3>(s, ref rv);
1148 return rv;
1149 }
1150#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT
1151 public static bool TryParse(string s, out Matrix3x3 result)
1152 {
1153 result = Zero;
1154 return ParseHelper.TryParseMatrix<Matrix3x3>(s, ref result);
1155 }
1156#endif
1157
1158
1159 public static bool Equals(Matrix3x3 left, Matrix3x3 right)
1160 {
1161 return
1162 left.m00 == right.m00 && left.m01 == right.m01 && left.m02 == right.m02 &&
1163 left.m10 == right.m10 && left.m11 == right.m11 && left.m12 == right.m12 &&
1164 left.m20 == right.m20 && left.m21 == right.m21 && left.m22 == right.m22;
1165 }
1166 public static bool Equals(ref Matrix3x3 left, ref Matrix3x3 right)
1167 {
1168 return
1169 left.m00 == right.m00 && left.m01 == right.m01 && left.m02 == right.m02 &&
1170 left.m10 == right.m10 && left.m11 == right.m11 && left.m12 == right.m12 &&
1171 left.m20 == right.m20 && left.m21 == right.m21 && left.m22 == right.m22;
1172 }
1173
1174 #endregion
1175 #region fields
1176
1177 // | m00 m01 m02 |
1178 // | m10 m11 m12 |
1179 // | m20 m21 m22 |
1180 [XmlIgnore]
1181 public Scalar m00, m01, m02;
1182 [XmlIgnore]
1183 public Scalar m10, m11, m12;
1184 [XmlIgnore]
1185 public Scalar m20, m21, m22;
1186
1187 #endregion
1188 #region Constructors
1189
1196 {
1197 this.m00 = m00; this.m01 = m01; this.m02 = m02;
1198 this.m10 = m10; this.m11 = m11; this.m12 = m12;
1199 this.m20 = m20; this.m21 = m21; this.m22 = m22;
1200 }
1201
1208 [InstanceConstructor("Rx,Ry,Rz")]
1209 public Matrix3x3(Vector3D xAxis, Vector3D yAxis, Vector3D zAxis)
1210 {
1211 this.m00 = xAxis.X; this.m01 = xAxis.Y; this.m02 = xAxis.Z;
1212 this.m10 = yAxis.X; this.m11 = yAxis.Y; this.m12 = yAxis.Z;
1213 this.m20 = zAxis.X; this.m21 = zAxis.Y; this.m22 = zAxis.Z;
1214 }
1215 public Matrix3x3(Scalar[] values) : this(values, 0) { }
1216 public Matrix3x3(Scalar[] values, int index)
1217 {
1218 Copy(values, index, out this);
1219 }
1220 #endregion
1221 #region Properties
1222 [AdvBrowsable]
1223#if !WINDOWS_STOREAPP
1224 [System.ComponentModel.Description("The First row of the Matrix3x3")]
1225#endif
1227 {
1228 get
1229 {
1230 Vector3D value;
1231 value.X = m00;
1232 value.Y = m01;
1233 value.Z = m02;
1234 return value;
1235 }
1236 set
1237 {
1238 m00 = value.X;
1239 m01 = value.Y;
1240 m02 = value.Z;
1241 }
1242 }
1243 [AdvBrowsable]
1244#if !WINDOWS_STOREAPP
1245 [System.ComponentModel.Description("The Second row of the Matrix3x3")]
1246#endif
1248 {
1249 get
1250 {
1251 Vector3D value;
1252 value.X = m10;
1253 value.Y = m11;
1254 value.Z = m12;
1255 return value;
1256 }
1257 set
1258 {
1259 m10 = value.X;
1260 m11 = value.Y;
1261 m12 = value.Z;
1262 }
1263 }
1264 [AdvBrowsable]
1265#if !WINDOWS_STOREAPP
1266 [System.ComponentModel.Description("The Third row of the Matrix3x3")]
1267#endif
1269 {
1270 get
1271 {
1272 Vector3D value;
1273 value.X = m20;
1274 value.Y = m21;
1275 value.Z = m22;
1276 return value;
1277 }
1278 set
1279 {
1280 m20 = value.X;
1281 m21 = value.Y;
1282 m22 = value.Z;
1283 }
1284 }
1285 [XmlIgnore]
1287 {
1288 get
1289 {
1290 return new Vector3D(m00, m10, m20);
1291 }
1292 set
1293 {
1294 this.m00 = value.X;
1295 this.m10 = value.Y;
1296 this.m20 = value.Z;
1297 }
1298 }
1299 [XmlIgnore]
1301 {
1302 get
1303 {
1304 return new Vector3D(m01, m11, m21);
1305 }
1306 set
1307 {
1308 this.m01 = value.X;
1309 this.m11 = value.Y;
1310 this.m21 = value.Z;
1311 }
1312 }
1313 [XmlIgnore]
1315 {
1316 get
1317 {
1318 return new Vector3D(m02, m12, m22);
1319 }
1320 set
1321 {
1322 this.m02 = value.X;
1323 this.m12 = value.Y;
1324 this.m22 = value.Z;
1325 }
1326 }
1327
1329 {
1330 get
1331 {
1332 Scalar result;
1333 GetDeterminant(ref this, out result);
1334 return result;
1335 }
1336 }
1342 {
1343 get
1344 {
1345 Matrix3x3 result;
1346 Transpose(ref this, out result);
1347 return result;
1348 }
1349 }
1351 {
1352 get
1353 {
1354 Matrix3x3 result;
1355 GetAdjoint(ref this, out result);
1356 return result;
1357 }
1358 }
1360 {
1361 get
1362 {
1363 Matrix3x3 result;
1364 GetCofactor(ref this, out result);
1365 return result;
1366 }
1367 }
1369 {
1370 get
1371 {
1372 Matrix3x3 result;
1373 Invert(ref this, out result);
1374 return result;
1375 }
1376 }
1377
1378 int IAdvanceValueType.Count { get { return Count; } }
1379 int IMatrix.RowCount { get { return RowCount; } }
1380 int IMatrix.ColumnCount { get { return ColumnCount; } }
1381 #endregion Properties
1382 #region Methods
1383
1384 public Vector3D GetColumn(int columnIndex)
1385 {
1386 switch (columnIndex)
1387 {
1388 case 0:
1389 return Cx;
1390 case 1:
1391 return Cy;
1392 case 2:
1393 return Cz;
1394 }
1395 throw ThrowHelper.GetThrowIndex("columnIndex", ColumnCount);
1396 }
1397 public void SetColumn(int columnIndex, Vector3D value)
1398 {
1399
1400 switch (columnIndex)
1401 {
1402 case 0:
1403 Cx = value;
1404 return;
1405 case 1:
1406 Cy = value;
1407 return;
1408 case 2:
1409 Cz = value;
1410 return;
1411 }
1412 throw ThrowHelper.GetThrowIndex("columnIndex", ColumnCount);
1413 }
1414 public Vector3D GetRow(int rowIndex)
1415 {
1416 switch (rowIndex)
1417 {
1418 case 0:
1419 return Rx;
1420 case 1:
1421 return Ry;
1422 case 2:
1423 return Rz;
1424 }
1425 throw ThrowHelper.GetThrowIndex("rowIndex", RowCount);
1426 }
1427 public void SetRow(int rowIndex, Vector3D value)
1428 {
1429 switch (rowIndex)
1430 {
1431 case 0:
1432 Rx = value;
1433 return;
1434 case 1:
1435 Ry = value;
1436 return;
1437 case 2:
1438 Rz = value;
1439 return;
1440 }
1441 throw ThrowHelper.GetThrowIndex("rowIndex", RowCount);
1442 }
1443
1445 {
1446 return new Scalar[RowCount, ColumnCount] { { m00, m01, m02 }, { m10, m11, m12 }, { m20, m21, m22 } };
1447 }
1448 public Scalar[] ToArray()
1449 {
1450 return new Scalar[Count] { m00, m01, m02, m10, m11, m12, m20, m21, m22 };
1451 }
1453 {
1454 return new Scalar[Count] { m00, m10, m20, m01, m11, m21, m02, m12, m22 };
1455 }
1456
1458 {
1459 Matrix4x4 result = Matrix4x4.Identity;
1460 result.m00 = this.m00; result.m01 = this.m01; result.m03 = this.m02;
1461 result.m10 = this.m10; result.m11 = this.m11; result.m13 = this.m12;
1462 result.m30 = this.m20; result.m31 = this.m21; result.m33 = this.m22;
1463 return result;
1464 }
1466 {
1467 Matrix4x4 result = Matrix4x4.Identity;
1468 result.m00 = this.m00; result.m01 = this.m01; result.m02 = this.m02;
1469 result.m10 = this.m10; result.m11 = this.m11; result.m12 = this.m12;
1470 result.m20 = this.m20; result.m21 = this.m21; result.m22 = this.m22;
1471 return result;
1472 }
1473
1474 public void CopyTo(Scalar[] array, int index)
1475 {
1476 Copy(ref this, array, index);
1477 }
1478 public void CopyTransposedTo(Scalar[] array, int index)
1479 {
1480 CopyTranspose(ref this, array, index);
1481 }
1482 public void CopyFrom(Scalar[] array, int index)
1483 {
1484 Copy(array, index, out this);
1485 }
1486 public void CopyTransposedFrom(Scalar[] array, int index)
1487 {
1488 CopyTranspose(array, index, out this);
1489 }
1490
1491
1492
1493 private string ToStringInternal(string FormatString)
1494 {
1495 return string.Format(FormatString,
1496 m00, m01, m02,
1497 m10, m11, m12,
1498 m20, m21, m22);
1499 }
1500 public string ToString(string format)
1501 {
1502 return ToStringInternal(string.Format(FormatableString, format));
1503 }
1504 public override string ToString()
1505 {
1507 }
1508
1509 public override int GetHashCode()
1510 {
1511 return
1512 m00.GetHashCode() ^ m01.GetHashCode() ^ m02.GetHashCode() ^
1513 m10.GetHashCode() ^ m11.GetHashCode() ^ m12.GetHashCode() ^
1514 m20.GetHashCode() ^ m21.GetHashCode() ^ m22.GetHashCode();
1515 }
1516
1517 public override bool Equals(object obj)
1518 {
1519 return
1520 (obj is Matrix3x3) &&
1521 Equals((Matrix3x3)obj);
1522 }
1523 public bool Equals(Matrix3x3 other)
1524 {
1525 return Equals(ref this, ref other);
1526 }
1527
1528 #endregion
1529 #region Indexors
1530#if UNSAFE
1538 public Scalar this[int rowIndex, int columnIndex]
1539 {
1540 get
1541 {
1542 ThrowHelper.CheckIndex("rowIndex", rowIndex, RowCount);
1543 ThrowHelper.CheckIndex("columnIndex", columnIndex, ColumnCount);
1544 unsafe
1545 {
1546 fixed (Scalar* pM = &m00)
1547 {
1548 return pM[(ColumnCount * rowIndex) + columnIndex];
1549 }
1550 }
1551 }
1552 set
1553 {
1554 ThrowHelper.CheckIndex("rowIndex", rowIndex, RowCount);
1555 ThrowHelper.CheckIndex("columnIndex", columnIndex, ColumnCount);
1556 unsafe
1557 {
1558 fixed (Scalar* pM = &m00)
1559 {
1560 pM[(ColumnCount * rowIndex) + columnIndex] = value;
1561 }
1562 }
1563 }
1564 }
1572 public Scalar this[int index]
1573 {
1574 get
1575 {
1576 ThrowHelper.CheckIndex("index", index, Count);
1577 unsafe
1578 {
1579 fixed (Scalar* pMatrix = &this.m00)
1580 {
1581 return pMatrix[index];
1582 }
1583 }
1584 }
1585 set
1586 {
1587 ThrowHelper.CheckIndex("index", index, Count);
1588 unsafe
1589 {
1590 fixed (Scalar* pMatrix = &this.m00)
1591 {
1592 pMatrix[index] = value;
1593 }
1594 }
1595 }
1596 }
1597#endif
1598 #endregion
1599 #region Operator overloads
1606 public static Matrix3x3 operator *(Matrix3x3 left, Matrix3x3 right)
1607 {
1608
1609 Matrix3x3 result;
1610
1611 result.m00 = left.m00 * right.m00 + left.m01 * right.m10 + left.m02 * right.m20;
1612 result.m01 = left.m00 * right.m01 + left.m01 * right.m11 + left.m02 * right.m21;
1613 result.m02 = left.m00 * right.m02 + left.m01 * right.m12 + left.m02 * right.m22;
1614
1615 result.m10 = left.m10 * right.m00 + left.m11 * right.m10 + left.m12 * right.m20;
1616 result.m11 = left.m10 * right.m01 + left.m11 * right.m11 + left.m12 * right.m21;
1617 result.m12 = left.m10 * right.m02 + left.m11 * right.m12 + left.m12 * right.m22;
1618
1619 result.m20 = left.m20 * right.m00 + left.m21 * right.m10 + left.m22 * right.m20;
1620 result.m21 = left.m20 * right.m01 + left.m21 * right.m11 + left.m22 * right.m21;
1621 result.m22 = left.m20 * right.m02 + left.m21 * right.m12 + left.m22 * right.m22;
1622
1623 return result;
1624 }
1631 public static Matrix3x3 operator *(Matrix2x2 left, Matrix3x3 right)
1632 {
1633
1634 Matrix3x3 result;
1635
1636 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
1637 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
1638 result.m02 = left.m00 * right.m02 + left.m01 * right.m12;
1639
1640 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
1641 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
1642 result.m12 = left.m10 * right.m02 + left.m11 * right.m12;
1643
1644 result.m20 = right.m20;
1645 result.m21 = right.m21;
1646 result.m22 = right.m22;
1647
1648 return result;
1649 }
1656 public static Matrix3x3 operator *(Matrix3x3 left, Matrix2x2 right)
1657 {
1658
1659 Matrix3x3 result;
1660
1661 result.m00 = left.m00 * right.m00 + left.m01 * right.m10;
1662 result.m01 = left.m00 * right.m01 + left.m01 * right.m11;
1663 result.m02 = left.m02;
1664
1665 result.m10 = left.m10 * right.m00 + left.m11 * right.m10;
1666 result.m11 = left.m10 * right.m01 + left.m11 * right.m11;
1667 result.m12 = left.m12;
1668
1669 result.m20 = left.m20 * right.m00 + left.m21 * right.m10;
1670 result.m21 = left.m20 * right.m01 + left.m21 * right.m11;
1671 result.m22 = left.m22;
1672
1673 return result;
1674 }
1675
1682 public static Matrix3x3 operator *(Matrix3x3 matrix, Scalar scalar)
1683 {
1684 Matrix3x3 result;
1685
1686 result.m00 = matrix.m00 * scalar;
1687 result.m01 = matrix.m01 * scalar;
1688 result.m02 = matrix.m02 * scalar;
1689 result.m10 = matrix.m10 * scalar;
1690 result.m11 = matrix.m11 * scalar;
1691 result.m12 = matrix.m12 * scalar;
1692 result.m20 = matrix.m20 * scalar;
1693 result.m21 = matrix.m21 * scalar;
1694 result.m22 = matrix.m22 * scalar;
1695
1696 return result;
1697 }
1704 public static Matrix3x3 operator *(Scalar scalar, Matrix3x3 matrix)
1705 {
1706 Matrix3x3 result;
1707
1708 result.m00 = matrix.m00 * scalar;
1709 result.m01 = matrix.m01 * scalar;
1710 result.m02 = matrix.m02 * scalar;
1711 result.m10 = matrix.m10 * scalar;
1712 result.m11 = matrix.m11 * scalar;
1713 result.m12 = matrix.m12 * scalar;
1714 result.m20 = matrix.m20 * scalar;
1715 result.m21 = matrix.m21 * scalar;
1716 result.m22 = matrix.m22 * scalar;
1717
1718 return result;
1719 }
1726 public static Matrix3x3 operator +(Matrix3x3 left, Matrix3x3 right)
1727 {
1728 Matrix3x3 result;
1729
1730 result.m00 = left.m00 + right.m00;
1731 result.m01 = left.m01 + right.m01;
1732 result.m02 = left.m02 + right.m02;
1733
1734 result.m10 = left.m10 + right.m10;
1735 result.m11 = left.m11 + right.m11;
1736 result.m12 = left.m12 + right.m12;
1737
1738 result.m20 = left.m20 + right.m20;
1739 result.m21 = left.m21 + right.m21;
1740 result.m22 = left.m22 + right.m22;
1741
1742 return result;
1743 }
1744 public static Matrix3x3 operator +(Matrix2x2 left, Matrix3x3 right)
1745 {
1746 Matrix3x3 result;
1747 Add(ref left, ref right, out result);
1748 return result;
1749 }
1750 public static Matrix3x3 operator +(Matrix3x3 left, Matrix2x2 right)
1751 {
1752 Matrix3x3 result;
1753 Add(ref left, ref right, out result);
1754 return result;
1755 }
1762 public static Matrix3x3 operator -(Matrix3x3 left, Matrix3x3 right)
1763 {
1764 Matrix3x3 result;
1765
1766 result.m00 = left.m00 - right.m00;
1767 result.m01 = left.m01 - right.m01;
1768 result.m02 = left.m02 - right.m02;
1769
1770 result.m10 = left.m10 - right.m10;
1771 result.m11 = left.m11 - right.m11;
1772 result.m12 = left.m12 - right.m12;
1773
1774 result.m20 = left.m20 - right.m20;
1775 result.m21 = left.m21 - right.m21;
1776 result.m22 = left.m22 - right.m22;
1777
1778 return result;
1779 }
1780 public static Matrix3x3 operator -(Matrix2x2 left, Matrix3x3 right)
1781 {
1782 Matrix3x3 result;
1783 Subtract(ref left, ref right, out result);
1784 return result;
1785 }
1786 public static Matrix3x3 operator -(Matrix3x3 left, Matrix2x2 right)
1787 {
1788 Matrix3x3 result;
1789 Subtract(ref left, ref right, out result);
1790 return result;
1791 }
1797 public static Matrix3x3 operator -(Matrix3x3 matrix)
1798 {
1799 Matrix3x3 result;
1800
1801 result.m00 = -matrix.m00;
1802 result.m01 = -matrix.m01;
1803 result.m02 = -matrix.m02;
1804 result.m10 = -matrix.m10;
1805 result.m11 = -matrix.m11;
1806 result.m12 = -matrix.m12;
1807 result.m20 = -matrix.m20;
1808 result.m21 = -matrix.m21;
1809 result.m22 = -matrix.m22;
1810
1811 return result;
1812 }
1819 public static bool operator ==(Matrix3x3 left, Matrix3x3 right)
1820 {
1821 return
1822 left.m00 == right.m00 && left.m01 == right.m01 && left.m02 == right.m02 &&
1823 left.m10 == right.m10 && left.m11 == right.m11 && left.m12 == right.m12 &&
1824 left.m20 == right.m20 && left.m21 == right.m21 && left.m22 == right.m22;
1825 }
1826 public static bool operator !=(Matrix3x3 left, Matrix3x3 right)
1827 {
1828 return !(left == right);
1829 }
1830
1831
1832 public static explicit operator Matrix3x3(Matrix4x4 source)
1833 {
1834 Matrix3x3 result;
1835
1836 result.m00 = source.m00;
1837 result.m01 = source.m01;
1838 result.m02 = source.m02;
1839
1840 result.m10 = source.m10;
1841 result.m11 = source.m11;
1842 result.m12 = source.m12;
1843
1844 result.m20 = source.m20;
1845 result.m21 = source.m21;
1846 result.m22 = source.m22;
1847
1848 return result;
1849 }
1850 public static explicit operator Matrix3x3(Matrix2x2 source)
1851 {
1852 Matrix3x3 result;
1853
1854 result.m00 = source.m00;
1855 result.m01 = source.m01;
1856 result.m02 = 0;
1857
1858 result.m10 = source.m10;
1859 result.m11 = source.m11;
1860 result.m12 = 0;
1861
1862 result.m20 = 0;
1863 result.m21 = 0;
1864 result.m22 = 1;
1865
1866
1867
1868
1869
1870 return result;
1871 }
1872
1873 #endregion
1874 }
1875}
System.Single Scalar
Definition: Clamped.cs:29
System.Single Scalar
Definition: Matrix3x3.cs:27
static Scalar Cos(Scalar d)
Definition: MathHelper.cs:302
static Scalar Sin(Scalar a)
Definition: MathHelper.cs:312
const Scalar PiOver2
Definition: MathHelper.cs:43
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 3x3 matrix which can represent rotations around axes.
Definition: Matrix3x3.cs:62
static void Subtract(ref Matrix3x3 left, ref Matrix2x2 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:582
static readonly string FormatString
Definition: Matrix3x3.cs:82
void CopyTransposedTo(Scalar[] array, int index)
Definition: Matrix3x3.cs:1478
static void Add(ref Matrix2x2 left, ref Matrix3x3 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:479
static void Subtract(ref Matrix2x2 left, ref Matrix3x3 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:562
static void Multiply(ref Matrix3x3 left, ref Matrix2x2 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:358
Matrix3x3(Scalar m00, Scalar m01, Scalar m02, Scalar m10, Scalar m11, Scalar m12, Scalar m20, Scalar m21, Scalar m22)
Creates a new Matrix3 with all the specified parameters.
Definition: Matrix3x3.cs:1193
void SetColumn(int columnIndex, Vector3D value)
Definition: Matrix3x3.cs:1397
static void FromScale(ref Vector3D scale, out Matrix3x3 result)
Definition: Matrix3x3.cs:998
void CopyTo(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType to the specified one-dimensional Array of Scalar.
Definition: Matrix3x3.cs:1474
static void Invert(ref Matrix3x3 source, out Matrix3x3 result)
Definition: Matrix3x3.cs:645
void SetRow(int rowIndex, Vector3D value)
Definition: Matrix3x3.cs:1427
static readonly string FormatableString
Definition: Matrix3x3.cs:83
static void FromRotationX(ref Scalar radianAngle, out Matrix3x3 result)
Definition: Matrix3x3.cs:846
Matrix3x3(Scalar[] values, int index)
Definition: Matrix3x3.cs:1216
static void CopyTranspose(ref Matrix3x3 matrix, Scalar[] destArray, int index)
Definition: Matrix3x3.cs:141
static void GetDeterminant(ref Matrix3x3 source, out Scalar result)
Definition: Matrix3x3.cs:687
static Matrix3x3 FromEulerAnglesXYZ(Scalar yaw, Scalar pitch, Scalar roll)
Constructs this Matrix from 3 euler angles, in degrees.
Definition: Matrix3x3.cs:1138
static Matrix3x3 Invert(Matrix3x3 source)
Definition: Matrix3x3.cs:639
static Matrix3x3 operator+(Matrix3x3 left, Matrix3x3 right)
Used to add two matrices together.
Definition: Matrix3x3.cs:1726
static Matrix3x3 Multiply(Matrix3x3 left, Scalar scalar)
Used to multiply a Matrix3x3 object by a scalar value..
Definition: Matrix3x3.cs:300
static void FromTranslate2D(ref Vector2D value, out Matrix3x3 result)
Definition: Matrix3x3.cs:1060
static void Multiply(ref Matrix2x2 left, ref Matrix3x3 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:408
static void Transpose(ref Matrix3x3 source, out Matrix3x3 result)
Definition: Matrix3x3.cs:702
static Matrix3x3 Transpose(Matrix3x3 source)
Definition: Matrix3x3.cs:696
static Matrix3x3 GetCofactor(Matrix3x3 source)
Definition: Matrix3x3.cs:758
Matrix3x3 Transposed
Swap the rows of the matrix with the columns.
Definition: Matrix3x3.cs:1342
static void GetAdjoint(ref Matrix3x3 source, out Matrix3x3 result)
Definition: Matrix3x3.cs:730
int IMatrix. RowCount
Definition: Matrix3x3.cs:1379
static Matrix3x3 Add(Matrix2x2 left, Matrix3x3 right)
Definition: Matrix3x3.cs:473
static Matrix3x3 Multiply(Matrix2x2 left, Matrix3x3 right)
Used to multiply (concatenate) a Matrix3x3 and a Matrix2x2.
Definition: Matrix3x3.cs:388
static void FromRotationY(ref Scalar radianAngle, out Matrix3x3 result)
Definition: Matrix3x3.cs:882
int IMatrix. ColumnCount
Definition: Matrix3x3.cs:1380
static readonly Matrix3x3 Identity
Definition: Matrix3x3.cs:85
static Matrix3x3 Subtract(Matrix3x3 left, Matrix3x3 right)
Used to subtract two matrices.
Definition: Matrix3x3.cs:522
Vector3D GetColumn(int columnIndex)
Definition: Matrix3x3.cs:1384
static void Multiply(ref Matrix3x3 left, ref Matrix3x3 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:266
override int GetHashCode()
Definition: Matrix3x3.cs:1509
override bool Equals(object obj)
Definition: Matrix3x3.cs:1517
static Matrix3x3 FromRotationZ(Scalar radianAngle)
Definition: Matrix3x3.cs:899
static Matrix3x3 Add(Matrix3x3 left, Matrix2x2 right)
Definition: Matrix3x3.cs:493
string ToString(string format)
turns the object into a string representation of itself with a special format for each Scaler in it.
Definition: Matrix3x3.cs:1500
Scalar[,] ToMatrixArray()
Definition: Matrix3x3.cs:1444
static Matrix3x3 operator*(Matrix3x3 left, Matrix3x3 right)
Multiply (concatenate) two Matrix3 instances together.
Definition: Matrix3x3.cs:1606
static bool TryParse(string s, out Matrix3x3 result)
Definition: Matrix3x3.cs:1151
static Matrix3x3 FromScale(Vector2D scale)
Definition: Matrix3x3.cs:1012
Matrix3x3(Vector3D xAxis, Vector3D yAxis, Vector3D zAxis)
Create a new Matrix from 3 Vertex3 objects.
Definition: Matrix3x3.cs:1209
static Matrix3x3 Negate(Matrix3x3 source)
Negates a Matrix3x3.
Definition: Matrix3x3.cs:601
static void FromShear3D(ref Vector2D value, out Matrix3x3 result)
Definition: Matrix3x3.cs:1092
static void FromScale(ref Vector2D scale, out Matrix3x3 result)
Definition: Matrix3x3.cs:1028
string ToStringInternal(string FormatString)
Definition: Matrix3x3.cs:1493
static Matrix3x3 FromRotationX(Scalar radianAngle)
Definition: Matrix3x3.cs:826
int IAdvanceValueType. Count
Definition: Matrix3x3.cs:1378
static void Negate(ref Matrix3x3 source)
Definition: Matrix3x3.cs:620
static void Add(ref Matrix3x3 left, ref Matrix2x2 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:499
static readonly Matrix3x3 Zero
Definition: Matrix3x3.cs:89
static bool Equals(Matrix3x3 left, Matrix3x3 right)
Definition: Matrix3x3.cs:1159
static void Copy2DToOpenGlMatrix(ref Matrix3x3 source, Scalar[] destArray)
Definition: Matrix3x3.cs:201
Matrix4x4 ToMatrix4x4()
Definition: Matrix3x3.cs:1465
static void FromTransformation(ref Scalar rotation, ref Vector2D translation, out Matrix3x3 result)
Definition: Matrix3x3.cs:813
static void Copy(ref Matrix3x3 matrix, Scalar[] destArray, int index)
Definition: Matrix3x3.cs:100
static Matrix3x3 FromTransposedArray(Scalar[] array)
Definition: Matrix3x3.cs:800
static Scalar GetDeterminant(Matrix3x3 source)
Definition: Matrix3x3.cs:681
static void CopyTranspose(ref Matrix3x3 matrix, Scalar[] destArray)
Definition: Matrix3x3.cs:137
static void Copy(ref Matrix4x4 source, out Matrix3x3 dest)
Definition: Matrix3x3.cs:178
static Matrix3x3 Parse(string s)
Definition: Matrix3x3.cs:1144
Vector3D GetRow(int rowIndex)
Definition: Matrix3x3.cs:1414
void CopyTransposedFrom(Scalar[] array, int index)
Definition: Matrix3x3.cs:1486
static Matrix3x3 Add(Matrix3x3 left, Matrix3x3 right)
Used to add two matrices together.
Definition: Matrix3x3.cs:440
static void CopyTranspose(Scalar[] sourceArray, out Matrix3x3 result)
Definition: Matrix3x3.cs:157
const int RowCount
The number of rows.
Definition: Matrix3x3.cs:67
static Matrix3x3 FromScale(Vector3D scale)
Definition: Matrix3x3.cs:980
const int Count
The number of Scalar values in the class.
Definition: Matrix3x3.cs:75
Scalar[] ToArray()
Copies the elements of the IAdvanceValueType to a new array of Scalar .
Definition: Matrix3x3.cs:1448
static void Subtract(ref Matrix3x3 left, ref Matrix3x3 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:540
static Matrix3x3 FromArray(Scalar[] array)
Definition: Matrix3x3.cs:794
static Matrix3x3 Subtract(Matrix2x2 left, Matrix3x3 right)
Definition: Matrix3x3.cs:556
static void CopyTranspose(Scalar[] sourceArray, int index, out Matrix3x3 result)
Definition: Matrix3x3.cs:161
static void Copy(ref Matrix2x2 source, ref Matrix3x3 dest)
Definition: Matrix3x3.cs:192
static Matrix3x3 operator-(Matrix3x3 left, Matrix3x3 right)
Used to subtract two matrices.
Definition: Matrix3x3.cs:1762
static Matrix3x3 Multiply(Matrix3x3 left, Matrix3x3 right)
Used to multiply (concatenate) two Matrix4x4s.
Definition: Matrix3x3.cs:248
static void GetCofactor(ref Matrix3x3 source, out Matrix3x3 result)
Definition: Matrix3x3.cs:764
static Matrix3x3 FromLookAt(Vector3D origin, Vector3D positiveZAxis, Vector3D onPositiveY)
Definition: Matrix3x3.cs:970
static Matrix3x3 FromTransformation(Scalar rotation, Vector2D translation)
Definition: Matrix3x3.cs:807
static void Copy(ref Matrix3x3 matrix, Scalar[] destArray)
Definition: Matrix3x3.cs:96
static Matrix3x3 Subtract(Matrix3x3 left, Matrix2x2 right)
Definition: Matrix3x3.cs:576
Matrix3x3(Scalar[] values)
Definition: Matrix3x3.cs:1215
static void Multiply(ref Matrix3x3 left, ref Scalar scalar, out Matrix3x3 result)
Definition: Matrix3x3.cs:318
static Matrix3x3 FromShear3D(Vector2D value)
Definition: Matrix3x3.cs:1074
static bool Equals(ref Matrix3x3 left, ref Matrix3x3 right)
Definition: Matrix3x3.cs:1166
const int ColumnCount
The number of columns.
Definition: Matrix3x3.cs:71
static Matrix3x3 GetAdjoint(Matrix3x3 source)
Definition: Matrix3x3.cs:724
static bool operator==(Matrix3x3 left, Matrix3x3 right)
Test two matrices for (value) equality
Definition: Matrix3x3.cs:1819
static Matrix3x3 FromRotationY(Scalar radianAngle)
Definition: Matrix3x3.cs:862
static void Add(ref Matrix3x3 left, ref Matrix3x3 right, out Matrix3x3 result)
Definition: Matrix3x3.cs:458
static Matrix3x3 Lerp(Matrix3x3 left, Matrix3x3 right, Scalar amount)
Definition: Matrix3x3.cs:220
void CopyFrom(Scalar[] array, int index)
Copies all the elements of the IAdvanceValueType, of the specified one-dimensional Array to the IAdva...
Definition: Matrix3x3.cs:1482
override string ToString()
Definition: Matrix3x3.cs:1504
static Matrix3x3 FromRotationAxis(Scalar radianAngle, Vector3D axis)
Definition: Matrix3x3.cs:965
static void Negate(ref Matrix3x3 source, out Matrix3x3 result)
Definition: Matrix3x3.cs:624
const int Size
The Size of the class in bytes;
Definition: Matrix3x3.cs:79
static bool operator!=(Matrix3x3 left, Matrix3x3 right)
Definition: Matrix3x3.cs:1826
static void FromRotationZ(ref Scalar radianAngle, out Matrix3x3 result)
Definition: Matrix3x3.cs:919
static Matrix3x3 Multiply(Matrix3x3 left, Matrix2x2 right)
Used to multiply (concatenate) a Matrix3x3 and a Matrix2x2.
Definition: Matrix3x3.cs:340
static void Copy(Scalar[] sourceArray, out Matrix3x3 result)
Definition: Matrix3x3.cs:116
static Scalar GetDeterminant(Vector3D Rx, Vector3D Ry, Vector3D Rz)
Definition: Matrix3x3.cs:1120
static Matrix3x3 FromRotationAxisUsingAtan(Scalar radianAngle, Vector3D axis)
Definition: Matrix3x3.cs:937
static Scalar GetDeterminant(Scalar m00, Scalar m01, Scalar m02, Scalar m10, Scalar m11, Scalar m12, Scalar m20, Scalar m21, Scalar m22)
Definition: Matrix3x3.cs:1107
bool Equals(Matrix3x3 other)
Definition: Matrix3x3.cs:1523
Matrix4x4 ToMatrix4x4From2D()
Definition: Matrix3x3.cs:1457
static void Lerp(ref Matrix3x3 left, ref Matrix3x3 right, ref Scalar amount, out Matrix3x3 result)
Definition: Matrix3x3.cs:226
Scalar[] ToTransposedArray()
Definition: Matrix3x3.cs:1452
static Matrix3x3 FromTranslate2D(Vector2D value)
Definition: Matrix3x3.cs:1042
static void Copy(Scalar[] sourceArray, int index, out Matrix3x3 result)
Definition: Matrix3x3.cs:120
static readonly Matrix4x4 Identity
Definition: Matrix4x4.cs:72
This is the Vector Class.
Definition: Vector2D.cs:50
Scalar X
This is the X value. (Usually represents a horizontal position or direction.)
Definition: Vector2D.cs:796
Scalar Y
This is the Y value. (Usually represents a vertical position or direction.)
Definition: Vector2D.cs:805
A Vector with 3 dimensions.
Definition: Vector3D.cs:47
Scalar X
This is the X value.
Definition: Vector3D.cs:692
static Vector3D Normalize(Vector3D source)
This returns the Normalized Vector3D that is passed. This is also known as a Unit Vector.
Definition: Vector3D.cs:542
static readonly Vector3D Zero
Vector3D(0,0,0)
Definition: Vector3D.cs:66
Scalar Y
This is the Y value.
Definition: Vector3D.cs:701
Scalar Z
This is the Z value.
Definition: Vector3D.cs:710