Add closed param to kerf()
Allow for non close line segments and handle ends correctly
This commit is contained in:
parent
de7a168377
commit
33681db645
|
@ -83,7 +83,7 @@ def mmul(m0, m1):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def kerf(points, k):
|
def kerf(points, k, closed=True):
|
||||||
"""Outset points by k
|
"""Outset points by k
|
||||||
Assumes a closed loop of points
|
Assumes a closed loop of points
|
||||||
"""
|
"""
|
||||||
|
@ -94,6 +94,12 @@ def kerf(points, k):
|
||||||
# get normalized orthogonals of both segments
|
# get normalized orthogonals of both segments
|
||||||
v1 = vorthogonal(normalize(vdiff(points[i - 1], points[i])))
|
v1 = vorthogonal(normalize(vdiff(points[i - 1], points[i])))
|
||||||
v2 = vorthogonal(normalize(vdiff(points[i], points[(i + 1) % lp])))
|
v2 = vorthogonal(normalize(vdiff(points[i], points[(i + 1) % lp])))
|
||||||
|
|
||||||
|
if not closed:
|
||||||
|
if i == 0:
|
||||||
|
v1 = v2
|
||||||
|
if i == lp-1:
|
||||||
|
v2 = v1
|
||||||
# direction the point has to move
|
# direction the point has to move
|
||||||
d = normalize(vadd(v1, v2))
|
d = normalize(vadd(v1, v2))
|
||||||
# cos of the half the angle between the segments
|
# cos of the half the angle between the segments
|
||||||
|
|
Loading…
Reference in New Issue