From 4f2cec0f5ee21041a1f8c80f161334f349180933 Mon Sep 17 00:00:00 2001 From: Diorcet Yann Date: Tue, 26 Mar 2024 18:00:15 +0100 Subject: [PATCH] radiusArc: due to float looseness the length computation can be slightly over radius length, leading to a ValueError exception. Using TOL value in order to remove this issue (#1528) --- cadquery/cq.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cadquery/cq.py b/cadquery/cq.py index c8c3853c0..c1fcfe1ad 100644 --- a/cadquery/cq.py +++ b/cadquery/cq.py @@ -2231,7 +2231,11 @@ def radiusArc( # Calculate the sagitta from the radius length = endPoint.sub(startPoint).Length / 2.0 try: - sag = abs(radius) - math.sqrt(radius ** 2 - length ** 2) + sag = abs(radius) + r_2_l_2 = radius ** 2 - length ** 2 + # Float imprecision can lead slightly negative values: consider them as zeros + if abs(r_2_l_2) >= TOL: + sag -= math.sqrt(r_2_l_2) except ValueError: raise ValueError("Arc radius is not large enough to reach the end point.")