예제 #1
0
        public void GetRow()
        {
            Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);

            Assert.AreEqual(new Vector2F(1.0f, 2.0f), m.GetRow(0));
            Assert.AreEqual(new Vector2F(3.0f, 4.0f), m.GetRow(1));
        }
예제 #2
0
        public void SetRow()
        {
            Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);

            m.SetRow(0, new Vector2F(0.1f, 0.2f));
            Assert.AreEqual(new Vector2F(0.1f, 0.2f), m.GetRow(0));
            Assert.AreEqual(new Vector2F(3.0f, 4.0f), m.GetRow(1));

            m.SetRow(1, new Vector2F(0.4f, 0.5f));
            Assert.AreEqual(new Vector2F(0.1f, 0.2f), m.GetRow(0));
            Assert.AreEqual(new Vector2F(0.4f, 0.5f), m.GetRow(1));
        }
예제 #3
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]);
            }
        }
예제 #4
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]);
                }
            }
        }
예제 #5
0
        public void GetRowException2()
        {
            Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);

            m.GetRow(2);
        }
예제 #6
0
        public void SetRow()
        {
            Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);
              m.SetRow(0, new Vector2F(0.1f, 0.2f));
              Assert.AreEqual(new Vector2F(0.1f, 0.2f), m.GetRow(0));
              Assert.AreEqual(new Vector2F(3.0f, 4.0f), m.GetRow(1));

              m.SetRow(1, new Vector2F(0.4f, 0.5f));
              Assert.AreEqual(new Vector2F(0.1f, 0.2f), m.GetRow(0));
              Assert.AreEqual(new Vector2F(0.4f, 0.5f), m.GetRow(1));
        }
예제 #7
0
        public void MultiplyVectorOperator()
        {
            Vector2F v = new Vector2F(2.34f, 3.45f);
              Assert.AreEqual(v, Matrix22F.Identity * v);
              Assert.AreEqual(Vector2F.Zero, Matrix22F.Zero * v);

              Matrix22F m = new Matrix22F(12, 23, 45, 67);
              Assert.IsTrue(Vector2F.AreNumericallyEqual(v, m * m.Inverse * v));

              for (int i = 0; i < 2; i++)
            Assert.AreEqual(Vector2F.Dot(m.GetRow(i), v), (m * v)[i]);
        }
예제 #8
0
        public void MultiplyMatrixOperator()
        {
            Matrix22F m = new Matrix22F(12, 23, 45, 67);
              Assert.AreEqual(Matrix22F.Zero, m * Matrix22F.Zero);
              Assert.AreEqual(Matrix22F.Zero, Matrix22F.Zero * m);
              Assert.AreEqual(m, m * Matrix22F.Identity);
              Assert.AreEqual(m, Matrix22F.Identity * m);
              Assert.IsTrue(Matrix22F.AreNumericallyEqual(Matrix22F.Identity, m * m.Inverse));
              Assert.IsTrue(Matrix22F.AreNumericallyEqual(Matrix22F.Identity, m.Inverse * m));

              Matrix22F m1 = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);
              Matrix22F m2 = new Matrix22F(12, 23, 45, 67);
              Matrix22F result = 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]);
        }
예제 #9
0
 public void GetRowException2()
 {
     Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);
       m.GetRow(2);
 }
예제 #10
0
 public void GetRow()
 {
     Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor);
       Assert.AreEqual(new Vector2F(1.0f, 2.0f), m.GetRow(0));
       Assert.AreEqual(new Vector2F(3.0f, 4.0f), m.GetRow(1));
 }