public void GetColumn() { Matrix33D m = new Matrix33D(columnMajor, MatrixOrder.ColumnMajor); Assert.AreEqual(new Vector3D(1.0, 4.0, 7.0), m.GetColumn(0)); Assert.AreEqual(new Vector3D(2.0, 5.0, 8.0), m.GetColumn(1)); Assert.AreEqual(new Vector3D(3.0, 6.0, 9.0), m.GetColumn(2)); }
public void MultiplyMatrix() { Matrix33D m = new Matrix33D(12, 23, 45, 67, 89, 90, 43, 65, 87); Assert.AreEqual(Matrix33D.Zero, Matrix33D.Multiply(m, Matrix33D.Zero)); Assert.AreEqual(Matrix33D.Zero, Matrix33D.Multiply(Matrix33D.Zero, m)); Assert.AreEqual(m, Matrix33D.Multiply(m, Matrix33D.Identity)); Assert.AreEqual(m, Matrix33D.Multiply(Matrix33D.Identity, m)); Assert.IsTrue(Matrix33D.AreNumericallyEqual(Matrix33D.Identity, Matrix33D.Multiply(m, m.Inverse))); Assert.IsTrue(Matrix33D.AreNumericallyEqual(Matrix33D.Identity, Matrix33D.Multiply(m.Inverse, m))); Matrix33D m1 = new Matrix33D(columnMajor, MatrixOrder.ColumnMajor); Matrix33D m2 = new Matrix33D(12, 23, 45, 67, 89, 90, 43, 65, 87); Matrix33D result = Matrix33D.Multiply(m1, m2); for (int column = 0; column < 3; column++) { for (int row = 0; row < 3; row++) { Assert.AreEqual(Vector3D.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]); } } }
public void SetColumn() { Matrix33D m = new Matrix33D(columnMajor, MatrixOrder.ColumnMajor); m.SetColumn(0, new Vector3D(0.1, 0.2, 0.3)); Assert.AreEqual(new Vector3D(0.1, 0.2, 0.3), m.GetColumn(0)); Assert.AreEqual(new Vector3D(2.0, 5.0, 8.0), m.GetColumn(1)); Assert.AreEqual(new Vector3D(3.0, 6.0, 9.0), m.GetColumn(2)); m.SetColumn(1, new Vector3D(0.4, 0.5, 0.6)); Assert.AreEqual(new Vector3D(0.1, 0.2, 0.3), m.GetColumn(0)); Assert.AreEqual(new Vector3D(0.4, 0.5, 0.6), m.GetColumn(1)); Assert.AreEqual(new Vector3D(3.0, 6.0, 9.0), m.GetColumn(2)); m.SetColumn(2, new Vector3D(0.7, 0.8, 0.9)); Assert.AreEqual(new Vector3D(0.1, 0.2, 0.3), m.GetColumn(0)); Assert.AreEqual(new Vector3D(0.4, 0.5, 0.6), m.GetColumn(1)); Assert.AreEqual(new Vector3D(0.7, 0.8, 0.9), m.GetColumn(2)); }
public void GetColumnException2() { Matrix33D m = new Matrix33D(columnMajor, MatrixOrder.ColumnMajor); m.GetColumn(3); }
public void MultiplyMatrixOperator() { Matrix33D m = new Matrix33D(12, 23, 45, 67, 89, 90, 43, 65, 87); Assert.AreEqual(Matrix33D.Zero, m * Matrix33D.Zero); Assert.AreEqual(Matrix33D.Zero, Matrix33D.Zero * m); Assert.AreEqual(m, m * Matrix33D.Identity); Assert.AreEqual(m, Matrix33D.Identity * m); Assert.IsTrue(Matrix33D.AreNumericallyEqual(Matrix33D.Identity, m * m.Inverse)); Assert.IsTrue(Matrix33D.AreNumericallyEqual(Matrix33D.Identity, m.Inverse * m)); Matrix33D m1 = new Matrix33D(columnMajor, MatrixOrder.ColumnMajor); Matrix33D m2 = new Matrix33D(12, 23, 45, 67, 89, 90, 43, 65, 87); Matrix33D result = m1 * m2; for (int column = 0; column < 3; column++) for (int row = 0; row < 3; row++) Assert.AreEqual(Vector3D.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]); }