public void Matrix3x2DeterminantTest1() { Matrix3x2 a = new Matrix3x2(); a.M11 = 5.0f; a.M12 = 2.0f; a.M21 = 12.0f; a.M22 = 6.8f; a.M31 = 6.5f; a.M32 = 1.0f; Matrix3x2 i; Assert.True(Matrix3x2.Invert(a, out i)); Single detA = a.GetDeterminant(); Single detI = i.GetDeterminant(); Single t = 1.0f / detI; // only accurate to 3 precision Assert.True(Math.Abs(detA - t) < 1e-3, "Matrix3x2.Determinant was not set correctly."); // sanity check against 4x4 version Assert.Equal(new Matrix4x4(a).GetDeterminant(), detA); Assert.Equal(new Matrix4x4(i).GetDeterminant(), detI); }
public void Matrix3x2InvertTest1() { Matrix3x2 a = new Matrix3x2(); a.M11 = 0.0f; a.M12 = 2.0f; a.M21 = 0.0f; a.M22 = 4.0f; a.M31 = 5.0f; a.M32 = 6.0f; Single detA = a.GetDeterminant(); Assert.True(MathHelper.Equal(detA, 0.0f), "Matrix3x2.Invert did not return the expected value."); Matrix3x2 actual; Assert.False(Matrix3x2.Invert(a, out actual)); // all the elements in Actual is NaN Assert.True( Single.IsNaN(actual.M11) && Single.IsNaN(actual.M12) && Single.IsNaN(actual.M21) && Single.IsNaN(actual.M22) && Single.IsNaN(actual.M31) && Single.IsNaN(actual.M32) , "Matrix3x2.Invert did not return the expected value."); }
public void Matrix3x2DeterminantTest() { Matrix3x2 target = Matrix3x2.CreateRotation(MathHelper.ToRadians(30.0f)); Single val = 1.0f; Single det = target.GetDeterminant(); Assert.True(MathHelper.Equal(val, det), "Matrix3x2.Determinant was not set correctly."); }