mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-24 21:57:42 -05:00
fix(geometry): give tangent circles their tangent point, never NaN
Circle-circle intersection passed its containment test for internally tangent circles while roundoff left r^2 - a^2 a hair below zero, so the tangent point came back NaN. Material capture refused such parts as "nonfinite program coordinates" and Plan Cutting fell back to a best-effort plan: N26-2JJ's crescents (an inner arc tangent to the outer one) failed whenever they were rotated 180 degrees, but only on the live DWG geometry, since saving rounds the program and hides it. Clamp r^2 - a^2 at zero. The externally tangent lead in NativeContactRegressionTests is now refused on its contact rather than as an incomplete check. The problem-nest corpus is identical to master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3108fdb64a
commit
1972aa17c5
3 files changed
+87
-3
No files matched your search
@@ -156,7 +156,9 @@ namespace OpenNest.Geometry
|
||||
- circle2.Radius * circle2.Radius
|
||||
+ distance * distance
|
||||
) / (2.0 * distance);
|
||||
var h = System.Math.Sqrt(circle1.Radius * circle1.Radius - a * a);
|
||||
// The checks above make r^2 - a^2 nonnegative in exact arithmetic. For tangent circles
|
||||
// roundoff can leave it a hair below zero: that is the tangent point, not NaN.
|
||||
var h = System.Math.Sqrt(System.Math.Max(circle1.Radius * circle1.Radius - a * a, 0));
|
||||
|
||||
var pt = new Vector(
|
||||
circle1.Center.X + (a * d.X) / distance,
|
||||
|
||||
Reference in new issue
Block a user