From d27b5c55d38018537efbcbc5f258b3ed39af363e Mon Sep 17 00:00:00 2001 From: thatcosmonaut Date: Thu, 31 Oct 2019 15:57:04 -0700 Subject: [PATCH] remove monogame dependency --- Structs/MathHelper.cs | 10 ++++++++++ Structs/Position2D.cs | 2 +- Structs/Structs.csproj | 5 +---- Structs/Transform2D.cs | 12 ++++++------ Tests/Position2DTest.cs | 3 ++- Tests/Transform2DTest.cs | 3 ++- 6 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 Structs/MathHelper.cs diff --git a/Structs/MathHelper.cs b/Structs/MathHelper.cs new file mode 100644 index 0000000..fc020f5 --- /dev/null +++ b/Structs/MathHelper.cs @@ -0,0 +1,10 @@ +namespace MoonTools.Core.Structs +{ + public static class MathHelper + { + public static double ToRadians(double angle) + { + return (System.Math.PI / 180) * angle; + } + } +} \ No newline at end of file diff --git a/Structs/Position2D.cs b/Structs/Position2D.cs index 24db499..4d0725a 100644 --- a/Structs/Position2D.cs +++ b/Structs/Position2D.cs @@ -1,5 +1,5 @@ using System; -using Microsoft.Xna.Framework; +using System.Numerics; namespace MoonTools.Core.Structs { diff --git a/Structs/Structs.csproj b/Structs/Structs.csproj index 97ca14c..326d91c 100644 --- a/Structs/Structs.csproj +++ b/Structs/Structs.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + netstandard2.1 MoonTools.Core.Structs MoonTools.Core.Structs 1.1.0 @@ -14,7 +14,4 @@ https://github.com/MoonsideGames/MoonTools.Core.Structs LGPL-3.0-only - - - \ No newline at end of file diff --git a/Structs/Transform2D.cs b/Structs/Transform2D.cs index 52fe7a0..aab7338 100644 --- a/Structs/Transform2D.cs +++ b/Structs/Transform2D.cs @@ -1,5 +1,5 @@ using System; -using Microsoft.Xna.Framework; +using System.Numerics; namespace MoonTools.Core.Structs { @@ -16,7 +16,7 @@ namespace MoonTools.Core.Structs private float _rotation; private Vector2 _scale; - public Matrix TransformMatrix { get; private set; } + public Matrix4x4 TransformMatrix { get; private set; } public Position2D Position { @@ -119,11 +119,11 @@ namespace MoonTools.Core.Structs return new Transform2D(Position + other.Position, Rotation + other.Rotation, Scale * other.Scale); } - private static Matrix CreateTransformMatrix(Position2D translation, float rotationDegrees, Vector2 scale) + private static Matrix4x4 CreateTransformMatrix(Position2D translation, float rotation, Vector2 scale) { - return Matrix.CreateScale(scale.X, scale.Y, 1) * - Matrix.CreateRotationZ(Microsoft.Xna.Framework.MathHelper.ToRadians(rotationDegrees)) * - Matrix.CreateTranslation(translation.X, translation.Y, 0); + return Matrix4x4.CreateScale(scale.X, scale.Y, 1) * + Matrix4x4.CreateRotationZ(rotation) * + Matrix4x4.CreateTranslation(translation.X, translation.Y, 0); } public override bool Equals(Object other) diff --git a/Tests/Position2DTest.cs b/Tests/Position2DTest.cs index 675c1b2..c566fc2 100644 --- a/Tests/Position2DTest.cs +++ b/Tests/Position2DTest.cs @@ -1,7 +1,8 @@ using FluentAssertions; -using Microsoft.Xna.Framework; using NUnit.Framework; + using MoonTools.Core.Structs; +using System.Numerics; namespace Tests { diff --git a/Tests/Transform2DTest.cs b/Tests/Transform2DTest.cs index 018e941..32372f7 100644 --- a/Tests/Transform2DTest.cs +++ b/Tests/Transform2DTest.cs @@ -1,7 +1,8 @@ using FluentAssertions; -using Microsoft.Xna.Framework; using NUnit.Framework; + using MoonTools.Core.Structs; +using System.Numerics; namespace Tests {