mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Remove redundant collinear points from bezpath_curve() output.
This commit is contained in:
parent
8ea8ebf341
commit
ebb98b47d2
1 changed files with 9 additions and 6 deletions
|
@ -466,12 +466,15 @@ function bezpath_curve(bezpath, splinesteps=16, N=3, endpoint=true) =
|
||||||
assert(len(bezpath)%N == 1, str("A degree ",N," bezier path should have a multiple of ",N," points in it, plus 1."))
|
assert(len(bezpath)%N == 1, str("A degree ",N," bezier path should have a multiple of ",N," points in it, plus 1."))
|
||||||
let(
|
let(
|
||||||
segs = (len(bezpath)-1) / N,
|
segs = (len(bezpath)-1) / N,
|
||||||
step = 1 / splinesteps
|
step = 1 / splinesteps,
|
||||||
) [
|
path = [
|
||||||
for (seg = [0:1:segs-1])
|
for (seg = [0:1:segs-1])
|
||||||
each bezier_points(select(bezpath, seg*N, (seg+1)*N), [0:step:1-step/2]),
|
each bezier_points(select(bezpath, seg*N, (seg+1)*N), [0:step:1-step/2]),
|
||||||
if (endpoint) last(bezpath)
|
if (endpoint) last(bezpath)
|
||||||
];
|
],
|
||||||
|
is_closed = approx(path[0], last(path)),
|
||||||
|
out = path_merge_collinear(path, closed=is_closed)
|
||||||
|
) out;
|
||||||
|
|
||||||
|
|
||||||
// Function: bezpath_closest_point()
|
// Function: bezpath_closest_point()
|
||||||
|
|
Loading…
Reference in a new issue