diff --git a/src/PolyZone/Shapes/Polygon.cs b/src/PolyZone/Shapes/Polygon.cs index 025e376..7d3ff7d 100644 --- a/src/PolyZone/Shapes/Polygon.cs +++ b/src/PolyZone/Shapes/Polygon.cs @@ -13,9 +13,11 @@ namespace PolyZone.Shapes; public class Polygon(IReadOnlyList points) : IPolygon { - public bool IsInside(in Vector2 point) => IsInside(point, points); + public readonly IReadOnlyList _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 polygon) {