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