public void SetRow() { Matrix44D m = new Matrix44D(rowMajor, MatrixOrder.RowMajor); m.SetRow(0, new Vector4D(0.1, 0.2, 0.3, 0.4)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetRow(0)); Assert.AreEqual(new Vector4D(5.0, 6.0, 7.0, 8.0), m.GetRow(1)); Assert.AreEqual(new Vector4D(9.0, 10.0, 11.0, 12.0), m.GetRow(2)); Assert.AreEqual(new Vector4D(13.0, 14.0, 15.0, 16.0), m.GetRow(3)); m.SetRow(1, new Vector4D(0.4, 0.5, 0.6, 0.7)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetRow(0)); Assert.AreEqual(new Vector4D(0.4, 0.5, 0.6, 0.7), m.GetRow(1)); Assert.AreEqual(new Vector4D(9.0, 10.0, 11.0, 12.0), m.GetRow(2)); Assert.AreEqual(new Vector4D(13.0, 14.0, 15.0, 16.0), m.GetRow(3)); m.SetRow(2, new Vector4D(0.7, 0.8, 0.9, 1.0)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetRow(0)); Assert.AreEqual(new Vector4D(0.4, 0.5, 0.6, 0.7), m.GetRow(1)); Assert.AreEqual(new Vector4D(0.7, 0.8, 0.9, 1.0), m.GetRow(2)); Assert.AreEqual(new Vector4D(13.0, 14.0, 15.0, 16.0), m.GetRow(3)); m.SetRow(3, new Vector4D(1.7, 1.8, 1.9, 1.3)); Assert.AreEqual(new Vector4D(0.1, 0.2, 0.3, 0.4), m.GetRow(0)); Assert.AreEqual(new Vector4D(0.4, 0.5, 0.6, 0.7), m.GetRow(1)); Assert.AreEqual(new Vector4D(0.7, 0.8, 0.9, 1.0), m.GetRow(2)); Assert.AreEqual(new Vector4D(1.7, 1.8, 1.9, 1.3), m.GetRow(3)); }
public void MultiplyVectorOperator() { Vector4D v = new Vector4D(2.34, 3.45, 4.56, 23.4); Assert.AreEqual(v, Matrix44D.Identity * v); Assert.AreEqual(Vector4D.Zero, Matrix44D.Zero * v); Matrix44D m = new Matrix44D(12, 23, 45, 56, 67, 89, 90, 12, 43, 65, 87, 43, 34, -12, 84, 44); Assert.IsTrue(Vector4D.AreNumericallyEqual(v, m * m.Inverse * v)); for (int i = 0; i < 4; i++) Assert.AreEqual(Vector4D.Dot(m.GetRow(i), v), (m * v)[i]); }
public void GetRowException2() { Matrix44D m = new Matrix44D(rowMajor, MatrixOrder.RowMajor); m.GetRow(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 GetRow() { Matrix44D m = new Matrix44D(rowMajor, MatrixOrder.RowMajor); Assert.AreEqual(new Vector4D(1.0, 2.0, 3.0, 4.0), m.GetRow(0)); Assert.AreEqual(new Vector4D(5.0, 6.0, 7.0, 8.0), m.GetRow(1)); Assert.AreEqual(new Vector4D(9.0, 10.0, 11.0, 12.0), m.GetRow(2)); Assert.AreEqual(new Vector4D(13.0, 14.0, 15.0, 16.0), m.GetRow(3)); }