Files
OpenNest/OpenNest.Core/Geometry/CollisionResult.cs
AJ Isaacs 8f2fbee02c feat: add Collision static class with Sutherland-Hodgman clipping and tests
Polygon-polygon collision detection using convex decomposition (ear-clipping
triangulation) followed by Sutherland-Hodgman clipping on each triangle pair.
Handles overlapping, non-overlapping, edge-touching, containment, and concave
polygons. Includes hole subtraction support for future use.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 09:35:41 -04:00

24 lines
769 B
C#

using System.Collections.Generic;
using System.Linq;
namespace OpenNest.Geometry
{
public class CollisionResult
{
public static readonly CollisionResult None = new(false, new List<Polygon>(), new List<Vector>());
public CollisionResult(bool overlaps, List<Polygon> overlapRegions, List<Vector> intersectionPoints)
{
Overlaps = overlaps;
OverlapRegions = overlapRegions;
IntersectionPoints = intersectionPoints;
OverlapArea = overlapRegions.Sum(r => r.Area());
}
public bool Overlaps { get; }
public IReadOnlyList<Polygon> OverlapRegions { get; }
public IReadOnlyList<Vector> IntersectionPoints { get; }
public double OverlapArea { get; }
}
}