Example #1
0
        public void Matrix3x2MultiplyTest3()
        {
            Matrix3x2 a = GenerateMatrixNumberFrom1To6();
            Matrix3x2 b = GenerateMatrixNumberFrom1To6();

            Matrix3x2 expected = new Matrix3x2();

            expected.M11 = a.M11 * b.M11 + a.M12 * b.M21;
            expected.M12 = a.M11 * b.M12 + a.M12 * b.M22;

            expected.M21 = a.M21 * b.M11 + a.M22 * b.M21;
            expected.M22 = a.M21 * b.M12 + a.M22 * b.M22;

            expected.M31 = a.M31 * b.M11 + a.M32 * b.M21 + b.M31;
            expected.M32 = a.M31 * b.M12 + a.M32 * b.M22 + b.M32;
            Matrix3x2 actual;

            actual = Matrix3x2.Multiply(a, b);

            Assert.Equal(expected, actual);

            // Sanity check by comparison with 4x4 multiply.
            a = Matrix3x2.CreateRotation(MathHelper.ToRadians(30)) * Matrix3x2.CreateTranslation(23, 42);
            b = Matrix3x2.CreateScale(3, 7) * Matrix3x2.CreateTranslation(666, -1);

            actual = Matrix3x2.Multiply(a, b);

            Matrix4x4 a44        = new Matrix4x4(a);
            Matrix4x4 b44        = new Matrix4x4(b);
            Matrix4x4 expected44 = Matrix4x4.Multiply(a44, b44);
            Matrix4x4 actual44   = new Matrix4x4(actual);

            Assert.True(MathHelper.Equal(expected44, actual44), "Matrix3x2.Multiply did not return the expected value.");
        }
Example #2
0
        public void Matrix3x2MultiplyTest5()
        {
            Matrix3x2 a        = GenerateMatrixNumberFrom1To6();
            Matrix3x2 expected = new Matrix3x2(3, 6, 9, 12, 15, 18);
            Matrix3x2 actual   = Matrix3x2.Multiply(a, 3);

            Assert.Equal(expected, actual);
        }