fix: eraser can handle dots without regressing prior performance improvements (#9946)

Co-authored-by: Márk Tolmács <mark@lazycat.hu>
This commit is contained in:
Christopher Tangonan
2025-09-14 04:33:43 -07:00
committed by GitHub
parent 204e06b77b
commit 1161f1b8ba
3 changed files with 176 additions and 4 deletions

View File

@@ -177,3 +177,19 @@ export function lineSegmentIntersectionPoints<
return candidate;
}
export function lineSegmentsDistance<Point extends GlobalPoint | LocalPoint>(
s1: LineSegment<Point>,
s2: LineSegment<Point>,
): number {
if (lineSegmentIntersectionPoints(s1, s2)) {
return 0;
}
return Math.min(
distanceToLineSegment(s1[0], s2),
distanceToLineSegment(s1[1], s2),
distanceToLineSegment(s2[0], s1),
distanceToLineSegment(s2[1], s1),
);
}