From 230a11d32e9a4c5444415a05044934721dcfa4ff Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sun, 29 Mar 2026 09:32:51 -0400 Subject: [PATCH] feat: add CollisionResult data class for polygon collision detection Immutable result type that holds overlap flag, overlap regions (as polygons), intersection points, and computed overlap area. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest.Core/Geometry/CollisionResult.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 OpenNest.Core/Geometry/CollisionResult.cs diff --git a/OpenNest.Core/Geometry/CollisionResult.cs b/OpenNest.Core/Geometry/CollisionResult.cs new file mode 100644 index 0000000..095613f --- /dev/null +++ b/OpenNest.Core/Geometry/CollisionResult.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Linq; + +namespace OpenNest.Geometry +{ + public class CollisionResult + { + public static readonly CollisionResult None = new(false, new List(), new List()); + + public CollisionResult(bool overlaps, List overlapRegions, List intersectionPoints) + { + Overlaps = overlaps; + OverlapRegions = overlapRegions; + IntersectionPoints = intersectionPoints; + OverlapArea = overlapRegions.Sum(r => r.Area()); + } + + public bool Overlaps { get; } + public List OverlapRegions { get; } + public List IntersectionPoints { get; } + public double OverlapArea { get; } + } +}