Files
sbox-public/engine/Sandbox.Test/System/Math/MatrixTest.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

40 lines
886 B
C#

namespace TestSystem.Math;
[TestClass]
public class MatrixTest
{
[TestMethod]
public void FromTransform()
{
var transform = new Transform(
new Vector3( 100, 420, 340 ),
Rotation.From( 90, 0, 45 ),
2.0f
);
var mat = Matrix.FromTransform( transform );
var expectedScale = Matrix.CreateScale( transform.Scale );
var expectedRotation = Matrix.CreateRotation( transform.Rotation );
var expectedTranslation = Matrix.CreateTranslation( transform.Position );
var expectedMatrix = expectedScale * expectedRotation * expectedTranslation;
Assert.AreEqual( mat, expectedMatrix );
}
[TestMethod]
public void ToTransform()
{
var transform = new Transform(
new Vector3( 100, 420, 340 ),
Rotation.From( 90, 0, 45 ),
2.0f
);
var mat = Matrix.FromTransform( transform );
var tx = mat.ExtractTransform();
Assert.AreEqual( transform, tx );
}
}