public void SetColumn() { Matrix44D m = new Matrix44D(rowMajor, MatrixOrder.RowMajor); m.SetColumn(0, new Vector4D(0.1, 0.2, 0.3, 0.4)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetColumn(0)); Assert.AreEqual(new Vector4D(2.0, 6.0, 10.0, 14.0), m.GetColumn(1)); Assert.AreEqual(new Vector4D(3.0, 7.0, 11.0, 15.0), m.GetColumn(2)); Assert.AreEqual(new Vector4D(4.0, 8.0, 12.0, 16.0), m.GetColumn(3)); m.SetColumn(1, new Vector4D(0.4, 0.5, 0.6, 0.7)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetColumn(0)); Assert.AreEqual(new Vector4D(0.4, 0.5, 0.6, 0.7), m.GetColumn(1)); Assert.AreEqual(new Vector4D(3.0, 7.0, 11.0, 15.0), m.GetColumn(2)); Assert.AreEqual(new Vector4D(4.0, 8.0, 12.0, 16.0), m.GetColumn(3)); m.SetColumn(2, new Vector4D(0.7, 0.8, 0.9, 1.0)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetColumn(0)); Assert.AreEqual(new Vector4D(0.4, 0.5, 0.6, 0.7), m.GetColumn(1)); Assert.AreEqual(new Vector4D(0.7, 0.8, 0.9, 1.0), m.GetColumn(2)); Assert.AreEqual(new Vector4D(4.0, 8.0, 12.0, 16.0), m.GetColumn(3)); m.SetColumn(3, new Vector4D(1.1, 1.8, 1.9, 1.2)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetColumn(0)); Assert.AreEqual(new Vector4D(0.4, 0.5, 0.6, 0.7), m.GetColumn(1)); Assert.AreEqual(new Vector4D(0.7, 0.8, 0.9, 1.0), m.GetColumn(2)); Assert.AreEqual(new Vector4D(1.1, 1.8, 1.9, 1.2), m.GetColumn(3)); }
public void GetColumnException2() { Matrix44D m = new Matrix44D(rowMajor, MatrixOrder.RowMajor); m.GetColumn(4); }
public void MultiplyMatrixOperator() { Matrix44D m = new Matrix44D(12, 23, 45, 56, 67, 89, 90, 12, 43, 65, 87, 43, 34, -12, 84, 44); Assert.AreEqual(Matrix44D.Zero, m * Matrix44D.Zero); Assert.AreEqual(Matrix44D.Zero, Matrix44D.Zero * m); Assert.AreEqual(m, m * Matrix44D.Identity); Assert.AreEqual(m, Matrix44D.Identity * m); Assert.IsTrue(Matrix44D.AreNumericallyEqual(Matrix44D.Identity, m * m.Inverse)); Assert.IsTrue(Matrix44D.AreNumericallyEqual(Matrix44D.Identity, m.Inverse * m)); Matrix44D m1 = new Matrix44D(rowMajor, MatrixOrder.RowMajor); Matrix44D m2 = new Matrix44D(12, 23, 45, 56, 67, 89, 90, 12, 43, 65, 87, 43, 34, -12, 84, 44); Matrix44D result = m1 * m2; for (int column = 0; column < 4; column++) for (int row = 0; row < 4; row++) Assert.AreEqual(Vector4D.Dot(m1.GetRow(row), m2.GetColumn(column)), result[row, column]); }
public void GetColumn() { Matrix44D m = new Matrix44D(rowMajor, MatrixOrder.RowMajor); Assert.AreEqual(new Vector4D(1.0, 5.0, 9.0, 13.0), m.GetColumn(0)); Assert.AreEqual(new Vector4D(2.0, 6.0, 10.0, 14.0), m.GetColumn(1)); Assert.AreEqual(new Vector4D(3.0, 7.0, 11.0, 15.0), m.GetColumn(2)); Assert.AreEqual(new Vector4D(4.0, 8.0, 12.0, 16.0), m.GetColumn(3)); }