better error check in arc()

bugfix for join_path()
modifications for bevel gear to support internal teeth
This commit is contained in:
Adrian Mariano
2023-10-18 20:24:48 -04:00
parent 7d2b547efc
commit e1876c3432
3 changed files with 85 additions and 64 deletions

View File

@@ -851,6 +851,7 @@ function _path_join(paths,joint,k=0.5,i=0,result=[],relocate=true,closed=false)
d_next = is_vector(joint[i]) ? joint[i][1] : joint[i]
)
assert(d_first>=0 && d_next>=0, str("Joint value negative when adding path ",i+1))
assert(d_first<path_length(revresult),str("Path ",i," is too short for specified cut distance ",d_first))
assert(d_next<path_length(nextpath), str("Path ",i+1," is too short for specified cut distance ",d_next))
let(
@@ -861,7 +862,8 @@ function _path_join(paths,joint,k=0.5,i=0,result=[],relocate=true,closed=false)
let(
first_dir=firstcut[2],
next_dir=nextcut[2],
corner = line_intersection([firstcut[0], firstcut[0]-first_dir], [nextcut[0], nextcut[0]-next_dir],RAY,RAY)
corner = approx(firstcut[0],nextcut[0]) ? firstcut[0]
: line_intersection([firstcut[0], firstcut[0]-first_dir], [nextcut[0], nextcut[0]-next_dir],RAY,RAY)
)
assert(is_def(corner), str("Curve directions at cut points don't intersect in a corner when ",
loop?"closing the path":str("adding path ",i+1)))