refactor: added forgotten epsilon for Shape2D.ApproximatelyEquals

This commit is contained in:
2025-03-21 22:33:05 +03:00
parent b2a286b5e5
commit 30caa202dc
6 changed files with 19 additions and 42 deletions

View File

@@ -198,13 +198,13 @@ public readonly struct Shape2D(List<Vector2D> vertices) : IEnumerable<Vector2D>
/// <param name="left">The first shape to compare.</param>
/// <param name="right">The second shape to compare.</param>
/// <returns><c>true</c> if the shapes are approximately equal; otherwise, <c>false</c>.</returns>
public static bool ApproximatelyEquals(Shape2D left, Shape2D right)
public static bool ApproximatelyEquals(Shape2D left, Shape2D right, float epsilon = float.Epsilon)
{
if (left.Vertices.Count != right.Vertices.Count)
return false;
for (int i = 0; i < left.Vertices.Count; i++)
if (!left.Vertices[i].ApproximatelyEquals(right.Vertices[i]))
if (!left.Vertices[i].ApproximatelyEquals(right.Vertices[i], epsilon))
return false;
return true;
@@ -282,11 +282,5 @@ public static class Shape2DExtensions
/// <param name="to">The transformed shape.</param>
public static void TransformShape(this ITransform transform, Shape2D from, ref Shape2D to) => Shape2D.TransformShape(from, transform, ref to);
/// <summary>
/// Determines whether two shapes are approximately equal.
/// </summary>
/// <param name="left">The first shape to compare.</param>
/// <param name="right">The second shape to compare.</param>
/// <returns><c>true</c> if the shapes are approximately equal; otherwise, <c>false</c>.</returns>
public static bool ApproximatelyEquals(this Shape2D left, Shape2D right) => Shape2D.ApproximatelyEquals(left, right);
public static bool ApproximatelyEquals(this Shape2D left, Shape2D right, float epsilon = float.Epsilon) => Shape2D.ApproximatelyEquals(left, right, epsilon);
}