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)); }
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)); }
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]); } }
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]); } } }
public void GetRowException2() { Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor); m.GetRow(2); }
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]); }
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]); }