public void IndexerThrowsWithColumnOutOfRange([Range(0, 2)] int row, [Values(-1, 3)] int column) { Matrix3By3 matrix = Matrix3By3.DiagonalMatrix(-3.0, 1.0, 5.0); var exception = Assert.Throws <ArgumentOutOfRangeException>(() => { double unused = matrix[row, column]; }); Assert.AreEqual("column", exception.ParamName); }
public void TestMatrixReturns() { double x = 1; double y = 2; double z = 3; Matrix3By3 mat1 = Matrix3By3.CrossProductEquivalentMatrix(new Cartesian(x, y, z)); Assert.AreEqual(0.0, mat1.M11); Assert.AreEqual(-z, mat1.M12); Assert.AreEqual(y, mat1.M13); Assert.AreEqual(z, mat1.M21); Assert.AreEqual(0, mat1.M22); Assert.AreEqual(-x, mat1.M23); Assert.AreEqual(-y, mat1.M31); Assert.AreEqual(x, mat1.M32); Assert.AreEqual(0.0, mat1.M33); UnitCartesian u = new UnitCartesian(x, y, z); x = u.X; y = u.Y; z = u.Z; Matrix3By3 mat2 = Matrix3By3.CrossProductEquivalentMatrix(u); Assert.AreEqual(0.0, mat2.M11); Assert.AreEqual(-z, mat2.M12); Assert.AreEqual(y, mat2.M13); Assert.AreEqual(z, mat2.M21); Assert.AreEqual(0, mat2.M22); Assert.AreEqual(-x, mat2.M23); Assert.AreEqual(-y, mat2.M31); Assert.AreEqual(x, mat2.M32); Assert.AreEqual(0.0, mat2.M33); Matrix3By3 mat3 = Matrix3By3.DiagonalMatrix(new Cartesian(1, 2, 3)); Assert.AreEqual(mat3.M11, 1); Assert.AreEqual(mat3.M22, 2); Assert.AreEqual(mat3.M33, 3); Matrix3By3 mat4 = Matrix3By3.DiagonalMatrix(new UnitCartesian(1, 0, 0)); Assert.AreEqual(mat4.M11, 1); Assert.AreEqual(mat4.M22, 0); Assert.AreEqual(mat4.M33, 0); }
public void TestSecondIndexTooLow2() { Matrix3By3 diagonal = Matrix3By3.DiagonalMatrix(-3.0, 1.0, 5.0); double bad = diagonal[2, -1]; }
public void TestSecondIndexTooHigh0() { Matrix3By3 diagonal = Matrix3By3.DiagonalMatrix(-3.0, 1.0, 5.0); double bad = diagonal[0, 3]; }
public void TestFirstIndexTooLow() { Matrix3By3 diagonal = Matrix3By3.DiagonalMatrix(-3.0, 1.0, 5.0); double bad = diagonal[-1, 0]; }