Example #1
0
        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);
        }
Example #2
0
        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.");
        }
Example #3
0
        public void Matrix3x2InvertIdentityTest()
        {
            Matrix3x2 mtx = Matrix3x2.Identity;

            Matrix3x2 actual;

            Assert.True(Matrix3x2.Invert(mtx, out actual));

            Assert.True(MathHelper.Equal(actual, Matrix3x2.Identity));
        }
Example #4
0
        public void Matrix3x2InvertScaleTest()
        {
            Matrix3x2 mtx = Matrix3x2.CreateScale(23, -42);

            Matrix3x2 actual;

            Assert.True(Matrix3x2.Invert(mtx, out actual));

            Matrix3x2 i = mtx * actual;

            Assert.True(MathHelper.Equal(i, Matrix3x2.Identity));
        }
Example #5
0
        public void Matrix3x2InvertRotationTest()
        {
            Matrix3x2 mtx = Matrix3x2.CreateRotation(2);

            Matrix3x2 actual;

            Assert.True(Matrix3x2.Invert(mtx, out actual));

            Matrix3x2 i = mtx * actual;

            Assert.True(MathHelper.Equal(i, Matrix3x2.Identity));
        }
Example #6
0
        public void Matrix3x2InvertAffineTest()
        {
            Matrix3x2 mtx = Matrix3x2.CreateRotation(2) *
                            Matrix3x2.CreateScale(23, -42) *
                            Matrix3x2.CreateTranslation(17, 53);

            Matrix3x2 actual;

            Assert.True(Matrix3x2.Invert(mtx, out actual));

            Matrix3x2 i = mtx * actual;

            Assert.True(MathHelper.Equal(i, Matrix3x2.Identity));
        }
Example #7
0
        public void Matrix3x2InvertTest()
        {
            Matrix3x2 mtx = Matrix3x2.CreateRotation(MathHelper.ToRadians(30.0f));

            Matrix3x2 expected = new Matrix3x2();

            expected.M11 = 0.8660254f;
            expected.M12 = -0.5f;

            expected.M21 = 0.5f;
            expected.M22 = 0.8660254f;

            expected.M31 = 0;
            expected.M32 = 0;

            Matrix3x2 actual;

            Assert.True(Matrix3x2.Invert(mtx, out actual));
            Assert.True(MathHelper.Equal(expected, actual), "Matrix3x2.Invert did not return the expected value.");

            Matrix3x2 i = mtx * actual;

            Assert.True(MathHelper.Equal(i, Matrix3x2.Identity), "Matrix3x2.Invert did not return the expected value.");
        }