Skip to content

Commit 4f2cec0

Browse files
authored
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)
1 parent e9423d6 commit 4f2cec0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cadquery/cq.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,11 @@ def radiusArc(
22312231
# Calculate the sagitta from the radius
22322232
length = endPoint.sub(startPoint).Length / 2.0
22332233
try:
2234-
sag = abs(radius) - math.sqrt(radius ** 2 - length ** 2)
2234+
sag = abs(radius)
2235+
r_2_l_2 = radius ** 2 - length ** 2
2236+
# Float imprecision can lead slightly negative values: consider them as zeros
2237+
if abs(r_2_l_2) >= TOL:
2238+
sag -= math.sqrt(r_2_l_2)
22352239
except ValueError:
22362240
raise ValueError("Arc radius is not large enough to reach the end point.")
22372241

0 commit comments

Comments
 (0)