Skip to content

Commit

Permalink
radiusArc: due to float looseness the length computation can be sligh…
Browse files Browse the repository at this point in the history
…tly over radius length, leading to a ValueError exception. Using TOL value in order to remove this issue (#1528)
  • Loading branch information
diorcety authored Mar 26, 2024
1 parent e9423d6 commit 4f2cec0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cadquery/cq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down

0 comments on commit 4f2cec0

Please sign in to comment.