30 using System.Collections.Generic;
31 using System.Runtime.CompilerServices;
32 using System.Security;
34 using System.Runtime.InteropServices;
35 using System.ComponentModel;
36 using System.Globalization;
37 using SiliconStudio.Core.Serialization;
39 namespace SiliconStudio.Core.Mathematics
44 [DataContract(
"float4x4")]
46 [StructLayout(LayoutKind.Sequential, Pack = 4)]
49 #if SILICONSTUDIO_PLATFORM_ANDROID
57 public static readonly
int SizeInBytes = Marshal.SizeOf(typeof(
Matrix));
67 public static readonly
Matrix Identity =
new Matrix() { M11 = 1.0f, M22 = 1.0f, M33 = 1.0f, M44 = 1.0f };
155 M11 = M21 = M31 = M41 =
156 M12 = M22 = M32 = M42 =
157 M13 = M23 = M33 = M43 =
158 M14 = M24 = M34 = M44 = value;
180 public Matrix(
float M11,
float M12,
float M13,
float M14,
181 float M21,
float M22,
float M23,
float M24,
182 float M31,
float M32,
float M33,
float M34,
183 float M41,
float M42,
float M43,
float M44)
185 this.M11 = M11; this.M12 = M12; this.M13 = M13; this.M14 = M14;
186 this.M21 = M21; this.M22 = M22; this.M23 = M23; this.M24 = M24;
187 this.M31 = M31; this.M32 = M32; this.M33 = M33; this.M34 = M34;
188 this.M41 = M41; this.M42 = M42; this.M43 = M43; this.M44 = M44;
200 throw new ArgumentNullException(
"values");
201 if (values.Length != 16)
202 throw new ArgumentOutOfRangeException(
"values",
"There must be sixteen and only sixteen input values for Matrix.");
231 get {
return new Vector4(M11, M12, M13, M14); }
232 set { M11 = value.X; M12 = value.Y; M13 = value.Z; M14 = value.W; }
241 get {
return new Vector4(M21, M22, M23, M24); }
242 set { M21 = value.X; M22 = value.Y; M23 = value.Z; M24 = value.W; }
251 get {
return new Vector4(M31, M32, M33, M34); }
252 set { M31 = value.X; M32 = value.Y; M33 = value.Z; M34 = value.W; }
261 get {
return new Vector4(M41, M42, M43, M44); }
262 set { M41 = value.X; M42 = value.Y; M43 = value.Z; M44 = value.W; }
271 get {
return new Vector4(M11, M21, M31, M41); }
272 set { M11 = value.X; M21 = value.Y; M31 = value.Z; M41 = value.W; }
281 get {
return new Vector4(M12, M22, M32, M42); }
282 set { M12 = value.X; M22 = value.Y; M32 = value.Z; M42 = value.W; }
291 get {
return new Vector4(M13, M23, M33, M43); }
292 set { M13 = value.X; M23 = value.Y; M33 = value.Z; M43 = value.W; }
301 get {
return new Vector4(M14, M24, M34, M44); }
302 set { M14 = value.X; M24 = value.Y; M34 = value.Z; M44 = value.W; }
309 public Vector3 TranslationVector
311 get {
return new Vector3(M41, M42, M43); }
312 set { M41 = value.X; M42 = value.Y; M43 = value.Z; }
321 get {
return new Vector3(M11, M22, M33); }
322 set { M11 = value.X; M22 = value.Y; M33 = value.Z; }
331 public bool IsIdentity
333 get {
return this.Equals(Identity); }
343 public float this[
int index]
367 throw new ArgumentOutOfRangeException(
"index",
"Indices for Matrix run from 0 to 15, inclusive.");
374 case 0: M11 = value;
break;
375 case 1: M12 = value;
break;
376 case 2: M13 = value;
break;
377 case 3: M14 = value;
break;
378 case 4: M21 = value;
break;
379 case 5: M22 = value;
break;
380 case 6: M23 = value;
break;
381 case 7: M24 = value;
break;
382 case 8: M31 = value;
break;
383 case 9: M32 = value;
break;
384 case 10: M33 = value;
break;
385 case 11: M34 = value;
break;
386 case 12: M41 = value;
break;
387 case 13: M42 = value;
break;
388 case 14: M43 = value;
break;
389 case 15: M44 = value;
break;
390 default:
throw new ArgumentOutOfRangeException(
"index",
"Indices for Matrix run from 0 to 15, inclusive.");
403 public float this[
int row,
int column]
407 if (row < 0 || row > 3)
408 throw new ArgumentOutOfRangeException(
"row",
"Rows and columns for matrices run from 0 to 3, inclusive.");
409 if (column < 0 || column > 3)
410 throw new ArgumentOutOfRangeException(
"column",
"Rows and columns for matrices run from 0 to 3, inclusive.");
412 return this[(row * 4) + column];
417 if (row < 0 || row > 3)
418 throw new ArgumentOutOfRangeException(
"row",
"Rows and columns for matrices run from 0 to 3, inclusive.");
419 if (column < 0 || column > 3)
420 throw new ArgumentOutOfRangeException(
"column",
"Rows and columns for matrices run from 0 to 3, inclusive.");
422 this[(row * 4) + column] = value;
432 float temp1 = (M33 * M44) - (M34 * M43);
433 float temp2 = (M32 * M44) - (M34 * M42);
434 float temp3 = (M32 * M43) - (M33 * M42);
435 float temp4 = (M31 * M44) - (M34 * M41);
436 float temp5 = (M31 * M43) - (M33 * M41);
437 float temp6 = (M31 * M42) - (M32 * M41);
439 return ((((M11 * (((M22 * temp1) - (M23 * temp2)) + (M24 * temp3))) - (M12 * (((M21 * temp1) -
440 (M23 * temp4)) + (M24 * temp5)))) + (M13 * (((M21 * temp2) - (M22 * temp4)) + (M24 * temp6)))) -
441 (M14 * (((M21 * temp3) - (M22 * temp5)) + (M23 * temp6))));
449 Invert(ref
this, out
this);
457 Transpose(ref
this, out
this);
476 Orthogonalize(ref
this, out
this);
497 Orthonormalize(ref
this, out
this);
509 Orthonormalize(ref temp, out Q);
513 R.M11 = Vector4.Dot(Q.Column1, Column1);
514 R.M12 = Vector4.Dot(Q.Column1, Column2);
515 R.M13 = Vector4.Dot(Q.Column1, Column3);
516 R.M14 = Vector4.Dot(Q.Column1, Column4);
518 R.M22 = Vector4.Dot(Q.Column2, Column2);
519 R.M23 = Vector4.Dot(Q.Column2, Column3);
520 R.M24 = Vector4.Dot(Q.Column2, Column4);
522 R.M33 = Vector4.Dot(Q.Column3, Column3);
523 R.M34 = Vector4.Dot(Q.Column3, Column4);
525 R.M44 = Vector4.Dot(Q.Column4, Column4);
535 Orthonormalize(ref
this, out Q);
538 L.M11 = Vector4.Dot(Q.Row1, Row1);
540 L.M21 = Vector4.Dot(Q.Row1, Row2);
541 L.M22 = Vector4.Dot(Q.Row2, Row2);
543 L.M31 = Vector4.Dot(Q.Row1, Row3);
544 L.M32 = Vector4.Dot(Q.Row2, Row3);
545 L.M33 = Vector4.Dot(Q.Row3, Row3);
547 L.M41 = Vector4.Dot(Q.Row1, Row4);
548 L.M42 = Vector4.Dot(Q.Row2, Row4);
549 L.M43 = Vector4.Dot(Q.Row3, Row4);
550 L.M44 = Vector4.Dot(Q.Row4, Row4);
559 public void Decompose(out
float yaw, out
float pitch, out
float roll)
561 pitch = (float)Math.Asin(-M32);
564 double test = Math.Cos(pitch);
567 roll = (float)Math.Atan2(M12, M22);
568 yaw = (float)Math.Atan2(M31, M33);
572 roll = (float)Math.Atan2(-M21, M11);
584 rotation.Y = (float)Math.Asin(-M13);
585 double test = Math.Cos(rotation.Y);
588 rotation.Z = (float)Math.Atan2(M12, M11);
589 rotation.X = (float)Math.Atan2(M23, M33);
593 rotation.Z = (float)Math.Atan2(-M21, M31);
613 translation.X = this.M41;
614 translation.Y = this.M42;
615 translation.Z = this.M43;
618 scale.X = (float)Math.Sqrt((M11 * M11) + (M12 * M12) + (M13 * M13));
619 scale.Y = (float)Math.Sqrt((M21 * M21) + (M22 * M22) + (M23 * M23));
620 scale.Z = (float)Math.Sqrt((M31 * M31) + (M32 * M32) + (M33 * M33));
623 if (Math.Abs(scale.X) < MathUtil.ZeroTolerance ||
625 Math.Abs(scale.Z) < MathUtil.ZeroTolerance)
627 rotation = Quaternion.Identity;
633 rotationmatrix.M11 = M11 / scale.X;
634 rotationmatrix.M12 = M12 / scale.X;
635 rotationmatrix.M13 = M13 / scale.X;
637 rotationmatrix.M21 = M21 / scale.Y;
638 rotationmatrix.M22 = M22 / scale.Y;
639 rotationmatrix.M23 = M23 / scale.Y;
641 rotationmatrix.M31 = M31 / scale.Z;
642 rotationmatrix.M32 = M32 / scale.Z;
643 rotationmatrix.M33 = M33 / scale.Z;
645 rotationmatrix.M44 = 1f;
647 Quaternion.RotationMatrix(ref rotationmatrix, out rotation);
659 throw new ArgumentOutOfRangeException(
"firstRow",
"The parameter firstRow must be greater than or equal to zero.");
661 throw new ArgumentOutOfRangeException(
"firstRow",
"The parameter firstRow must be less than or equal to three.");
663 throw new ArgumentOutOfRangeException(
"secondRow",
"The parameter secondRow must be greater than or equal to zero.");
665 throw new ArgumentOutOfRangeException(
"secondRow",
"The parameter secondRow must be less than or equal to three.");
667 if (firstRow == secondRow)
670 float temp0 =
this[secondRow, 0];
671 float temp1 =
this[secondRow, 1];
672 float temp2 =
this[secondRow, 2];
673 float temp3 =
this[secondRow, 3];
675 this[secondRow, 0] =
this[firstRow, 0];
676 this[secondRow, 1] =
this[firstRow, 1];
677 this[secondRow, 2] =
this[firstRow, 2];
678 this[secondRow, 3] =
this[firstRow, 3];
680 this[firstRow, 0] = temp0;
681 this[firstRow, 1] = temp1;
682 this[firstRow, 2] = temp2;
683 this[firstRow, 3] = temp3;
694 throw new ArgumentOutOfRangeException(
"firstColumn",
"The parameter firstColumn must be greater than or equal to zero.");
696 throw new ArgumentOutOfRangeException(
"firstColumn",
"The parameter firstColumn must be less than or equal to three.");
697 if (secondColumn < 0)
698 throw new ArgumentOutOfRangeException(
"secondColumn",
"The parameter secondColumn must be greater than or equal to zero.");
699 if (secondColumn > 3)
700 throw new ArgumentOutOfRangeException(
"secondColumn",
"The parameter secondColumn must be less than or equal to three.");
702 if (firstColumn == secondColumn)
705 float temp0 =
this[0, secondColumn];
706 float temp1 =
this[1, secondColumn];
707 float temp2 =
this[2, secondColumn];
708 float temp3 =
this[3, secondColumn];
710 this[0, secondColumn] =
this[0, firstColumn];
711 this[1, secondColumn] =
this[1, firstColumn];
712 this[2, secondColumn] =
this[2, firstColumn];
713 this[3, secondColumn] =
this[3, firstColumn];
715 this[0, firstColumn] = temp0;
716 this[1, firstColumn] = temp1;
717 this[2, firstColumn] = temp2;
718 this[3, firstColumn] = temp3;
727 return new[] { M11, M12, M13, M14, M21, M22, M23, M24, M31, M32, M33, M34, M41, M42, M43, M44 };
738 result.M11 = left.M11 + right.M11;
739 result.M21 = left.M21 + right.M21;
740 result.M31 = left.M31 + right.M31;
741 result.M41 = left.M41 + right.M41;
742 result.M12 = left.M12 + right.M12;
743 result.M22 = left.M22 + right.M22;
744 result.M32 = left.M32 + right.M32;
745 result.M42 = left.M42 + right.M42;
746 result.M13 = left.M13 + right.M13;
747 result.M23 = left.M23 + right.M23;
748 result.M33 = left.M33 + right.M33;
749 result.M43 = left.M43 + right.M43;
750 result.M14 = left.M14 + right.M14;
751 result.M24 = left.M24 + right.M24;
752 result.M34 = left.M34 + right.M34;
753 result.M44 = left.M44 + right.M44;
765 Add(ref left, ref right, out result);
777 result.M11 = left.M11 - right.M11;
778 result.M21 = left.M21 - right.M21;
779 result.M31 = left.M31 - right.M31;
780 result.M41 = left.M41 - right.M41;
781 result.M12 = left.M12 - right.M12;
782 result.M22 = left.M22 - right.M22;
783 result.M32 = left.M32 - right.M32;
784 result.M42 = left.M42 - right.M42;
785 result.M13 = left.M13 - right.M13;
786 result.M23 = left.M23 - right.M23;
787 result.M33 = left.M33 - right.M33;
788 result.M43 = left.M43 - right.M43;
789 result.M14 = left.M14 - right.M14;
790 result.M24 = left.M24 - right.M24;
791 result.M34 = left.M34 - right.M34;
792 result.M44 = left.M44 - right.M44;
804 Subtract(ref left, ref right, out result);
816 result.M11 = left.M11 * right;
817 result.M21 = left.M21 * right;
818 result.M31 = left.M31 * right;
819 result.M41 = left.M41 * right;
820 result.M12 = left.M12 * right;
821 result.M22 = left.M22 * right;
822 result.M32 = left.M32 * right;
823 result.M42 = left.M42 * right;
824 result.M13 = left.M13 * right;
825 result.M23 = left.M23 * right;
826 result.M33 = left.M33 * right;
827 result.M43 = left.M43 * right;
828 result.M14 = left.M14 * right;
829 result.M24 = left.M24 * right;
830 result.M34 = left.M34 * right;
831 result.M44 = left.M44 * right;
843 Multiply(ref left, right, out result);
855 result.M11 = (left.M11 * right.M11) + (left.M12 * right.M21) + (left.M13 * right.M31) + (left.M14 * right.M41);
856 result.M21 = (left.M21 * right.M11) + (left.M22 * right.M21) + (left.M23 * right.M31) + (left.M24 * right.M41);
857 result.M31 = (left.M31 * right.M11) + (left.M32 * right.M21) + (left.M33 * right.M31) + (left.M34 * right.M41);
858 result.M41 = (left.M41 * right.M11) + (left.M42 * right.M21) + (left.M43 * right.M31) + (left.M44 * right.M41);
859 result.M12 = (left.M11 * right.M12) + (left.M12 * right.M22) + (left.M13 * right.M32) + (left.M14 * right.M42);
860 result.M22 = (left.M21 * right.M12) + (left.M22 * right.M22) + (left.M23 * right.M32) + (left.M24 * right.M42);
861 result.M32 = (left.M31 * right.M12) + (left.M32 * right.M22) + (left.M33 * right.M32) + (left.M34 * right.M42);
862 result.M42 = (left.M41 * right.M12) + (left.M42 * right.M22) + (left.M43 * right.M32) + (left.M44 * right.M42);
863 result.M13 = (left.M11 * right.M13) + (left.M12 * right.M23) + (left.M13 * right.M33) + (left.M14 * right.M43);
864 result.M23 = (left.M21 * right.M13) + (left.M22 * right.M23) + (left.M23 * right.M33) + (left.M24 * right.M43);
865 result.M33 = (left.M31 * right.M13) + (left.M32 * right.M23) + (left.M33 * right.M33) + (left.M34 * right.M43);
866 result.M43 = (left.M41 * right.M13) + (left.M42 * right.M23) + (left.M43 * right.M33) + (left.M44 * right.M43);
867 result.M14 = (left.M11 * right.M14) + (left.M12 * right.M24) + (left.M13 * right.M34) + (left.M14 * right.M44);
868 result.M24 = (left.M21 * right.M14) + (left.M22 * right.M24) + (left.M23 * right.M34) + (left.M24 * right.M44);
869 result.M34 = (left.M31 * right.M14) + (left.M32 * right.M24) + (left.M33 * right.M34) + (left.M34 * right.M44);
870 result.M44 = (left.M41 * right.M14) + (left.M42 * right.M24) + (left.M43 * right.M34) + (left.M44 * right.M44);
879 #if SILICONSTUDIO_PLATFORM_ANDROID
880 [MethodImpl(MethodImplOptions.AggressiveInlining)]
884 #if SILICONSTUDIO_PLATFORM_ANDROID
885 NEON_Matrix4Mul(ref left, ref right, out result);
887 result.M11 = (left.M11 * right.M11) + (left.M12 * right.M21) + (left.M13 * right.M31) + (left.M14 * right.M41);
888 result.M21 = (left.M21 * right.M11) + (left.M22 * right.M21) + (left.M23 * right.M31) + (left.M24 * right.M41);
889 result.M31 = (left.M31 * right.M11) + (left.M32 * right.M21) + (left.M33 * right.M31) + (left.M34 * right.M41);
890 result.M41 = (left.M41 * right.M11) + (left.M42 * right.M21) + (left.M43 * right.M31) + (left.M44 * right.M41);
891 result.M12 = (left.M11 * right.M12) + (left.M12 * right.M22) + (left.M13 * right.M32) + (left.M14 * right.M42);
892 result.M22 = (left.M21 * right.M12) + (left.M22 * right.M22) + (left.M23 * right.M32) + (left.M24 * right.M42);
893 result.M32 = (left.M31 * right.M12) + (left.M32 * right.M22) + (left.M33 * right.M32) + (left.M34 * right.M42);
894 result.M42 = (left.M41 * right.M12) + (left.M42 * right.M22) + (left.M43 * right.M32) + (left.M44 * right.M42);
895 result.M13 = (left.M11 * right.M13) + (left.M12 * right.M23) + (left.M13 * right.M33) + (left.M14 * right.M43);
896 result.M23 = (left.M21 * right.M13) + (left.M22 * right.M23) + (left.M23 * right.M33) + (left.M24 * right.M43);
897 result.M33 = (left.M31 * right.M13) + (left.M32 * right.M23) + (left.M33 * right.M33) + (left.M34 * right.M43);
898 result.M43 = (left.M41 * right.M13) + (left.M42 * right.M23) + (left.M43 * right.M33) + (left.M44 * right.M43);
899 result.M14 = (left.M11 * right.M14) + (left.M12 * right.M24) + (left.M13 * right.M34) + (left.M14 * right.M44);
900 result.M24 = (left.M21 * right.M14) + (left.M22 * right.M24) + (left.M23 * right.M34) + (left.M24 * right.M44);
901 result.M34 = (left.M31 * right.M14) + (left.M32 * right.M24) + (left.M33 * right.M34) + (left.M34 * right.M44);
902 result.M44 = (left.M41 * right.M14) + (left.M42 * right.M24) + (left.M43 * right.M34) + (left.M44 * right.M44);
914 result.M11 = (left.M11 * right.M11) + (left.M12 * right.M21) + (left.M13 * right.M31) + (left.M14 * right.M41);
915 result.M21 = (left.M21 * right.M11) + (left.M22 * right.M21) + (left.M23 * right.M31) + (left.M24 * right.M41);
916 result.M31 = (left.M31 * right.M11) + (left.M32 * right.M21) + (left.M33 * right.M31) + (left.M34 * right.M41);
917 result.M41 = (left.M41 * right.M11) + (left.M42 * right.M21) + (left.M43 * right.M31) + (left.M44 * right.M41);
918 result.M12 = (left.M11 * right.M12) + (left.M12 * right.M22) + (left.M13 * right.M32) + (left.M14 * right.M42);
919 result.M22 = (left.M21 * right.M12) + (left.M22 * right.M22) + (left.M23 * right.M32) + (left.M24 * right.M42);
920 result.M32 = (left.M31 * right.M12) + (left.M32 * right.M22) + (left.M33 * right.M32) + (left.M34 * right.M42);
921 result.M42 = (left.M41 * right.M12) + (left.M42 * right.M22) + (left.M43 * right.M32) + (left.M44 * right.M42);
922 result.M13 = (left.M11 * right.M13) + (left.M12 * right.M23) + (left.M13 * right.M33) + (left.M14 * right.M43);
923 result.M23 = (left.M21 * right.M13) + (left.M22 * right.M23) + (left.M23 * right.M33) + (left.M24 * right.M43);
924 result.M33 = (left.M31 * right.M13) + (left.M32 * right.M23) + (left.M33 * right.M33) + (left.M34 * right.M43);
925 result.M43 = (left.M41 * right.M13) + (left.M42 * right.M23) + (left.M43 * right.M33) + (left.M44 * right.M43);
926 result.M14 = (left.M11 * right.M14) + (left.M12 * right.M24) + (left.M13 * right.M34) + (left.M14 * right.M44);
927 result.M24 = (left.M21 * right.M14) + (left.M22 * right.M24) + (left.M23 * right.M34) + (left.M24 * right.M44);
928 result.M34 = (left.M31 * right.M14) + (left.M32 * right.M24) + (left.M33 * right.M34) + (left.M34 * right.M44);
929 result.M44 = (left.M41 * right.M14) + (left.M42 * right.M24) + (left.M43 * right.M34) + (left.M44 * right.M44);
941 Multiply(ref left, ref right, out result);
953 float inv = 1.0f / right;
955 result.M11 = left.M11 * inv;
956 result.M21 = left.M21 * inv;
957 result.M31 = left.M31 * inv;
958 result.M41 = left.M41 * inv;
959 result.M12 = left.M12 * inv;
960 result.M22 = left.M22 * inv;
961 result.M32 = left.M32 * inv;
962 result.M42 = left.M42 * inv;
963 result.M13 = left.M13 * inv;
964 result.M23 = left.M23 * inv;
965 result.M33 = left.M33 * inv;
966 result.M43 = left.M43 * inv;
967 result.M14 = left.M14 * inv;
968 result.M24 = left.M24 * inv;
969 result.M34 = left.M34 * inv;
970 result.M44 = left.M44 * inv;
982 Divide(ref left, right, out result);
994 result.M11 = left.M11 / right.M11;
995 result.M21 = left.M21 / right.M21;
996 result.M31 = left.M31 / right.M31;
997 result.M41 = left.M41 / right.M41;
998 result.M12 = left.M12 / right.M12;
999 result.M22 = left.M22 / right.M22;
1000 result.M32 = left.M32 / right.M32;
1001 result.M42 = left.M42 / right.M42;
1002 result.M13 = left.M13 / right.M13;
1003 result.M23 = left.M23 / right.M23;
1004 result.M33 = left.M33 / right.M33;
1005 result.M43 = left.M43 / right.M43;
1006 result.M14 = left.M14 / right.M14;
1007 result.M24 = left.M24 / right.M24;
1008 result.M34 = left.M34 / right.M34;
1009 result.M44 = left.M44 / right.M44;
1021 Divide(ref left, ref right, out result);
1038 throw new ArgumentOutOfRangeException(
"exponent",
"The exponent can not be negative.");
1042 result = Matrix.Identity;
1052 Matrix identity = Matrix.Identity;
1057 if ((exponent & 1) != 0)
1058 identity = identity * temp;
1081 Exponent(ref value, exponent, out result);
1092 result.M11 = -value.M11;
1093 result.M21 = -value.M21;
1094 result.M31 = -value.M31;
1095 result.M41 = -value.M41;
1096 result.M12 = -value.M12;
1097 result.M22 = -value.M22;
1098 result.M32 = -value.M32;
1099 result.M42 = -value.M42;
1100 result.M13 = -value.M13;
1101 result.M23 = -value.M23;
1102 result.M33 = -value.M33;
1103 result.M43 = -value.M43;
1104 result.M14 = -value.M14;
1105 result.M24 = -value.M24;
1106 result.M34 = -value.M34;
1107 result.M44 = -value.M44;
1118 Negate(ref value, out result);
1136 result.M11 = start.M11 + ((end.M11 - start.M11) * amount);
1137 result.M21 = start.M21 + ((end.M21 - start.M21) * amount);
1138 result.M31 = start.M31 + ((end.M31 - start.M31) * amount);
1139 result.M41 = start.M41 + ((end.M41 - start.M41) * amount);
1140 result.M12 = start.M12 + ((end.M12 - start.M12) * amount);
1141 result.M22 = start.M22 + ((end.M22 - start.M22) * amount);
1142 result.M32 = start.M32 + ((end.M32 - start.M32) * amount);
1143 result.M42 = start.M42 + ((end.M42 - start.M42) * amount);
1144 result.M13 = start.M13 + ((end.M13 - start.M13) * amount);
1145 result.M23 = start.M23 + ((end.M23 - start.M23) * amount);
1146 result.M33 = start.M33 + ((end.M33 - start.M33) * amount);
1147 result.M43 = start.M43 + ((end.M43 - start.M43) * amount);
1148 result.M14 = start.M14 + ((end.M14 - start.M14) * amount);
1149 result.M24 = start.M24 + ((end.M24 - start.M24) * amount);
1150 result.M34 = start.M34 + ((end.M34 - start.M34) * amount);
1151 result.M44 = start.M44 + ((end.M44 - start.M44) * amount);
1169 Lerp(ref start, ref end, amount, out result);
1182 amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f : amount);
1183 amount = (amount * amount) * (3.0f - (2.0f * amount));
1185 result.M11 = start.M11 + ((end.M11 - start.M11) * amount);
1186 result.M21 = start.M21 + ((end.M21 - start.M21) * amount);
1187 result.M31 = start.M31 + ((end.M31 - start.M31) * amount);
1188 result.M41 = start.M41 + ((end.M41 - start.M41) * amount);
1189 result.M12 = start.M12 + ((end.M12 - start.M12) * amount);
1190 result.M22 = start.M22 + ((end.M22 - start.M22) * amount);
1191 result.M32 = start.M32 + ((end.M32 - start.M32) * amount);
1192 result.M42 = start.M42 + ((end.M42 - start.M42) * amount);
1193 result.M13 = start.M13 + ((end.M13 - start.M13) * amount);
1194 result.M23 = start.M23 + ((end.M23 - start.M23) * amount);
1195 result.M33 = start.M33 + ((end.M33 - start.M33) * amount);
1196 result.M43 = start.M43 + ((end.M43 - start.M43) * amount);
1197 result.M14 = start.M14 + ((end.M14 - start.M14) * amount);
1198 result.M24 = start.M24 + ((end.M24 - start.M24) * amount);
1199 result.M34 = start.M34 + ((end.M34 - start.M34) * amount);
1200 result.M44 = start.M44 + ((end.M44 - start.M44) * amount);
1213 SmoothStep(ref start, ref end, amount, out result);
1225 temp.M11 = value.M11;
1226 temp.M21 = value.M12;
1227 temp.M31 = value.M13;
1228 temp.M41 = value.M14;
1229 temp.M12 = value.M21;
1230 temp.M22 = value.M22;
1231 temp.M32 = value.M23;
1232 temp.M42 = value.M24;
1233 temp.M13 = value.M31;
1234 temp.M23 = value.M32;
1235 temp.M33 = value.M33;
1236 temp.M43 = value.M34;
1237 temp.M14 = value.M41;
1238 temp.M24 = value.M42;
1239 temp.M34 = value.M43;
1240 temp.M44 = value.M44;
1253 Transpose(ref value, out result);
1264 float b0 = (value.M31 * value.M42) - (value.M32 * value.M41);
1265 float b1 = (value.M31 * value.M43) - (value.M33 * value.M41);
1266 float b2 = (value.M34 * value.M41) - (value.M31 * value.M44);
1267 float b3 = (value.M32 * value.M43) - (value.M33 * value.M42);
1268 float b4 = (value.M34 * value.M42) - (value.M32 * value.M44);
1269 float b5 = (value.M33 * value.M44) - (value.M34 * value.M43);
1271 float d11 = value.M22 * b5 + value.M23 * b4 + value.M24 * b3;
1272 float d12 = value.M21 * b5 + value.M23 * b2 + value.M24 * b1;
1273 float d13 = value.M21 * -b4 + value.M22 * b2 + value.M24 * b0;
1274 float d14 = value.M21 * b3 + value.M22 * -b1 + value.M23 * b0;
1276 float det = value.M11 * d11 - value.M12 * d12 + value.M13 * d13 - value.M14 * d14;
1277 if (Math.Abs(det) <= MathUtil.ZeroTolerance)
1279 result = Matrix.Zero;
1285 float a0 = (value.M11 * value.M22) - (value.M12 * value.M21);
1286 float a1 = (value.M11 * value.M23) - (value.M13 * value.M21);
1287 float a2 = (value.M14 * value.M21) - (value.M11 * value.M24);
1288 float a3 = (value.M12 * value.M23) - (value.M13 * value.M22);
1289 float a4 = (value.M14 * value.M22) - (value.M12 * value.M24);
1290 float a5 = (value.M13 * value.M24) - (value.M14 * value.M23);
1292 float d21 = value.M12 * b5 + value.M13 * b4 + value.M14 * b3;
1293 float d22 = value.M11 * b5 + value.M13 * b2 + value.M14 * b1;
1294 float d23 = value.M11 * -b4 + value.M12 * b2 + value.M14 * b0;
1295 float d24 = value.M11 * b3 + value.M12 * -b1 + value.M13 * b0;
1297 float d31 = value.M42 * a5 + value.M43 * a4 + value.M44 * a3;
1298 float d32 = value.M41 * a5 + value.M43 * a2 + value.M44 * a1;
1299 float d33 = value.M41 * -a4 + value.M42 * a2 + value.M44 * a0;
1300 float d34 = value.M41 * a3 + value.M42 * -a1 + value.M43 * a0;
1302 float d41 = value.M32 * a5 + value.M33 * a4 + value.M34 * a3;
1303 float d42 = value.M31 * a5 + value.M33 * a2 + value.M34 * a1;
1304 float d43 = value.M31 * -a4 + value.M32 * a2 + value.M34 * a0;
1305 float d44 = value.M31 * a3 + value.M32 * -a1 + value.M33 * a0;
1307 result.M11 = +d11 * det; result.M12 = -d21 * det; result.M13 = +d31 * det; result.M14 = -d41 * det;
1308 result.M21 = -d12 * det; result.M22 = +d22 * det; result.M23 = -d32 * det; result.M24 = +d42 * det;
1309 result.M31 = +d13 * det; result.M32 = -d23 * det; result.M33 = +d33 * det; result.M34 = -d43 * det;
1310 result.M41 = -d14 * det; result.M42 = +d24 * det; result.M43 = -d34 * det; result.M44 = +d44 * det;
1351 result.Row2 = result.Row2 - (Vector4.Dot(result.Row1, result.Row2) /
Vector4.
Dot(result.Row1, result.Row1)) * result.Row1;
1353 result.Row3 = result.Row3 - (
Vector4.
Dot(result.Row1, result.Row3) / Vector4.Dot(result.Row1, result.Row1)) * result.Row1;
1354 result.Row3 = result.Row3 - (Vector4.Dot(result.Row2, result.Row3) /
Vector4.
Dot(result.Row2, result.Row2)) * result.Row2;
1356 result.Row4 = result.Row4 - (
Vector4.
Dot(result.Row1, result.Row4) / Vector4.Dot(result.Row1, result.Row1)) * result.Row1;
1357 result.Row4 = result.Row4 - (Vector4.Dot(result.Row2, result.Row4) /
Vector4.
Dot(result.Row2, result.Row2)) * result.Row2;
1358 result.Row4 = result.Row4 - (
Vector4.
Dot(result.Row3, result.Row4) / Vector4.Dot(result.Row3, result.Row3)) * result.Row3;
1380 Orthogonalize(ref value, out result);
1415 result.Row1 = Vector4.Normalize(result.Row1);
1417 result.Row2 = result.Row2 - Vector4.Dot(result.Row1, result.Row2) * result.Row1;
1420 result.Row3 = result.Row3 - Vector4.Dot(result.Row1, result.Row3) * result.Row1;
1421 result.Row3 = result.Row3 -
Vector4.
Dot(result.Row2, result.Row3) * result.Row2;
1422 result.Row3 = Vector4.Normalize(result.Row3);
1424 result.Row4 = result.Row4 - Vector4.Dot(result.Row1, result.Row4) * result.Row1;
1425 result.Row4 = result.Row4 -
Vector4.
Dot(result.Row2, result.Row4) * result.Row2;
1426 result.Row4 = result.Row4 - Vector4.Dot(result.Row3, result.Row4) * result.Row3;
1451 Orthonormalize(ref value, out result);
1472 int columncount = 4;
1474 for (
int r = 0; r < rowcount; ++r)
1476 if (columncount <= lead)
1481 while (Math.Abs(result[i, lead]) < MathUtil.ZeroTolerance)
1490 if (lead == columncount)
1497 result.ExchangeRows(i, r);
1500 float multiplier = 1f / result[r, lead];
1502 for (; i < rowcount; ++i)
1506 result[i, 0] -= result[r, 0] * multiplier * result[i, lead];
1507 result[i, 1] -= result[r, 1] * multiplier * result[i, lead];
1508 result[i, 2] -= result[r, 2] * multiplier * result[i, lead];
1509 result[i, 3] -= result[r, 3] * multiplier * result[i, lead];
1531 UpperTriangularForm(ref value, out result);
1550 Matrix.Transpose(ref temp, out result);
1554 int columncount = 4;
1556 for (
int r = 0; r < rowcount; ++r)
1558 if (columncount <= lead)
1563 while (Math.Abs(result[i, lead]) < MathUtil.ZeroTolerance)
1572 if (lead == columncount)
1579 result.ExchangeRows(i, r);
1582 float multiplier = 1f / result[r, lead];
1584 for (; i < rowcount; ++i)
1588 result[i, 0] -= result[r, 0] * multiplier * result[i, lead];
1589 result[i, 1] -= result[r, 1] * multiplier * result[i, lead];
1590 result[i, 2] -= result[r, 2] * multiplier * result[i, lead];
1591 result[i, 3] -= result[r, 3] * multiplier * result[i, lead];
1598 Matrix.Transpose(ref result, out result);
1615 LowerTriangularForm(ref value, out result);
1632 int columncount = 4;
1634 for (
int r = 0; r < rowcount; ++r)
1636 if (columncount <= lead)
1641 while (Math.Abs(result[i, lead]) < MathUtil.ZeroTolerance)
1650 if (lead == columncount)
1657 result.ExchangeRows(i, r);
1660 float multiplier = 1f / result[r, lead];
1661 result[r, 0] *= multiplier;
1662 result[r, 1] *= multiplier;
1663 result[r, 2] *= multiplier;
1664 result[r, 3] *= multiplier;
1666 for (; i < rowcount; ++i)
1670 result[i, 0] -= result[r, 0] * result[i, lead];
1671 result[i, 1] -= result[r, 1] * result[i, lead];
1672 result[i, 2] -= result[r, 2] * result[i, lead];
1673 result[i, 3] -= result[r, 3] * result[i, lead];
1689 RowEchelonForm(ref value, out result);
1715 float[,] matrix =
new float[4, 5];
1717 matrix[0, 0] = value[0, 0];
1718 matrix[0, 1] = value[0, 1];
1719 matrix[0, 2] = value[0, 2];
1720 matrix[0, 3] = value[0, 3];
1721 matrix[0, 4] = augment[0];
1723 matrix[1, 0] = value[1, 0];
1724 matrix[1, 1] = value[1, 1];
1725 matrix[1, 2] = value[1, 2];
1726 matrix[1, 3] = value[1, 3];
1727 matrix[1, 4] = augment[1];
1729 matrix[2, 0] = value[2, 0];
1730 matrix[2, 1] = value[2, 1];
1731 matrix[2, 2] = value[2, 2];
1732 matrix[2, 3] = value[2, 3];
1733 matrix[2, 4] = augment[2];
1735 matrix[3, 0] = value[3, 0];
1736 matrix[3, 1] = value[3, 1];
1737 matrix[3, 2] = value[3, 2];
1738 matrix[3, 3] = value[3, 3];
1739 matrix[3, 4] = augment[3];
1743 int columncount = 5;
1745 for (
int r = 0; r < rowcount; r++)
1747 if (columncount <= lead)
1752 while (matrix[i, lead] == 0)
1761 if (columncount == lead)
1766 for (
int j = 0; j < columncount; j++)
1768 float temp = matrix[r, j];
1769 matrix[r, j] = matrix[i, j];
1770 matrix[i, j] = temp;
1773 float div = matrix[r, lead];
1775 for (
int j = 0; j < columncount; j++)
1777 matrix[r, j] /= div;
1780 for (
int j = 0; j < rowcount; j++)
1784 float sub = matrix[j, lead];
1785 for (
int k = 0; k < columncount; k++) matrix[j, k] -= (sub * matrix[r, k]);
1792 result.M11 = matrix[0, 0];
1793 result.M12 = matrix[0, 1];
1794 result.M13 = matrix[0, 2];
1795 result.M14 = matrix[0, 3];
1797 result.M21 = matrix[1, 0];
1798 result.M22 = matrix[1, 1];
1799 result.M23 = matrix[1, 2];
1800 result.M24 = matrix[1, 3];
1802 result.M31 = matrix[2, 0];
1803 result.M32 = matrix[2, 1];
1804 result.M33 = matrix[2, 2];
1805 result.M34 = matrix[2, 3];
1807 result.M41 = matrix[3, 0];
1808 result.M42 = matrix[3, 1];
1809 result.M43 = matrix[3, 2];
1810 result.M44 = matrix[3, 3];
1812 augmentResult.X = matrix[0, 4];
1813 augmentResult.Y = matrix[1, 4];
1814 augmentResult.Z = matrix[2, 4];
1815 augmentResult.W = matrix[3, 4];
1830 Vector3 difference = objectPosition - cameraPosition;
1832 float lengthSq = difference.LengthSquared();
1834 difference = -cameraForwardVector;
1836 difference *= (float)(1.0 / Math.Sqrt(lengthSq));
1838 Vector3.Cross(ref cameraUpVector, ref difference, out crossed);
1839 crossed.Normalize();
1840 Vector3.Cross(ref difference, ref crossed, out
final);
1842 result.M11 = crossed.X;
1843 result.M12 = crossed.Y;
1844 result.M13 = crossed.Z;
1846 result.M21 = final.X;
1847 result.M22 = final.Y;
1848 result.M23 = final.Z;
1850 result.M31 = difference.X;
1851 result.M32 = difference.Y;
1852 result.M33 = difference.Z;
1854 result.M41 = objectPosition.X;
1855 result.M42 = objectPosition.Y;
1856 result.M43 = objectPosition.Z;
1871 Billboard(ref objectPosition, ref cameraPosition, ref cameraUpVector, ref cameraForwardVector, out result);
1885 Vector3.Subtract(ref target, ref eye, out zaxis); zaxis.Normalize();
1886 Vector3.Cross(ref up, ref zaxis, out xaxis); xaxis.Normalize();
1887 Vector3.Cross(ref zaxis, ref xaxis, out yaxis);
1889 result = Matrix.Identity;
1890 result.M11 = xaxis.X; result.M21 = xaxis.Y; result.M31 = xaxis.Z;
1891 result.M12 = yaxis.X; result.M22 = yaxis.Y; result.M32 = yaxis.Z;
1892 result.M13 = zaxis.X; result.M23 = zaxis.Y; result.M33 = zaxis.Z;
1894 Vector3.Dot(ref xaxis, ref eye, out result.M41);
1895 Vector3.Dot(ref yaxis, ref eye, out result.M42);
1896 Vector3.Dot(ref zaxis, ref eye, out result.M43);
1898 result.M41 = -result.M41;
1899 result.M42 = -result.M42;
1900 result.M43 = -result.M43;
1913 LookAtLH(ref eye, ref target, ref up, out result);
1927 Vector3.Subtract(ref eye, ref target, out zaxis); zaxis.Normalize();
1928 Vector3.Cross(ref up, ref zaxis, out xaxis); xaxis.Normalize();
1929 Vector3.Cross(ref zaxis, ref xaxis, out yaxis);
1931 result = Matrix.Identity;
1932 result.M11 = xaxis.X; result.M21 = xaxis.Y; result.M31 = xaxis.Z;
1933 result.M12 = yaxis.X; result.M22 = yaxis.Y; result.M32 = yaxis.Z;
1934 result.M13 = zaxis.X; result.M23 = zaxis.Y; result.M33 = zaxis.Z;
1936 Vector3.Dot(ref xaxis, ref eye, out result.M41);
1937 Vector3.Dot(ref yaxis, ref eye, out result.M42);
1938 Vector3.Dot(ref zaxis, ref eye, out result.M43);
1940 result.M41 = -result.M41;
1941 result.M42 = -result.M42;
1942 result.M43 = -result.M43;
1955 LookAtRH(ref eye, ref target, ref up, out result);
1967 public static void OrthoLH(
float width,
float height,
float znear,
float zfar, out
Matrix result)
1969 float halfWidth = width * 0.5f;
1970 float halfHeight = height * 0.5f;
1972 OrthoOffCenterLH(-halfWidth, halfWidth, -halfHeight, halfHeight, znear, zfar, out result);
1983 public static Matrix OrthoLH(
float width,
float height,
float znear,
float zfar)
1986 OrthoLH(width, height, znear, zfar, out result);
1998 public static void OrthoRH(
float width,
float height,
float znear,
float zfar, out
Matrix result)
2000 float halfWidth = width * 0.5f;
2001 float halfHeight = height * 0.5f;
2003 OrthoOffCenterRH(-halfWidth, halfWidth, -halfHeight, halfHeight, znear, zfar, out result);
2014 public static Matrix OrthoRH(
float width,
float height,
float znear,
float zfar)
2017 OrthoRH(width, height, znear, zfar, out result);
2031 public static void OrthoOffCenterLH(
float left,
float right,
float bottom,
float top,
float znear,
float zfar, out
Matrix result)
2033 float zRange = 1.0f / (zfar - znear);
2035 result = Matrix.Identity;
2036 result.M11 = 2.0f / (right - left);
2037 result.M22 = 2.0f / (top - bottom);
2038 result.M33 = zRange;
2039 result.M41 = (left + right) / (left - right);
2040 result.M42 = (top + bottom) / (bottom - top);
2041 result.M43 = -znear * zRange;
2057 OrthoOffCenterLH(left, right, bottom, top, znear, zfar, out result);
2071 public static void OrthoOffCenterRH(
float left,
float right,
float bottom,
float top,
float znear,
float zfar, out
Matrix result)
2073 OrthoOffCenterLH(left, right, bottom, top, znear, zfar, out result);
2074 result.M33 *= -1.0f;
2090 OrthoOffCenterRH(left, right, bottom, top, znear, zfar, out result);
2104 float halfWidth = width * 0.5f;
2105 float halfHeight = height * 0.5f;
2107 PerspectiveOffCenterLH(-halfWidth, halfWidth, -halfHeight, halfHeight, znear, zfar, out result);
2121 PerspectiveLH(width, height, znear, zfar, out result);
2135 float halfWidth = width * 0.5f;
2136 float halfHeight = height * 0.5f;
2138 PerspectiveOffCenterRH(-halfWidth, halfWidth, -halfHeight, halfHeight, znear, zfar, out result);
2152 PerspectiveRH(width, height, znear, zfar, out result);
2166 float yScale = (float)(1.0 / Math.Tan(fov * 0.5f));
2167 float xScale = yScale / aspect;
2169 float halfWidth = znear / xScale;
2170 float halfHeight = znear / yScale;
2172 PerspectiveOffCenterLH(-halfWidth, halfWidth, -halfHeight, halfHeight, znear, zfar, out result);
2186 PerspectiveFovLH(fov, aspect, znear, zfar, out result);
2200 float yScale = (float)(1.0 / Math.Tan(fov * 0.5f));
2201 float xScale = yScale / aspect;
2203 float halfWidth = znear / xScale;
2204 float halfHeight = znear / yScale;
2206 PerspectiveOffCenterRH(-halfWidth, halfWidth, -halfHeight, halfHeight, znear, zfar, out result);
2220 PerspectiveFovRH(fov, aspect, znear, zfar, out result);
2236 float zRange = zfar / (zfar - znear);
2239 result.M11 = 2.0f * znear / (right - left);
2240 result.M22 = 2.0f * znear / (top - bottom);
2241 result.M31 = (left + right) / (left - right);
2242 result.M32 = (top + bottom) / (bottom - top);
2243 result.M33 = zRange;
2245 result.M43 = -znear * zRange;
2261 PerspectiveOffCenterLH(left, right, bottom, top, znear, zfar, out result);
2277 PerspectiveOffCenterLH(left, right, bottom, top, znear, zfar, out result);
2278 result.M31 *= -1.0f;
2279 result.M32 *= -1.0f;
2280 result.M33 *= -1.0f;
2281 result.M34 *= -1.0f;
2297 PerspectiveOffCenterRH(left, right, bottom, top, znear, zfar, out result);
2308 float x = plane.Normal.X;
2309 float y = plane.Normal.Y;
2310 float z = plane.Normal.Z;
2311 float x2 = -2.0f * x;
2312 float y2 = -2.0f *
y;
2313 float z2 = -2.0f *
z;
2315 result.M11 = (x2 * x) + 1.0f;
2316 result.M12 = y2 * x;
2317 result.M13 = z2 * x;
2319 result.M21 = x2 *
y;
2320 result.M22 = (y2 *
y) + 1.0f;
2321 result.M23 = z2 *
y;
2323 result.M31 = x2 *
z;
2324 result.M32 = y2 *
z;
2325 result.M33 = (z2 *
z) + 1.0f;
2327 result.M41 = x2 * plane.D;
2328 result.M42 = y2 * plane.D;
2329 result.M43 = z2 * plane.D;
2341 Reflection(ref plane, out result);
2354 float dot = (plane.Normal.X * light.X) + (plane.Normal.Y * light.Y) + (plane.Normal.Z * light.Z) + (plane.D * light.W);
2355 float x = -plane.Normal.X;
2356 float y = -plane.Normal.Y;
2357 float z = -plane.Normal.Z;
2360 result.M11 = (x * light.X) + dot;
2361 result.M21 = y * light.X;
2362 result.M31 = z * light.X;
2363 result.M41 = d * light.X;
2364 result.M12 = x * light.Y;
2365 result.M22 = (y * light.Y) + dot;
2366 result.M32 = z * light.Y;
2367 result.M42 = d * light.Y;
2368 result.M13 = x * light.Z;
2369 result.M23 = y * light.Z;
2370 result.M33 = (z * light.Z) + dot;
2371 result.M43 = d * light.Z;
2372 result.M14 = x * light.W;
2373 result.M24 = y * light.W;
2374 result.M34 = z * light.W;
2375 result.M44 = (d * light.W) + dot;
2388 Shadow(ref light, ref plane, out result);
2399 Scaling(scale.X, scale.Y, scale.Z, out result);
2410 Scaling(ref scale, out result);
2423 result = Matrix.Identity;
2439 Scaling(x, y, z, out result);
2450 result = Matrix.Identity;
2451 result.M11 = result.M22 = result.M33 = scale;
2462 Scaling(scale, out result);
2473 float cos = (float)Math.Cos(angle);
2474 float sin = (float)Math.Sin(angle);
2476 result = Matrix.Identity;
2491 RotationX(angle, out result);
2502 float cos = (float)Math.Cos(angle);
2503 float sin = (float)Math.Sin(angle);
2505 result = Matrix.Identity;
2520 RotationY(angle, out result);
2531 float cos = (float)Math.Cos(angle);
2532 float sin = (float)Math.Sin(angle);
2534 result = Matrix.Identity;
2549 RotationZ(angle, out result);
2564 float cos = (float)Math.Cos(angle);
2565 float sin = (float)Math.Sin(angle);
2573 result = Matrix.Identity;
2574 result.M11 = xx + (cos * (1.0f - xx));
2575 result.M12 = (xy - (cos * xy)) + (sin *
z);
2576 result.M13 = (xz - (cos * xz)) - (sin *
y);
2577 result.M21 = (xy - (cos * xy)) - (sin *
z);
2578 result.M22 = yy + (cos * (1.0f - yy));
2579 result.M23 = (yz - (cos * yz)) + (sin * x);
2580 result.M31 = (xz - (cos * xz)) + (sin *
y);
2581 result.M32 = (yz - (cos * yz)) - (sin * x);
2582 result.M33 = zz + (cos * (1.0f - zz));
2594 RotationAxis(ref axis, angle, out result);
2605 float xx = rotation.X * rotation.X;
2606 float yy = rotation.Y * rotation.Y;
2607 float zz = rotation.Z * rotation.Z;
2608 float xy = rotation.X * rotation.Y;
2609 float zw = rotation.Z * rotation.W;
2610 float zx = rotation.Z * rotation.X;
2611 float yw = rotation.Y * rotation.W;
2612 float yz = rotation.Y * rotation.Z;
2613 float xw = rotation.X * rotation.W;
2615 result = Matrix.Identity;
2616 result.M11 = 1.0f - (2.0f * (yy + zz));
2617 result.M12 = 2.0f * (xy + zw);
2618 result.M13 = 2.0f * (zx - yw);
2619 result.M21 = 2.0f * (xy - zw);
2620 result.M22 = 1.0f - (2.0f * (zz + xx));
2621 result.M23 = 2.0f * (yz + xw);
2622 result.M31 = 2.0f * (zx + yw);
2623 result.M32 = 2.0f * (yz - xw);
2624 result.M33 = 1.0f - (2.0f * (yy + xx));
2635 RotationQuaternion(ref rotation, out result);
2649 Quaternion.RotationYawPitchRoll(yaw, pitch, roll, out quaternion);
2650 RotationQuaternion(ref quaternion, out result);
2663 RotationYawPitchRoll(yaw, pitch, roll, out result);
2674 Translation(value.X, value.Y, value.Z, out result);
2685 Translation(ref value, out result);
2698 result = Matrix.Identity;
2714 Translation(x, y, z, out result);
2727 result = Scaling(scaling) * RotationQuaternion(rotation) * Translation(translation);
2740 AffineTransformation(scaling, ref rotation, ref translation, out result);
2754 result = Scaling(scaling) * Translation(-rotationCenter) * RotationQuaternion(rotation) *
2755 Translation(rotationCenter) * Translation(translation);
2769 AffineTransformation(scaling, ref rotationCenter, ref rotation, ref translation, out result);
2782 result = Scaling(scaling, scaling, 1.0f) * RotationZ(rotation) * Translation((
Vector3)translation);
2795 AffineTransformation2D(scaling, rotation, ref translation, out result);
2809 result = Scaling(scaling, scaling, 1.0f) * Translation((
Vector3)(-rotationCenter)) * RotationZ(rotation) *
2810 Translation((
Vector3)rotationCenter) * Translation((
Vector3)translation);
2824 AffineTransformation2D(scaling, ref rotationCenter, rotation, ref translation, out result);
2840 Matrix sr = RotationQuaternion(scalingRotation);
2842 result = Translation(-scalingCenter) * Transpose(sr) * Scaling(scaling) * sr * Translation(scalingCenter) * Translation(-rotationCenter) *
2843 RotationQuaternion(rotation) * Translation(rotationCenter) * Translation(translation);
2859 Transformation(ref scalingCenter, ref scalingRotation, ref scaling, ref rotationCenter, ref rotation, ref translation, out result);
2875 result = Translation((
Vector3)(-scalingCenter)) * RotationZ(-scalingRotation) * Scaling((
Vector3)scaling) * RotationZ(scalingRotation) * Translation((
Vector3)scalingCenter) *
2876 Translation((
Vector3)(-rotationCenter)) * RotationZ(rotation) * Translation((
Vector3)rotationCenter) * Translation((
Vector3)translation);
2895 Transformation2D(ref scalingCenter, scalingRotation, ref scaling, ref rotationCenter, rotation, ref translation, out result);
2907 fixed (
void* pDest = &
this)
2909 var
dest = (
float*)pDest;
2910 for (
int i = 0; i < rows; ++i)
2912 for (
int j = 0; j < columns; ++j)
2930 fixed(
void* pDest = &
this)
2932 var
dest = (
float*) pDest;
2933 for (
int i = 0; i < rows; ++i)
2935 int sourceIndex = i;
2936 for (
int j = 0; j < columns; ++j)
2938 dest[j] = src[sourceIndex];
2939 sourceIndex += rows;
2955 Add(ref left, ref right, out result);
2978 Subtract(ref left, ref right, out result);
2990 Negate(ref value, out result);
3003 Multiply(ref right, left, out result);
3016 Multiply(ref left, right, out result);
3029 Multiply(ref left, ref right, out result);
3042 Divide(ref left, right, out result);
3055 Divide(ref left, ref right, out result);
3067 return left.Equals(right);
3078 return !left.Equals(right);
3089 return string.Format(CultureInfo.CurrentCulture,
"[M11:{0} M12:{1} M13:{2} M14:{3}] [M21:{4} M22:{5} M23:{6} M24:{7}] [M31:{8} M32:{9} M33:{10} M34:{11}] [M41:{12} M42:{13} M43:{14} M44:{15}]",
3090 M11, M12, M13, M14, M21, M22, M23, M24, M31, M32, M33, M34, M41, M42, M43, M44);
3105 return string.Format(
format, CultureInfo.CurrentCulture,
"[M11:{0} M12:{1} M13:{2} M14:{3}] [M21:{4} M22:{5} M23:{6} M24:{7}] [M31:{8} M32:{9} M33:{10} M34:{11}] [M41:{12} M42:{13} M43:{14} M44:{15}]",
3106 M11.ToString(
format, CultureInfo.CurrentCulture), M12.ToString(format, CultureInfo.CurrentCulture), M13.ToString(
format, CultureInfo.CurrentCulture), M14.ToString(format, CultureInfo.CurrentCulture),
3107 M21.ToString(
format, CultureInfo.CurrentCulture), M22.ToString(format, CultureInfo.CurrentCulture), M23.ToString(
format, CultureInfo.CurrentCulture), M24.ToString(format, CultureInfo.CurrentCulture),
3108 M31.ToString(
format, CultureInfo.CurrentCulture), M32.ToString(format, CultureInfo.CurrentCulture), M33.ToString(
format, CultureInfo.CurrentCulture), M34.ToString(format, CultureInfo.CurrentCulture),
3109 M41.ToString(
format, CultureInfo.CurrentCulture), M42.ToString(format, CultureInfo.CurrentCulture), M43.ToString(
format, CultureInfo.CurrentCulture), M44.ToString(format, CultureInfo.CurrentCulture));
3121 return string.Format(formatProvider,
"[M11:{0} M12:{1} M13:{2} M14:{3}] [M21:{4} M22:{5} M23:{6} M24:{7}] [M31:{8} M32:{9} M33:{10} M34:{11}] [M41:{12} M42:{13} M43:{14} M44:{15}]",
3122 M11.ToString(formatProvider), M12.ToString(formatProvider), M13.ToString(formatProvider), M14.ToString(formatProvider),
3123 M21.ToString(formatProvider), M22.ToString(formatProvider), M23.ToString(formatProvider), M24.ToString(formatProvider),
3124 M31.ToString(formatProvider), M32.ToString(formatProvider), M33.ToString(formatProvider), M34.ToString(formatProvider),
3125 M41.ToString(formatProvider), M42.ToString(formatProvider), M43.ToString(formatProvider), M44.ToString(formatProvider));
3139 return ToString(formatProvider);
3141 return string.Format(
format, formatProvider,
"[M11:{0} M12:{1} M13:{2} M14:{3}] [M21:{4} M22:{5} M23:{6} M24:{7}] [M31:{8} M32:{9} M33:{10} M34:{11}] [M41:{12} M42:{13} M43:{14} M44:{15}]",
3142 M11.ToString(
format, formatProvider), M12.ToString(format, formatProvider), M13.ToString(
format, formatProvider), M14.ToString(format, formatProvider),
3143 M21.ToString(
format, formatProvider), M22.ToString(format, formatProvider), M23.ToString(
format, formatProvider), M24.ToString(format, formatProvider),
3144 M31.ToString(
format, formatProvider), M32.ToString(format, formatProvider), M33.ToString(
format, formatProvider), M34.ToString(format, formatProvider),
3145 M41.ToString(
format, formatProvider), M42.ToString(format, formatProvider), M43.ToString(
format, formatProvider), M44.ToString(format, formatProvider));
3156 return M11.GetHashCode() + M12.GetHashCode() + M13.GetHashCode() + M14.GetHashCode() +
3157 M21.GetHashCode() + M22.GetHashCode() + M23.GetHashCode() + M24.GetHashCode() +
3158 M31.GetHashCode() + M32.GetHashCode() + M33.GetHashCode() + M34.GetHashCode() +
3159 M41.GetHashCode() + M42.GetHashCode() + M43.GetHashCode() + M44.GetHashCode();
3171 return (Math.Abs(other.
M11 - M11) < MathUtil.ZeroTolerance &&
3173 Math.Abs(other.
M13 - M13) < MathUtil.ZeroTolerance &&
3176 Math.Abs(other.
M21 - M21) < MathUtil.ZeroTolerance &&
3178 Math.Abs(other.
M23 - M23) < MathUtil.ZeroTolerance &&
3181 Math.Abs(other.
M31 - M31) < MathUtil.ZeroTolerance &&
3183 Math.Abs(other.
M33 - M33) < MathUtil.ZeroTolerance &&
3186 Math.Abs(other.
M41 - M41) < MathUtil.ZeroTolerance &&
3188 Math.Abs(other.
M43 - M43) < MathUtil.ZeroTolerance &&
3204 if (value.GetType() != GetType())
3207 return Equals((
Matrix)value);
3216 public static implicit
operator SlimDX.Matrix(
Matrix value)
3218 return new SlimDX.Matrix()
3220 M11 = value.M11, M12 = value.M12, M13 = value.M13, M14 = value.M14,
3221 M21 = value.M21, M22 = value.M22, M23 = value.M23, M24 = value.M24,
3222 M31 = value.M31, M32 = value.M32, M33 = value.M33, M34 = value.M34,
3223 M41 = value.M41, M42 = value.M42, M43 = value.M43, M44 = value.M44
3232 public static implicit
operator Matrix(SlimDX.Matrix value)
3236 M11 = value.M11, M12 = value.M12, M13 = value.M13, M14 = value.M14,
3237 M21 = value.M21, M22 = value.M22, M23 = value.M23, M24 = value.M24,
3238 M31 = value.M31, M32 = value.M32, M33 = value.M33, M34 = value.M34,
3239 M41 = value.M41, M42 = value.M42, M43 = value.M43, M44 = value.M44
3250 public static implicit
operator System.Windows.Media.Media3D.Matrix3D(Matrix value)
3252 return new System.Windows.Media.Media3D.Matrix3D()
3254 M11 = value.M11, M12 = value.M12, M13 = value.M13, M14 = value.M14,
3255 M21 = value.M21, M22 = value.M22, M23 = value.M23, M24 = value.M24,
3256 M31 = value.M31, M32 = value.M32, M33 = value.M33, M34 = value.M34,
3257 OffsetX = value.M41, OffsetY = value.M42, OffsetZ = value.M43, M44 = value.M44
3266 public static explicit operator Matrix(
System.Windows.Media.Media3D.Matrix3D value)
3270 M11 = (float)value.M11, M12 = (
float)value.M12, M13 = (float)value.M13, M14 = (
float)value.M14,
3271 M21 = (float)value.M21, M22 = (
float)value.M22, M23 = (float)value.M23, M24 = (
float)value.M24,
3272 M31 = (float)value.M31, M32 = (
float)value.M32, M33 = (float)value.M33, M34 = (
float)value.M34,
3273 M41 = (float)value.OffsetX, M42 = (
float)value.OffsetY, M43 = (float)value.OffsetZ, M44 = (
float)value.M44
3284 public static implicit
operator Microsoft.Xna.Framework.Matrix(Matrix value)
3286 return new Microsoft.Xna.Framework.Matrix()
3288 M11 = value.M11, M12 = value.M12, M13 = value.M13, M14 = value.M14,
3289 M21 = value.M21, M22 = value.M22, M23 = value.M23, M24 = value.M24,
3290 M31 = value.M31, M32 = value.M32, M33 = value.M33, M34 = value.M34,
3291 M41 = value.M41, M42 = value.M42, M43 = value.M43, M44 = value.M44
3300 public static implicit
operator Matrix(Microsoft.Xna.Framework.Matrix value)
3304 M11 = value.M11, M12 = value.M12, M13 = value.M13, M14 = value.M14,
3305 M21 = value.M21, M22 = value.M22, M23 = value.M23, M24 = value.M24,
3306 M31 = value.M31, M32 = value.M32, M33 = value.M33, M34 = value.M34,
3307 M41 = value.M41, M42 = value.M42, M43 = value.M43, M44 = value.M44
static Matrix RotationZ(float angle)
Creates a matrix that rotates around the z-axis.
void Normalize()
Converts the vector into a unit vector.
static void RotationQuaternion(ref Quaternion rotation, out Matrix result)
Creates a rotation matrix from a quaternion.
unsafe void CopyMatrixFrom(float *src, int columns, int rows)
Copies a nxm matrix to this instance.
void DecomposeXYZ(out Vector3 rotation)
Decomposes a rotation matrix with the specified X, Y and Z euler angles. Matrix.RotationX(rotation.X) * Matrix.RotationY(rotation.Y) * Matrix.RotationZ(rotation.Z) should represent the same rotation.
static Matrix OrthoLH(float width, float height, float znear, float zfar)
Creates a left-handed, orthographic projection matrix.
FbxDouble3 operator*(double factor, FbxDouble3 vector)
bool Decompose(out Vector3 scale, out Quaternion rotation, out Vector3 translation)
Decomposes a matrix into a scale, rotation, and translation.
static void Translation(float x, float y, float z, out Matrix result)
Creates a translation matrix using the specified offsets.
float M22
Value at row 2 column 2 of the matrix.
Represents a two dimensional mathematical vector.
static void LowerTriangularForm(ref Matrix value, out Matrix result)
Brings the matrix into lower triangular form using elementry row operations.
static Matrix PerspectiveFovLH(float fov, float aspect, float znear, float zfar)
Creates a left-handed, perspective projection matrix based on a field of view.
static Matrix Scaling(float scale)
Creates a matrix that uniformally scales along all three axis.
static void RowEchelonForm(ref Matrix value, out Matrix result)
Brings the matrix into row echelon form using elementry row operations;
static void PerspectiveFovRH(float fov, float aspect, float znear, float zfar, out Matrix result)
Creates a right-handed, perspective projection matrix based on a field of view.
float[] ToArray()
Creates an array containing the elements of the matrix.
static void Scaling(ref Vector3 scale, out Matrix result)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
static void RotationAxis(ref Vector3 axis, float angle, out Matrix result)
Creates a matrix that rotates around an arbitary axis.
static void Orthogonalize(ref Matrix value, out Matrix result)
Orthogonalizes the specified matrix.
float M21
Value at row 2 column 1 of the matrix.
static void PerspectiveLH(float width, float height, float znear, float zfar, out Matrix result)
Creates a left-handed, perspective projection matrix.
static void Negate(ref Matrix value, out Matrix result)
Negates a matrix.
void Invert()
Inverts the matrix.
static Matrix Scaling(float x, float y, float z)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
static void OrthoLH(float width, float height, float znear, float zfar, out Matrix result)
Creates a left-handed, orthographic projection matrix.
Matrix(float[] values)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Matrix struct.
static void Billboard(ref Vector3 objectPosition, ref Vector3 cameraPosition, ref Vector3 cameraUpVector, ref Vector3 cameraForwardVector, out Matrix result)
Creates a spherical billboard that rotates around a specified object position.
static void Subtract(ref Matrix left, ref Matrix right, out Matrix result)
Determines the difference between two matrices.
static Matrix Reflection(Plane plane)
Builds a matrix that can be used to reflect vectors about a plane.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
static void Divide(ref Matrix left, float right, out Matrix result)
Scales a matrix by the given value.
static Matrix PerspectiveOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar)
Creates a left-handed, customized perspective projection matrix.
override int GetHashCode()
Returns a hash code for this instance.
static Matrix Exponent(Matrix value, int exponent)
Performs the exponential operation on a matrix.
string ToString(string format)
Returns a System.String that represents this instance.
static Matrix Transformation(Vector3 scalingCenter, Quaternion scalingRotation, Vector3 scaling, Vector3 rotationCenter, Quaternion rotation, Vector3 translation)
Creates a transformation matrix.
static void RotationZ(float angle, out Matrix result)
Creates a matrix that rotates around the z-axis.
override string ToString()
Returns a System.String that represents this instance.
static void PerspectiveOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Creates a right-handed, customized perspective projection matrix.
float M13
Value at row 1 column 3 of the matrix.
static void PerspectiveFovLH(float fov, float aspect, float znear, float zfar, out Matrix result)
Creates a left-handed, perspective projection matrix based on a field of view.
static void Dot(ref Vector4 left, ref Vector4 right, out float result)
Calculates the dot product of two vectors.
const float ZeroTolerance
The value for which all absolute numbers smaller than are considered equal to zero.
Represents a three dimensional mathematical vector.
string ToString(IFormatProvider formatProvider)
Returns a System.String that represents this instance.
static Matrix LookAtLH(Vector3 eye, Vector3 target, Vector3 up)
Creates a left-handed, look-at matrix.
static void PerspectiveOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Creates a left-handed, customized perspective projection matrix.
float M23
Value at row 2 column 3 of the matrix.
static Matrix LowerTriangularForm(Matrix value)
Brings the matrix into lower triangular form using elementry row operations.
float M42
Value at row 4 column 2 of the matrix.
static void RotationX(float angle, out Matrix result)
Creates a matrix that rotates around the x-axis.
static void MultiplyTo(ref Matrix left, ref Matrix right, out Matrix result)
Determines the product of two matrices.
static void Shadow(ref Vector4 light, ref Plane plane, out Matrix result)
Creates a matrix that flattens geometry into a shadow.
unsafe void TransposeMatrixFrom(float *src, int columns, int rows)
Transposes a nmx matrix to this instance.
static void Translation(ref Vector3 value, out Matrix result)
Creates a translation matrix using the specified offsets.
void ExchangeRows(int firstRow, int secondRow)
Exchanges two rows in the matrix.
static void RotationY(float angle, out Matrix result)
Creates a matrix that rotates around the y-axis.
static Matrix Orthonormalize(Matrix value)
Orthonormalizes the specified matrix.
static void AffineTransformation2D(float scaling, float rotation, ref Vector2 translation, out Matrix result)
Creates a 2D affine transformation matrix.
static Matrix SmoothStep(Matrix start, Matrix end, float amount)
Performs a cubic interpolation between two matrices.
string ToString(string format, IFormatProvider formatProvider)
Returns a System.String that represents this instance.
void DecomposeQR(out Matrix Q, out Matrix R)
Decomposes a matrix into an orthonormalized matrix Q and a right traingular matrix R...
static void LookAtRH(ref Vector3 eye, ref Vector3 target, ref Vector3 up, out Matrix result)
Creates a right-handed, look-at matrix.
static Matrix RowEchelonForm(Matrix value)
Brings the matrix into row echelon form using elementry row operations;
static Matrix RotationX(float angle)
Creates a matrix that rotates around the x-axis.
static Matrix Transpose(Matrix value)
Calculates the transpose of the specified matrix.
float M31
Value at row 3 column 1 of the matrix.
static Matrix PerspectiveRH(float width, float height, float znear, float zfar)
Creates a right-handed, perspective projection matrix.
static Matrix OrthoOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar)
Creates a left-handed, customized orthographic projection matrix.
static Matrix Lerp(Matrix start, Matrix end, float amount)
Performs a linear interpolation between two matricies.
float M44
Value at row 4 column 4 of the matrix.
const CallingConvention CallConvention
Defines the calling convention for P/Invoking the native core methods.
static Matrix Translation(float x, float y, float z)
Creates a translation matrix using the specified offsets.
static void OrthoOffCenterLH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Creates a left-handed, customized orthographic projection matrix.
Represents a plane in three dimensional space.
void Decompose(out float yaw, out float pitch, out float roll)
Decomposes a rotation matrix with the specified yaw, pitch, roll
static void Add(ref Matrix left, ref Matrix right, out Matrix result)
Determines the sum of two matrices.
static void Scaling(float scale, out Matrix result)
Creates a matrix that uniformally scales along all three axis.
static Matrix Shadow(Vector4 light, Plane plane)
Creates a matrix that flattens geometry into a shadow.
static void MultiplyRef(ref Matrix left, ref Matrix right, ref Matrix result)
Determines the product of two matrices.
Matrix(float M11, float M12, float M13, float M14, float M21, float M22, float M23, float M24, float M31, float M32, float M33, float M34, float M41, float M42, float M43, float M44)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Matrix struct.
static void UpperTriangularForm(ref Matrix value, out Matrix result)
Brings the matrix into upper triangular form using elementry row operations.
static Matrix RotationY(float angle)
Creates a matrix that rotates around the y-axis.
void DecomposeLQ(out Matrix L, out Matrix Q)
Decomposes a matrix into a lower triangular matrix L and an orthonormalized matrix Q...
static void LookAtLH(ref Vector3 eye, ref Vector3 target, ref Vector3 up, out Matrix result)
Creates a left-handed, look-at matrix.
Represents a four dimensional mathematical vector.
float M14
Value at row 1 column 4 of the matrix.
static void SmoothStep(ref Matrix start, ref Matrix end, float amount, out Matrix result)
Performs a cubic interpolation between two matricies.
static void PerspectiveRH(float width, float height, float znear, float zfar, out Matrix result)
Creates a right-handed, perspective projection matrix.
Represents a four dimensional mathematical quaternion.
static void AffineTransformation(float scaling, ref Quaternion rotation, ref Vector3 translation, out Matrix result)
Creates a 3D affine transformation matrix.
float M11
Value at row 1 column 1 of the matrix.
static Matrix PerspectiveLH(float width, float height, float znear, float zfar)
Creates a left-handed, perspective projection matrix.
float M41
Value at row 4 column 1 of the matrix.
static void RotationYawPitchRoll(float yaw, float pitch, float roll, out Matrix result)
Creates a rotation matrix with a specified yaw, pitch, and roll.
SiliconStudio.Core.Mathematics.Quaternion Quaternion
override bool Equals(object value)
Determines whether the specified System.Object is equal to this instance.
Matrix(float value)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Matrix struct.
static Matrix RotationAxis(Vector3 axis, float angle)
Creates a matrix that rotates around an arbitary axis.
bool Equals(Matrix other)
Determines whether the specified SiliconStudio.Core.Mathematics.Matrix is equal to this instance...
static void Transpose(ref Matrix value, out Matrix result)
Calculates the transpose of the specified matrix.
static Matrix OrthoRH(float width, float height, float znear, float zfar)
Creates a right-handed, orthographic projection matrix.
static void Orthonormalize(ref Matrix value, out Matrix result)
Orthonormalizes the specified matrix.
static Matrix Scaling(Vector3 scale)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
static void ReducedRowEchelonForm(ref Matrix value, ref Vector4 augment, out Matrix result, out Vector4 augmentResult)
Brings the matrix into reduced row echelon form using elementry row operations.
static Matrix AffineTransformation2D(float scaling, float rotation, Vector2 translation)
Creates a 2D affine transformation matrix.
static Matrix RotationYawPitchRoll(float yaw, float pitch, float roll)
Creates a rotation matrix with a specified yaw, pitch, and roll.
static Matrix Divide(Matrix left, Matrix right)
Determines the quotient of two matrices.
float M12
Value at row 1 column 2 of the matrix.
static Matrix Transformation2D(Vector2 scalingCenter, float scalingRotation, Vector2 scaling, Vector2 rotationCenter, float rotation, Vector2 translation)
Creates a 2D transformation matrix.
static void Reflection(ref Plane plane, out Matrix result)
Builds a matrix that can be used to reflect vectors about a plane.
static void Multiply(ref Matrix left, ref Matrix right, out Matrix result)
Determines the product of two matrices.
const string LibraryName
Defines the location of the core native DLL.
static Matrix RotationQuaternion(Quaternion rotation)
Creates a rotation matrix from a quaternion.
static Matrix PerspectiveOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar)
Creates a right-handed, customized perspective projection matrix.
static Matrix LookAtRH(Vector3 eye, Vector3 target, Vector3 up)
Creates a right-handed, look-at matrix.
static void Exponent(ref Matrix value, int exponent, out Matrix result)
Performs the exponential operation on a matrix.
static void Invert(ref Matrix value, out Matrix result)
Calculates the inverse of the specified matrix.
static Matrix PerspectiveFovRH(float fov, float aspect, float znear, float zfar)
Creates a right-handed, perspective projection matrix based on a field of view.
static Matrix AffineTransformation(float scaling, Vector3 rotationCenter, Quaternion rotation, Vector3 translation)
Creates a 3D affine transformation matrix.
float M34
Value at row 3 column 4 of the matrix.
static void Divide(ref Matrix left, ref Matrix right, out Matrix result)
Determines the quotient of two matrices.
static Matrix Subtract(Matrix left, Matrix right)
Determines the difference between two matrices.
static Matrix AffineTransformation(float scaling, Quaternion rotation, Vector3 translation)
Creates a 3D affine transformation matrix.
static Matrix Multiply(Matrix left, float right)
Scales a matrix by the given value.
void Transpose()
Transposes the matrix.
SiliconStudio.Core.Mathematics.Vector3 Vector3
static void OrthoOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar, out Matrix result)
Creates a right-handed, customized orthographic projection matrix.
static Matrix Multiply(Matrix left, Matrix right)
Determines the product of two matrices.
float M33
Value at row 3 column 3 of the matrix.
static Matrix UpperTriangularForm(Matrix value)
Brings the matrix into upper triangular form using elementry row operations.
float M43
Value at row 4 column 3 of the matrix.
static void AffineTransformation2D(float scaling, ref Vector2 rotationCenter, float rotation, ref Vector2 translation, out Matrix result)
Creates a 2D affine transformation matrix.
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
static void Transformation(ref Vector3 scalingCenter, ref Quaternion scalingRotation, ref Vector3 scaling, ref Vector3 rotationCenter, ref Quaternion rotation, ref Vector3 translation, out Matrix result)
Creates a transformation matrix.
static Matrix Translation(Vector3 value)
Creates a translation matrix using the specified offsets.
void ExchangeColumns(int firstColumn, int secondColumn)
static Matrix Invert(Matrix value)
Calculates the inverse of the specified matrix.
static Matrix AffineTransformation2D(float scaling, Vector2 rotationCenter, float rotation, Vector2 translation)
Creates a 2D affine transformation matrix.
static void OrthoRH(float width, float height, float znear, float zfar, out Matrix result)
Creates a right-handed, orthographic projection matrix.
void Orthonormalize()
Orthonormalizes the specified matrix.
static Matrix Divide(Matrix left, float right)
Scales a matrix by the given value.
static void Lerp(ref Matrix start, ref Matrix end, float amount, out Matrix result)
Performs a linear interpolation between two matricies.
static Matrix Negate(Matrix value)
Negates a matrix.
static Matrix Add(Matrix left, Matrix right)
Determines the sum of two matrices.
static void AffineTransformation(float scaling, ref Vector3 rotationCenter, ref Quaternion rotation, ref Vector3 translation, out Matrix result)
Creates a 3D affine transformation matrix.
float M32
Value at row 3 column 2 of the matrix.
DataStyle
Specifies the style used for textual serialization when an array/list or a dictionary/map must be ser...
float Determinant()
Calculates the determinant of the matrix.
static Matrix OrthoOffCenterRH(float left, float right, float bottom, float top, float znear, float zfar)
Creates a right-handed, customized orthographic projection matrix.
static void Scaling(float x, float y, float z, out Matrix result)
Creates a matrix that scales along the x-axis, y-axis, and y-axis.
static void Multiply(ref Matrix left, float right, out Matrix result)
Scales a matrix by the given value.
static void Transformation2D(ref Vector2 scalingCenter, float scalingRotation, ref Vector2 scaling, ref Vector2 rotationCenter, float rotation, ref Vector2 translation, out Matrix result)
Creates a 2D transformation matrix.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t size_t z
static Matrix Orthogonalize(Matrix value)
Orthogonalizes the specified matrix.
void Orthogonalize()
Orthogonalizes the specified matrix.
static Matrix Billboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector)
Creates a spherical billboard that rotates around a specified object position.
float M24
Value at row 2 column 4 of the matrix.
Represents a 4x4 mathematical matrix.