public void GetColumn() { Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor); Assert.AreEqual(new Vector2F(1.0f, 3.0f), m.GetColumn(0)); Assert.AreEqual(new Vector2F(2.0f, 4.0f), m.GetColumn(1)); }
public void SetColumn() { Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor); m.SetColumn(0, new Vector2F(0.1f, 0.2f)); Assert.AreEqual(new Vector2F(0.1f, 0.2f), m.GetColumn(0)); Assert.AreEqual(new Vector2F(2.0f, 4.0f), m.GetColumn(1)); m.SetColumn(1, new Vector2F(0.4f, 0.5f)); Assert.AreEqual(new Vector2F(0.1f, 0.2f), m.GetColumn(0)); Assert.AreEqual(new Vector2F(0.4f, 0.5f), m.GetColumn(1)); }
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 GetColumnException2() { Matrix22F m = new Matrix22F(columnMajor, MatrixOrder.ColumnMajor); m.GetColumn(2); }
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]); }