mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-29 11:58:39 +01:00
add midpt_smooth
This commit is contained in:
parent
4e1eca2df2
commit
04fd1590a7
11
src/midpt_smooth.scad
Normal file
11
src/midpt_smooth.scad
Normal file
@ -0,0 +1,11 @@
|
||||
function _midpt_smooth_sub(points, iend, i, closed = false) =
|
||||
i == iend ? (
|
||||
closed ? [(points[i] + points[0]) / 2]
|
||||
: []
|
||||
) : concat([(points[i] + points[i + 1]) / 2], _midpt_smooth_sub(points, iend, i + 1, closed));
|
||||
|
||||
function midpt_smooth(points, n, closed = false) =
|
||||
let(
|
||||
smoothed = _midpt_smooth_sub(points, len(points) - 1, 0, closed)
|
||||
)
|
||||
n == 1 ? smoothed : midpt_smooth(smoothed, n - 1, closed);
|
Loading…
x
Reference in New Issue
Block a user