mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-15 14:52:35 +02:00
RobustToolbox projects should be named Robust.* This PR changes the RobustToolbox projects from SS14.* to Robust.* Updates SS14.* prefixes/namespaces to Robust.* Updates SpaceStation14.sln to RobustToolbox.sln Updates MSBUILD/SS14.* to MSBUILD/Robust.* Updates CSProject and MSBuild references for the above Updates git_helper.py Removes Runserver and Runclient as they are unusable
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using NUnit.Framework;
|
|
using Robust.Client.Utility;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.UnitTesting.Client.Utility
|
|
{
|
|
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
|
|
[TestFixture]
|
|
[TestOf(typeof(GodotConversions))]
|
|
class GodotConversionsTest
|
|
{
|
|
[Test]
|
|
public void TestTransform2DConversion()
|
|
{
|
|
var matrix = Matrix3.Identity;
|
|
var xform = matrix.Convert();
|
|
var vec = new Vector2(5, 7);
|
|
|
|
Assert.That(Xform(vec, xform), Is.EqualTo(matrix.Transform(vec)));
|
|
|
|
matrix = new Matrix3(0.75f, 0.20f, 5,
|
|
0.66f, 0.15f, 5,
|
|
0, 0, 1);
|
|
xform = matrix.Convert();
|
|
Assert.That(Xform(vec, xform), Is.EqualTo(matrix.Transform(vec)));
|
|
Assert.That(Xform(vec, xform.Convert()), Is.EqualTo(matrix.Transform(vec)));
|
|
vec = Vector2.Zero;
|
|
Assert.That(Xform(vec, xform), Is.EqualTo(matrix.Transform(vec)));
|
|
Assert.That(Xform(vec, xform.Convert()), Is.EqualTo(matrix.Transform(vec)));
|
|
}
|
|
|
|
private static Vector2 Xform(Vector2 vector, Matrix3 matrix)
|
|
{
|
|
var vec3 = new Vector3(vector.X, vector.Y, 1);
|
|
matrix.Transform(ref vec3);
|
|
return new Vector2(vec3.X, vec3.Y);
|
|
}
|
|
|
|
private static Vector2 Xform(Vector2 vector, Godot.Transform2D transform)
|
|
{
|
|
return transform.Xform(vector.Convert()).Convert();
|
|
}
|
|
}
|
|
}
|