Skip to content

Commit

Permalink
Update Polygon.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Twinki14 committed Jan 1, 2024
1 parent cdcd4a5 commit cf6a8f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/PolyZone/Shapes/Polygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ namespace PolyZone.Shapes;

public class Polygon(IReadOnlyList<Vector2> points) : IPolygon
{
public bool IsInside(in Vector2 point) => IsInside(point, points);
public readonly IReadOnlyList<Vector2> _points = points;

public bool IsInside(in Vector2 point) => IsInside(point, _points);

public float DistanceTo(in Vector2 point) => DistanceTo(point, points);
public float DistanceTo(in Vector2 point) => DistanceTo(point, _points);

private static bool IsInside(in Vector2 point, IReadOnlyList<Vector2> polygon)
{
Expand Down

0 comments on commit cf6a8f4

Please sign in to comment.