Пример #1
0
        public void MultiplyMatrix()
        {
            Matrix33F m = new Matrix33F(12, 23, 45,
                                        67, 89, 90,
                                        43, 65, 87);

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

            Matrix33F m1 = new Matrix33F(columnMajor, MatrixOrder.ColumnMajor);
            Matrix33F m2 = new Matrix33F(12, 23, 45,
                                         67, 89, 90,
                                         43, 65, 87);
            Matrix33F result = Matrix33F.Multiply(m1, m2);

            for (int column = 0; column < 3; column++)
            {
                for (int row = 0; row < 3; row++)
                {
                    Assert.AreEqual(Vector3F.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]);
                }
            }
        }
Пример #2
0
        public void Multiplication()
        {
            float     s = 0.1234f;
            Matrix33F m = new Matrix33F(columnMajor, MatrixOrder.ColumnMajor);

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

            Assert.AreEqual(v, Matrix33F.Multiply(Matrix33F.Identity, v));
            Assert.AreEqual(Vector3F.Zero, Matrix33F.Multiply(Matrix33F.Zero, v));

            Matrix33F m = new Matrix33F(12, 23, 45,
                                        67, 89, 90,
                                        43, 65, 87);

            Assert.IsTrue(Vector3F.AreNumericallyEqual(v, Matrix33F.Multiply(m * m.Inverse, v)));

            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(Vector3F.Dot(m.GetRow(i), v), Matrix33F.Multiply(m, v)[i]);
            }
        }