Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant collinear points from bezpath_curve() output. #1450

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions beziers.scad
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
let(
segs = (len(bezpath)-1) / N,
step = 1 / splinesteps
) [
for (seg = [0:1:segs-1])
each bezier_points(select(bezpath, seg*N, (seg+1)*N), [0:step:1-step/2]),
if (endpoint) last(bezpath)
];
step = 1 / splinesteps,
path = [
for (seg = [0:1:segs-1])
each bezier_points(select(bezpath, seg*N, (seg+1)*N), [0:step:1-step/2]),
if (endpoint) last(bezpath)
],
is_closed = approx(path[0], last(path)),
out = path_merge_collinear(path, closed=is_closed)
) out;


// Function: bezpath_closest_point()
Expand Down
Loading