Exemple #1
0
 public bool Equals(Matrix3x3 other)
 {
     return this.M11 == other.M11
         && this.M12 == other.M12
         && this.M13 == other.M13
         && this.M21 == other.M21
         && this.M22 == other.M22
         && this.M23 == other.M23
         && this.M31 == other.M31
         && this.M32 == other.M32
         && this.M33 == other.M33;
 }
Exemple #2
0
 public static void Transform(ref Vector3 v, ref Matrix3x3 matrix, out Vector3 result)
 {
     double vX = v.X, vY = v.Y, vZ = v.Z;
     result.X = vX * matrix.M11 + vY * matrix.M21 + vZ * matrix.M31;
     result.Y = vX * matrix.M12 + vY * matrix.M22 + vZ * matrix.M32;
     result.Z = vX * matrix.M13 + vY * matrix.M23 + vZ * matrix.M33;
 }
Exemple #3
0
 public static void Transpose(ref Matrix3x3 matrix, out Matrix3x3 result)
 {
     double m21 = matrix.M12;
     double m31 = matrix.M13;
     double m12 = matrix.M21;
     double m32 = matrix.M23;
     double m13 = matrix.M31;
     double m23 = matrix.M32;
     result.M11 = matrix.M11;
     result.M12 = m12;
     result.M13 = m13;
     result.M21 = m21;
     result.M22 = matrix.M22;
     result.M23 = m23;
     result.M31 = m31;
     result.M32 = m32;
     result.M33 = matrix.M33;
 }
Exemple #4
0
 public static void Negate(ref Matrix3x3 matrix, out Matrix3x3 result)
 {
     result.M11 = -matrix.M11;
     result.M12 = -matrix.M12;
     result.M13 = -matrix.M13;
     result.M21 = -matrix.M21;
     result.M22 = -matrix.M22;
     result.M23 = -matrix.M23;
     result.M31 = -matrix.M31;
     result.M32 = -matrix.M32;
     result.M33 = -matrix.M33;
 }
Exemple #5
0
 public static void Sub(ref Matrix3x3 a, ref Matrix3x3 b, out Matrix3x3 result)
 {
     result.M11 = a.M11 - b.M11;
     result.M12 = a.M12 - b.M12;
     result.M13 = a.M13 - b.M13;
     result.M21 = a.M21 - b.M21;
     result.M22 = a.M22 - b.M22;
     result.M23 = a.M23 - b.M23;
     result.M31 = a.M31 - b.M31;
     result.M32 = a.M32 - b.M32;
     result.M33 = a.M33 - b.M33;
 }
Exemple #6
0
 public static void Invert(ref Matrix3x3 matrix, out Matrix3x3 result)
 {
     double determinantInverse = 1 / matrix.Determinant();
     double m11 = (matrix.M22 * matrix.M33 - matrix.M23 * matrix.M32) * determinantInverse;
     double m12 = (matrix.M13 * matrix.M32 - matrix.M33 * matrix.M12) * determinantInverse;
     double m13 = (matrix.M12 * matrix.M23 - matrix.M22 * matrix.M13) * determinantInverse;
     double m21 = (matrix.M23 * matrix.M31 - matrix.M21 * matrix.M33) * determinantInverse;
     double m22 = (matrix.M11 * matrix.M33 - matrix.M13 * matrix.M31) * determinantInverse;
     double m23 = (matrix.M13 * matrix.M21 - matrix.M11 * matrix.M23) * determinantInverse;
     double m31 = (matrix.M21 * matrix.M32 - matrix.M22 * matrix.M31) * determinantInverse;
     double m32 = (matrix.M12 * matrix.M31 - matrix.M11 * matrix.M32) * determinantInverse;
     double m33 = (matrix.M11 * matrix.M22 - matrix.M12 * matrix.M21) * determinantInverse;
     result.M11 = m11;
     result.M12 = m12;
     result.M13 = m13;
     result.M21 = m21;
     result.M22 = m22;
     result.M23 = m23;
     result.M31 = m31;
     result.M32 = m32;
     result.M33 = m33;
 }
Exemple #7
0
 public static void Mul(ref Matrix3x3 a, ref Matrix3x3 b, out Matrix3x3 result)
 {
     double resultM11 = a.M11 * b.M11 + a.M12 * b.M21 + a.M13 * b.M31;
     double resultM12 = a.M11 * b.M12 + a.M12 * b.M22 + a.M13 * b.M32;
     double resultM13 = a.M11 * b.M13 + a.M12 * b.M23 + a.M13 * b.M33;
     double resultM21 = a.M21 * b.M11 + a.M22 * b.M21 + a.M23 * b.M31;
     double resultM22 = a.M21 * b.M12 + a.M22 * b.M22 + a.M23 * b.M32;
     double resultM23 = a.M21 * b.M13 + a.M22 * b.M23 + a.M23 * b.M33;
     double resultM31 = a.M31 * b.M11 + a.M32 * b.M21 + a.M33 * b.M31;
     double resultM32 = a.M31 * b.M12 + a.M32 * b.M22 + a.M33 * b.M32;
     double resultM33 = a.M31 * b.M13 + a.M32 * b.M23 + a.M33 * b.M33;
     result.M11 = resultM11;
     result.M12 = resultM12;
     result.M13 = resultM13;
     result.M21 = resultM21;
     result.M22 = resultM22;
     result.M23 = resultM23;
     result.M31 = resultM31;
     result.M32 = resultM32;
     result.M33 = resultM33;
 }
Exemple #8
0
 public static void CreateScale(ref Vector3 scale, out Matrix3x3 matrix)
 {
     matrix = new Matrix3x3
     {
         M11 = scale.X,
         M22 = scale.Y,
         M33 = scale.Z
     };
 }
Exemple #9
0
 public static void CreateScale(double x, double y, double z, out Matrix3x3 matrix)
 {
     matrix = new Matrix3x3
     {
         M11 = x,
         M22 = y,
         M33 = z
     };
 }
Exemple #10
0
 public static void CreateOuterProduct(ref Vector3 a, ref Vector3 b, out Matrix3x3 result)
 {
     result.M11 = a.X * b.X;
     result.M12 = a.X * b.Y;
     result.M13 = a.X * b.Z;
     result.M21 = a.Y * b.X;
     result.M22 = a.Y * b.Y;
     result.M23 = a.Y * b.Z;
     result.M31 = a.Z * b.X;
     result.M32 = a.Z * b.Y;
     result.M33 = a.Z * b.Z;
 }
Exemple #11
0
 public static void CreateScale(double scale, out Matrix3x3 matrix)
 {
     matrix = new Matrix3x3
     {
         M11 = scale,
         M22 = scale,
         M33 = scale
     };
 }
Exemple #12
0
 public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix3x3 result)
 {
     double qX2 = quaternion.X + quaternion.X;
     double qY2 = quaternion.Y + quaternion.Y;
     double qZ2 = quaternion.Z + quaternion.Z;
     double XX = qX2 * quaternion.X;
     double YY = qY2 * quaternion.Y;
     double ZZ = qZ2 * quaternion.Z;
     double XY = qX2 * quaternion.Y;
     double XZ = qX2 * quaternion.Z;
     double XW = qX2 * quaternion.W;
     double YZ = qY2 * quaternion.Z;
     double YW = qY2 * quaternion.W;
     double ZW = qZ2 * quaternion.W;
     result.M11 = 1 - YY - ZZ;
     result.M21 = XY - ZW;
     result.M31 = XZ + YW;
     result.M12 = XY + ZW;
     result.M22 = 1 - XX - ZZ;
     result.M32 = YZ - XW;
     result.M13 = XZ - YW;
     result.M23 = YZ + XW;
     result.M33 = 1 - XX - YY;
 }
Exemple #13
0
 public static void CreateFromMatrix(ref Matrix4x4 matrix4X4, out Matrix3x3 matrix3X3)
 {
     matrix3X3.M11 = matrix4X4.M11;
     matrix3X3.M12 = matrix4X4.M12;
     matrix3X3.M13 = matrix4X4.M13;
     matrix3X3.M21 = matrix4X4.M21;
     matrix3X3.M22 = matrix4X4.M22;
     matrix3X3.M23 = matrix4X4.M23;
     matrix3X3.M31 = matrix4X4.M31;
     matrix3X3.M32 = matrix4X4.M32;
     matrix3X3.M33 = matrix4X4.M33;
 }
Exemple #14
0
 public static void CreateFromAxisAngle(ref Vector3 axis, double angle, out Matrix3x3 result)
 {
     double xx = axis.X * axis.X;
     double yy = axis.Y * axis.Y;
     double zz = axis.Z * axis.Z;
     double xy = axis.X * axis.Y;
     double xz = axis.X * axis.Z;
     double yz = axis.Y * axis.Z;
     double sinAngle = System.Math.Sin(angle);
     double oneMinusCosAngle = 1.0 - System.Math.Cos(angle);
     result.M11 = 1 + oneMinusCosAngle * (xx - 1);
     result.M21 = -axis.Z * sinAngle + oneMinusCosAngle * xy;
     result.M31 = axis.Y * sinAngle + oneMinusCosAngle * xz;
     result.M12 = axis.Z * sinAngle + oneMinusCosAngle * xy;
     result.M22 = 1 + oneMinusCosAngle * (yy - 1);
     result.M32 = -axis.X * sinAngle + oneMinusCosAngle * yz;
     result.M13 = -axis.Y * sinAngle + oneMinusCosAngle * xz;
     result.M23 = axis.X * sinAngle + oneMinusCosAngle * yz;
     result.M33 = 1 + oneMinusCosAngle * (zz - 1);
 }
Exemple #15
0
 public static void CreateCrossProduct(ref Vector3 v, out Matrix3x3 result)
 {
     result.M11 = 0;
     result.M12 = -v.Z;
     result.M13 = v.Y;
     result.M21 = v.Z;
     result.M22 = 0;
     result.M23 = -v.X;
     result.M31 = -v.Y;
     result.M32 = v.X;
     result.M33 = 0;
 }
Exemple #16
0
 public static void Add(ref Matrix3x3 a, ref Matrix3x3 b, out Matrix3x3 result)
 {
     result.M11 = a.M11 + b.M11;
     result.M12 = a.M12 + b.M12;
     result.M13 = a.M13 + b.M13;
     result.M21 = a.M21 + b.M21;
     result.M22 = a.M22 + b.M22;
     result.M23 = a.M23 + b.M23;
     result.M31 = a.M31 + b.M31;
     result.M32 = a.M32 + b.M32;
     result.M33 = a.M33 + b.M33;
 }