mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Add grid merging (#3627)
* Add grid merging * More preliminary cleanup * Fixes * Fixes * weh * tweaks * Tests * weh * Fix direction test * Release notes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -258,7 +259,24 @@ namespace Robust.Shared.Maths
|
||||
/// <param name="degrees">The angle in degrees.</param>
|
||||
public static Angle FromDegrees(double degrees)
|
||||
{
|
||||
return new(MathHelper.DegreesToRadians(degrees));
|
||||
// Avoid rounding issues with common use cases.
|
||||
switch (degrees)
|
||||
{
|
||||
case -270:
|
||||
return new Angle(Math.PI * -1.5);
|
||||
case 90:
|
||||
return new Angle(Math.PI / 2);
|
||||
case -180:
|
||||
return new Angle(-Math.PI);
|
||||
case 180:
|
||||
return new Angle(Math.PI);
|
||||
case 270.0:
|
||||
return new Angle(Math.PI * 1.5);
|
||||
case -90:
|
||||
return new Angle(Math.PI / -2);
|
||||
default:
|
||||
return new(MathHelper.DegreesToRadians(degrees));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -109,6 +109,11 @@ namespace Robust.Shared.Maths
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2i Rotate(Angle angle)
|
||||
{
|
||||
return (Vector2i) angle.RotateVec(this);
|
||||
}
|
||||
|
||||
public static Vector2i operator -(Vector2i a, Vector2i b)
|
||||
{
|
||||
return new(a.X - b.X, a.Y - b.Y);
|
||||
|
||||
Reference in New Issue
Block a user