Пример #1
0
        public void Multiplication()
        {
            float     s = 0.1234f;
            Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);

            m = Matrix22F.Multiply(s, m);
            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(rowMajor[i] * s, m[i]);
            }
        }
Пример #2
0
        public void MultiplyVector()
        {
            Vector2F v = new Vector2F(2.34f, 3.45f);

            Assert.AreEqual(v, Matrix22F.Multiply(Matrix22F.Identity, v));
            Assert.AreEqual(Vector2F.Zero, Matrix22F.Multiply(Matrix22F.Zero, v));

            Matrix22F m = new Matrix22F(12, 23, 45, 67);

            Assert.IsTrue(Vector2F.AreNumericallyEqual(v, Matrix22F.Multiply(m * m.Inverse, v)));

            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(Vector2F.Dot(m.GetRow(i), v), Matrix22F.Multiply(m, v)[i]);
            }
        }
Пример #3
0
        public void MultiplyMatrix()
        {
            Matrix22F m = new Matrix22F(12, 23, 45, 67);

            Assert.AreEqual(Matrix22F.Zero, Matrix22F.Multiply(m, Matrix22F.Zero));
            Assert.AreEqual(Matrix22F.Zero, Matrix22F.Multiply(Matrix22F.Zero, m));
            Assert.AreEqual(m, Matrix22F.Multiply(m, Matrix22F.Identity));
            Assert.AreEqual(m, Matrix22F.Multiply(Matrix22F.Identity, m));
            Assert.IsTrue(Matrix22F.AreNumericallyEqual(Matrix22F.Identity, Matrix22F.Multiply(m, m.Inverse)));
            Assert.IsTrue(Matrix22F.AreNumericallyEqual(Matrix22F.Identity, Matrix22F.Multiply(m.Inverse, m)));

            Matrix22F m1     = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);
            Matrix22F m2     = new Matrix22F(12, 23, 45, 67);
            Matrix22F result = Matrix22F.Multiply(m1, m2);

            for (int column = 0; column < 2; column++)
            {
                for (int row = 0; row < 2; row++)
                {
                    Assert.AreEqual(Vector2F.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]);
                }
            }
        }