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) <noreply@anthropic.com>
This commit is contained in:
23
OpenNest.Core/Geometry/CollisionResult.cs
Normal file
23
OpenNest.Core/Geometry/CollisionResult.cs
Normal file
@@ -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<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 List<Polygon> OverlapRegions { get; }
|
||||
public List<Vector> IntersectionPoints { get; }
|
||||
public double OverlapArea { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user