github-classroom[bot] e77901d4f0
Initial commit
2025-09-11 09:05:42 +00:00

401 lines
23 KiB
C#

using OpenTK.Mathematics;
namespace VectorAndMatrixTests
{
[TestClass]
public class MatrixTests
{
[TestMethod]
public void Constructor()
{
// Use the Assert class to test conditions
MyMatrix myMatrix = new MyMatrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
Matrix4 matrix4 = new Matrix4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
Assert.AreEqual(matrix4.M11, myMatrix.GetElement(0, 0));
Assert.AreEqual(matrix4.M12, myMatrix.GetElement(0, 1));
Assert.AreEqual(matrix4.M13, myMatrix.GetElement(0, 2));
Assert.AreEqual(matrix4.M14, myMatrix.GetElement(0, 3));
Assert.AreEqual(matrix4.M21, myMatrix.GetElement(1, 0));
Assert.AreEqual(matrix4.M22, myMatrix.GetElement(1, 1));
Assert.AreEqual(matrix4.M23, myMatrix.GetElement(1, 2));
Assert.AreEqual(matrix4.M24, myMatrix.GetElement(1, 3));
Assert.AreEqual(matrix4.M31, myMatrix.GetElement(2, 0));
Assert.AreEqual(matrix4.M32, myMatrix.GetElement(2, 1));
Assert.AreEqual(matrix4.M33, myMatrix.GetElement(2, 2));
Assert.AreEqual(matrix4.M34, myMatrix.GetElement(2, 3));
Assert.AreEqual(matrix4.M41, myMatrix.GetElement(3, 0));
Assert.AreEqual(matrix4.M42, myMatrix.GetElement(3, 1));
Assert.AreEqual(matrix4.M43, myMatrix.GetElement(3, 2));
Assert.AreEqual(matrix4.M44, myMatrix.GetElement(3, 3));
}
[TestMethod]
public void CreateIdentity()
{
// Use the Assert class to test conditions
MyMatrix myMatrix = MyMatrix.CreateIdentity();
Matrix4 matrix4 = Matrix4.Identity;
Assert.AreEqual(matrix4.M11, myMatrix.GetElement(0, 0));
Assert.AreEqual(matrix4.M12, myMatrix.GetElement(0, 1));
Assert.AreEqual(matrix4.M13, myMatrix.GetElement(0, 2));
Assert.AreEqual(matrix4.M14, myMatrix.GetElement(0, 3));
Assert.AreEqual(matrix4.M21, myMatrix.GetElement(1, 0));
Assert.AreEqual(matrix4.M22, myMatrix.GetElement(1, 1));
Assert.AreEqual(matrix4.M23, myMatrix.GetElement(1, 2));
Assert.AreEqual(matrix4.M24, myMatrix.GetElement(1, 3));
Assert.AreEqual(matrix4.M31, myMatrix.GetElement(2, 0));
Assert.AreEqual(matrix4.M32, myMatrix.GetElement(2, 1));
Assert.AreEqual(matrix4.M33, myMatrix.GetElement(2, 2));
Assert.AreEqual(matrix4.M34, myMatrix.GetElement(2, 3));
Assert.AreEqual(matrix4.M41, myMatrix.GetElement(3, 0));
Assert.AreEqual(matrix4.M42, myMatrix.GetElement(3, 1));
Assert.AreEqual(matrix4.M43, myMatrix.GetElement(3, 2));
Assert.AreEqual(matrix4.M44, myMatrix.GetElement(3, 3));
}
[TestMethod]
public void CreateTranslation()
{
// Use the Assert class to test conditions
MyVector translationVector = new MyVector(30, 40, 50);
MyMatrix myMatrix = MyMatrix.CreateTranslation(translationVector);
Matrix4 matrix4 = Matrix4.CreateTranslation(translationVector.X, translationVector.Y, translationVector.Z);
Assert.AreEqual(matrix4.M11, myMatrix.GetElement(0, 0));
Assert.AreEqual(matrix4.M12, myMatrix.GetElement(0, 1));
Assert.AreEqual(matrix4.M13, myMatrix.GetElement(0, 2));
Assert.AreEqual(matrix4.M14, myMatrix.GetElement(0, 3));
Assert.AreEqual(matrix4.M21, myMatrix.GetElement(1, 0));
Assert.AreEqual(matrix4.M22, myMatrix.GetElement(1, 1));
Assert.AreEqual(matrix4.M23, myMatrix.GetElement(1, 2));
Assert.AreEqual(matrix4.M24, myMatrix.GetElement(1, 3));
Assert.AreEqual(matrix4.M31, myMatrix.GetElement(2, 0));
Assert.AreEqual(matrix4.M32, myMatrix.GetElement(2, 1));
Assert.AreEqual(matrix4.M33, myMatrix.GetElement(2, 2));
Assert.AreEqual(matrix4.M34, myMatrix.GetElement(2, 3));
Assert.AreEqual(matrix4.M41, myMatrix.GetElement(3, 0));
Assert.AreEqual(matrix4.M42, myMatrix.GetElement(3, 1));
Assert.AreEqual(matrix4.M43, myMatrix.GetElement(3, 2));
Assert.AreEqual(matrix4.M44, myMatrix.GetElement(3, 3));
}
[TestMethod]
public void CreateScale()
{
// Use the Assert class to test conditions
MyVector scaleVector = new MyVector(30, 40, 50);
MyMatrix myMatrix = MyMatrix.CreateScale(scaleVector);
Matrix4 matrix4 = Matrix4.CreateScale(scaleVector.X, scaleVector.Y, scaleVector.Z);
Assert.AreEqual(matrix4.M11, myMatrix.GetElement(0, 0));
Assert.AreEqual(matrix4.M12, myMatrix.GetElement(0, 1));
Assert.AreEqual(matrix4.M13, myMatrix.GetElement(0, 2));
Assert.AreEqual(matrix4.M14, myMatrix.GetElement(0, 3));
Assert.AreEqual(matrix4.M21, myMatrix.GetElement(1, 0));
Assert.AreEqual(matrix4.M22, myMatrix.GetElement(1, 1));
Assert.AreEqual(matrix4.M23, myMatrix.GetElement(1, 2));
Assert.AreEqual(matrix4.M24, myMatrix.GetElement(1, 3));
Assert.AreEqual(matrix4.M31, myMatrix.GetElement(2, 0));
Assert.AreEqual(matrix4.M32, myMatrix.GetElement(2, 1));
Assert.AreEqual(matrix4.M33, myMatrix.GetElement(2, 2));
Assert.AreEqual(matrix4.M34, myMatrix.GetElement(2, 3));
Assert.AreEqual(matrix4.M41, myMatrix.GetElement(3, 0));
Assert.AreEqual(matrix4.M42, myMatrix.GetElement(3, 1));
Assert.AreEqual(matrix4.M43, myMatrix.GetElement(3, 2));
Assert.AreEqual(matrix4.M44, myMatrix.GetElement(3, 3));
}
[TestMethod]
public void CreateRotationX()
{
// Use the Assert class to test conditions
float angle = MathF.PI/4;
float cosAngle = MathF.Cos(angle);
float sinAngle = MathF.Sin(angle);
MyMatrix myMatrix = MyMatrix.CreateRotationX(angle);
Matrix4 matrix4 = Matrix4.CreateRotationX(angle);
Assert.AreEqual(matrix4.M11, myMatrix.GetElement(0, 0));
Assert.AreEqual(matrix4.M12, myMatrix.GetElement(0, 1));
Assert.AreEqual(matrix4.M13, myMatrix.GetElement(0, 2));
Assert.AreEqual(matrix4.M14, myMatrix.GetElement(0, 3));
Assert.AreEqual(matrix4.M21, myMatrix.GetElement(1, 0));
Assert.AreEqual(matrix4.M22, myMatrix.GetElement(1, 1));
Assert.AreEqual(matrix4.M23, myMatrix.GetElement(1, 2));
Assert.AreEqual(matrix4.M24, myMatrix.GetElement(1, 3));
Assert.AreEqual(matrix4.M31, myMatrix.GetElement(2, 0));
Assert.AreEqual(matrix4.M32, myMatrix.GetElement(2, 1));
Assert.AreEqual(matrix4.M33, myMatrix.GetElement(2, 2));
Assert.AreEqual(matrix4.M34, myMatrix.GetElement(2, 3));
Assert.AreEqual(matrix4.M41, myMatrix.GetElement(3, 0));
Assert.AreEqual(matrix4.M42, myMatrix.GetElement(3, 1));
Assert.AreEqual(matrix4.M43, myMatrix.GetElement(3, 2));
Assert.AreEqual(matrix4.M44, myMatrix.GetElement(3, 3));
}
[TestMethod]
public void CreateRotationY()
{
// Use the Assert class to test conditions
float angle = MathF.PI/4;
float cosAngle = MathF.Cos(angle);
float sinAngle = MathF.Sin(angle);
MyMatrix myMatrix = MyMatrix.CreateRotationY(angle);
Matrix4 matrix4 = Matrix4.CreateRotationY(angle);
Assert.AreEqual(matrix4.M11, myMatrix.GetElement(0, 0));
Assert.AreEqual(matrix4.M12, myMatrix.GetElement(0, 1));
Assert.AreEqual(matrix4.M13, myMatrix.GetElement(0, 2));
Assert.AreEqual(matrix4.M14, myMatrix.GetElement(0, 3));
Assert.AreEqual(matrix4.M21, myMatrix.GetElement(1, 0));
Assert.AreEqual(matrix4.M22, myMatrix.GetElement(1, 1));
Assert.AreEqual(matrix4.M23, myMatrix.GetElement(1, 2));
Assert.AreEqual(matrix4.M24, myMatrix.GetElement(1, 3));
Assert.AreEqual(matrix4.M31, myMatrix.GetElement(2, 0));
Assert.AreEqual(matrix4.M32, myMatrix.GetElement(2, 1));
Assert.AreEqual(matrix4.M33, myMatrix.GetElement(2, 2));
Assert.AreEqual(matrix4.M34, myMatrix.GetElement(2, 3));
Assert.AreEqual(matrix4.M41, myMatrix.GetElement(3, 0));
Assert.AreEqual(matrix4.M42, myMatrix.GetElement(3, 1));
Assert.AreEqual(matrix4.M43, myMatrix.GetElement(3, 2));
Assert.AreEqual(matrix4.M44, myMatrix.GetElement(3, 3));
}
[TestMethod]
public void CreateRotationZ()
{
// Use the Assert class to test conditions
float angle = MathF.PI / 4;
float cosAngle = MathF.Cos(angle);
float sinAngle = MathF.Sin(angle);
MyMatrix myMatrix = MyMatrix.CreateRotationZ(angle);
Matrix4 matrix4 = Matrix4.CreateRotationZ(angle);
Assert.AreEqual(matrix4.M11, myMatrix.GetElement(0, 0));
Assert.AreEqual(matrix4.M12, myMatrix.GetElement(0, 1));
Assert.AreEqual(matrix4.M13, myMatrix.GetElement(0, 2));
Assert.AreEqual(matrix4.M14, myMatrix.GetElement(0, 3));
Assert.AreEqual(matrix4.M21, myMatrix.GetElement(1, 0));
Assert.AreEqual(matrix4.M22, myMatrix.GetElement(1, 1));
Assert.AreEqual(matrix4.M23, myMatrix.GetElement(1, 2));
Assert.AreEqual(matrix4.M24, myMatrix.GetElement(1, 3));
Assert.AreEqual(matrix4.M31, myMatrix.GetElement(2, 0));
Assert.AreEqual(matrix4.M32, myMatrix.GetElement(2, 1));
Assert.AreEqual(matrix4.M33, myMatrix.GetElement(2, 2));
Assert.AreEqual(matrix4.M34, myMatrix.GetElement(2, 3));
Assert.AreEqual(matrix4.M41, myMatrix.GetElement(3, 0));
Assert.AreEqual(matrix4.M42, myMatrix.GetElement(3, 1));
Assert.AreEqual(matrix4.M43, myMatrix.GetElement(3, 2));
Assert.AreEqual(matrix4.M44, myMatrix.GetElement(3, 3));
}
[TestMethod]
public void MultiplyVector()
{
// Use the Assert class to test conditions
MyVector myVector = new MyVector(30, 40, 0);
MyVector translationVector = new MyVector(10, 20, 30);
MyMatrix translationMatrix = MyMatrix.CreateTranslation(translationVector);
MyVector translatedVector = translationMatrix.Multiply(myVector);
Matrix4 translationMatrix4 = Matrix4.CreateTranslation(translationVector.X, translationVector.Y, translationVector.Z);
Vector4 vector4 = new Vector4(myVector.X, myVector.Y, myVector.Z, myVector.W);
Vector4 translatedVector4 = translationMatrix4 * vector4;
Assert.AreEqual(translatedVector4.X, translatedVector.X);
Assert.AreEqual(translatedVector4.Y, translatedVector.Y);
Assert.AreEqual(translatedVector4.Z, translatedVector.Z);
Assert.AreEqual(translatedVector4.W, translatedVector.W);
MyVector scaleVector = new MyVector(2, 2, 2);
MyMatrix scaleMatrix = MyMatrix.CreateScale(scaleVector);
MyVector scaledVector = scaleMatrix.Multiply(myVector);
Matrix4 scaleMatrix4 = Matrix4.CreateScale(scaleVector.X, scaleVector.Y, scaleVector.Z);
vector4 = new Vector4(myVector.X, myVector.Y, myVector.Z, myVector.W);
Vector4 scaledVector4 = scaleMatrix4 * vector4;
Assert.AreEqual(scaledVector4.X, scaledVector.X);
Assert.AreEqual(scaledVector4.Y, scaledVector.Y);
Assert.AreEqual(scaledVector4.Z, scaledVector.Z);
Assert.AreEqual(scaledVector4.W, scaledVector.W);
float angle = MathF.PI / 4;
MyMatrix rotationMatrix = MyMatrix.CreateRotationZ(angle);
MyVector rotatedVector = rotationMatrix.Multiply(myVector);
Matrix4 rotationMatrix4 = Matrix4.CreateRotationZ(angle);
vector4 = new Vector4(myVector.X, myVector.Y, myVector.Z, myVector.W);
Vector4 rotatedVector4 = rotationMatrix4 * vector4;
Assert.AreEqual(rotatedVector4.X, rotatedVector.X);
Assert.AreEqual(rotatedVector4.Y, rotatedVector.Y);
Assert.AreEqual(rotatedVector4.Z, rotatedVector.Z);
Assert.AreEqual(rotatedVector4.W, rotatedVector.W);
}
[TestMethod]
public void Multiply()
{
MyVector myVector = new MyVector(30, 40, 0);
MyVector translationVector = new MyVector(10, 20, 30);
MyMatrix translationMatrix = MyMatrix.CreateTranslation(translationVector);
float angle = MathF.PI / 4;
MyMatrix rotationMatrix = MyMatrix.CreateRotationZ(angle);
MyVector scaleVector = new MyVector(2, 2, 2);
MyMatrix scaleMatrix = MyMatrix.CreateScale(scaleVector);
Matrix4 translationMatrix4 = Matrix4.CreateTranslation(translationVector.X, translationVector.Y, translationVector.Z);
Matrix4 rotationMatrix4 = Matrix4.CreateRotationZ(angle);
Matrix4 scaleMatrix4 = Matrix4.CreateScale(scaleVector.X, scaleVector.Y, scaleVector.Z);
MyMatrix scaleXTranslationMatrix = scaleMatrix.Multiply(translationMatrix);
Matrix4 scaleXTranslationMatrix4 = scaleMatrix4 * translationMatrix4;
Assert.AreEqual(scaleXTranslationMatrix4.M11, scaleXTranslationMatrix.GetElement(0, 0));
Assert.AreEqual(scaleXTranslationMatrix4.M12, scaleXTranslationMatrix.GetElement(0, 1));
Assert.AreEqual(scaleXTranslationMatrix4.M13, scaleXTranslationMatrix.GetElement(0, 2));
Assert.AreEqual(scaleXTranslationMatrix4.M14, scaleXTranslationMatrix.GetElement(0, 3));
Assert.AreEqual(scaleXTranslationMatrix4.M21, scaleXTranslationMatrix.GetElement(1, 0));
Assert.AreEqual(scaleXTranslationMatrix4.M22, scaleXTranslationMatrix.GetElement(1, 1));
Assert.AreEqual(scaleXTranslationMatrix4.M23, scaleXTranslationMatrix.GetElement(1, 2));
Assert.AreEqual(scaleXTranslationMatrix4.M24, scaleXTranslationMatrix.GetElement(1, 3));
Assert.AreEqual(scaleXTranslationMatrix4.M31, scaleXTranslationMatrix.GetElement(2, 0));
Assert.AreEqual(scaleXTranslationMatrix4.M32, scaleXTranslationMatrix.GetElement(2, 1));
Assert.AreEqual(scaleXTranslationMatrix4.M33, scaleXTranslationMatrix.GetElement(2, 2));
Assert.AreEqual(scaleXTranslationMatrix4.M34, scaleXTranslationMatrix.GetElement(2, 3));
Assert.AreEqual(scaleXTranslationMatrix4.M41, scaleXTranslationMatrix.GetElement(3, 0));
Assert.AreEqual(scaleXTranslationMatrix4.M42, scaleXTranslationMatrix.GetElement(3, 1));
Assert.AreEqual(scaleXTranslationMatrix4.M43, scaleXTranslationMatrix.GetElement(3, 2));
Assert.AreEqual(scaleXTranslationMatrix4.M44, scaleXTranslationMatrix.GetElement(3, 3));
MyMatrix translationXScaleMatrix = translationMatrix.Multiply(scaleMatrix);
Matrix4 translationXScaleMatrix4 = translationMatrix4 * scaleMatrix4;
Assert.AreEqual(translationXScaleMatrix4.M11, translationXScaleMatrix.GetElement(0, 0));
Assert.AreEqual(translationXScaleMatrix4.M12, translationXScaleMatrix.GetElement(0, 1));
Assert.AreEqual(translationXScaleMatrix4.M13, translationXScaleMatrix.GetElement(0, 2));
Assert.AreEqual(translationXScaleMatrix4.M14, translationXScaleMatrix.GetElement(0, 3));
Assert.AreEqual(translationXScaleMatrix4.M21, translationXScaleMatrix.GetElement(1, 0));
Assert.AreEqual(translationXScaleMatrix4.M22, translationXScaleMatrix.GetElement(1, 1));
Assert.AreEqual(translationXScaleMatrix4.M23, translationXScaleMatrix.GetElement(1, 2));
Assert.AreEqual(translationXScaleMatrix4.M24, translationXScaleMatrix.GetElement(1, 3));
Assert.AreEqual(translationXScaleMatrix4.M31, translationXScaleMatrix.GetElement(2, 0));
Assert.AreEqual(translationXScaleMatrix4.M32, translationXScaleMatrix.GetElement(2, 1));
Assert.AreEqual(translationXScaleMatrix4.M33, translationXScaleMatrix.GetElement(2, 2));
Assert.AreEqual(translationXScaleMatrix4.M34, translationXScaleMatrix.GetElement(2, 3));
Assert.AreEqual(translationXScaleMatrix4.M41, translationXScaleMatrix.GetElement(3, 0));
Assert.AreEqual(translationXScaleMatrix4.M42, translationXScaleMatrix.GetElement(3, 1));
Assert.AreEqual(translationXScaleMatrix4.M43, translationXScaleMatrix.GetElement(3, 2));
Assert.AreEqual(translationXScaleMatrix4.M44, translationXScaleMatrix.GetElement(3, 3));
MyMatrix chainedMatrix = translationMatrix.Multiply(scaleMatrix).Multiply(rotationMatrix);
Matrix4 chainedMatrix4 = translationMatrix4 * scaleMatrix4 * rotationMatrix4;
float cosAngle = MathF.Cos(angle);
float sinAngle = MathF.Sin(angle);
Assert.AreEqual(chainedMatrix4.M11, chainedMatrix.GetElement(0, 0));
Assert.AreEqual(chainedMatrix4.M12, chainedMatrix.GetElement(0, 1));
Assert.AreEqual(chainedMatrix4.M13, chainedMatrix.GetElement(0, 2));
Assert.AreEqual(chainedMatrix4.M14, chainedMatrix.GetElement(0, 3));
Assert.AreEqual(chainedMatrix4.M21, chainedMatrix.GetElement(1, 0));
Assert.AreEqual(chainedMatrix4.M22, chainedMatrix.GetElement(1, 1));
Assert.AreEqual(chainedMatrix4.M23, chainedMatrix.GetElement(1, 2));
Assert.AreEqual(chainedMatrix4.M24, chainedMatrix.GetElement(1, 3));
Assert.AreEqual(chainedMatrix4.M31, chainedMatrix.GetElement(2, 0));
Assert.AreEqual(chainedMatrix4.M32, chainedMatrix.GetElement(2, 1));
Assert.AreEqual(chainedMatrix4.M33, chainedMatrix.GetElement(2, 2));
Assert.AreEqual(chainedMatrix4.M34, chainedMatrix.GetElement(2, 3));
Assert.AreEqual(chainedMatrix4.M41, chainedMatrix.GetElement(3, 0));
Assert.AreEqual(chainedMatrix4.M42, chainedMatrix.GetElement(3, 1));
Assert.AreEqual(chainedMatrix4.M43, chainedMatrix.GetElement(3, 2));
Assert.AreEqual(chainedMatrix4.M44, chainedMatrix.GetElement(3, 3));
}
[TestMethod]
public void Inverse()
{
MyVector translationVector = new MyVector(20, 10, 5);
MyMatrix translationMatrix = MyMatrix.CreateTranslation(translationVector);
MyVector scaleVector = new MyVector(2, 2, 2);
MyMatrix scaleMatrix = MyMatrix.CreateScale(scaleVector);
float angle = MathF.PI / 2;
MyMatrix rotationZMatrix = MyMatrix.CreateRotationZ(angle);
MyMatrix multipliedMatrix = translationMatrix.Multiply(scaleMatrix).Multiply(rotationZMatrix);
MyMatrix inverseMatrix = multipliedMatrix.Inverse();
MyMatrix identityMatrix = multipliedMatrix.Multiply(inverseMatrix);
Assert.AreEqual(1, identityMatrix.GetElement(0, 0), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(0, 1), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(0, 2), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(0, 3), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(1, 0), 0.001);
Assert.AreEqual(1, identityMatrix.GetElement(1, 1), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(1, 2), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(1, 3), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(2, 0), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(2, 1), 0.001);
Assert.AreEqual(1, identityMatrix.GetElement(2, 2), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(2, 3), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(3, 0), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(3, 1), 0.001);
Assert.AreEqual(0, identityMatrix.GetElement(3, 2), 0.001);
Assert.AreEqual(1, identityMatrix.GetElement(3, 3), 0.001);
Matrix4 translationMatrix4 = Matrix4.CreateTranslation(translationVector.X, translationVector.Y, translationVector.Z);
Matrix4 scaleMatrix4 = Matrix4.CreateScale(scaleVector.X, scaleVector.Y, scaleVector.Z);
Matrix4 rotationZMatrix4 = Matrix4.CreateRotationZ(angle);
Matrix4 multipliedMatrix4 = translationMatrix4 * scaleMatrix4 * rotationZMatrix4;
Matrix4 inverseMatrix4 = Matrix4.Invert(multipliedMatrix4);
Assert.AreEqual(inverseMatrix4.M11, inverseMatrix.GetElement(0, 0));
Assert.AreEqual(inverseMatrix4.M12, inverseMatrix.GetElement(0, 1));
Assert.AreEqual(inverseMatrix4.M13, inverseMatrix.GetElement(0, 2));
Assert.AreEqual(inverseMatrix4.M14, inverseMatrix.GetElement(0, 3));
Assert.AreEqual(inverseMatrix4.M21, inverseMatrix.GetElement(1, 0));
Assert.AreEqual(inverseMatrix4.M22, inverseMatrix.GetElement(1, 1));
Assert.AreEqual(inverseMatrix4.M23, inverseMatrix.GetElement(1, 2));
Assert.AreEqual(inverseMatrix4.M24, inverseMatrix.GetElement(1, 3));
Assert.AreEqual(inverseMatrix4.M31, inverseMatrix.GetElement(2, 0));
Assert.AreEqual(inverseMatrix4.M32, inverseMatrix.GetElement(2, 1));
Assert.AreEqual(inverseMatrix4.M33, inverseMatrix.GetElement(2, 2));
Assert.AreEqual(inverseMatrix4.M34, inverseMatrix.GetElement(2, 3));
Assert.AreEqual(inverseMatrix4.M41, inverseMatrix.GetElement(3, 0));
Assert.AreEqual(inverseMatrix4.M42, inverseMatrix.GetElement(3, 1));
Assert.AreEqual(inverseMatrix4.M43, inverseMatrix.GetElement(3, 2));
Assert.AreEqual(inverseMatrix4.M44, inverseMatrix.GetElement(3, 3));
}
[TestMethod]
public void ToMatrix4()
{
MyMatrix myMatrix = new MyMatrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
Matrix4 matrix4 = new Matrix4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
Matrix4 matrix4Convert = myMatrix.ToMatrix4();
Assert.AreEqual(matrix4.M11, matrix4Convert.M11);
Assert.AreEqual(matrix4.M12, matrix4Convert.M12);
Assert.AreEqual(matrix4.M13, matrix4Convert.M13);
Assert.AreEqual(matrix4.M14, matrix4Convert.M14);
Assert.AreEqual(matrix4.M21, matrix4Convert.M21);
Assert.AreEqual(matrix4.M22, matrix4Convert.M22);
Assert.AreEqual(matrix4.M23, matrix4Convert.M23);
Assert.AreEqual(matrix4.M24, matrix4Convert.M24);
Assert.AreEqual(matrix4.M31, matrix4Convert.M31);
Assert.AreEqual(matrix4.M32, matrix4Convert.M32);
Assert.AreEqual(matrix4.M33, matrix4Convert.M33);
Assert.AreEqual(matrix4.M34, matrix4Convert.M34);
Assert.AreEqual(matrix4.M41, matrix4Convert.M41);
Assert.AreEqual(matrix4.M42, matrix4Convert.M42);
Assert.AreEqual(matrix4.M43, matrix4Convert.M43);
Assert.AreEqual(matrix4.M44, matrix4Convert.M44);
}
}
}