1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 09:33:26 +01:00
This commit is contained in:
Justin Lin 2019-06-16 18:25:45 +08:00
parent 002711ae3e
commit 057ad863af

View File

@ -8,14 +8,17 @@
*
**/
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_sub(points, iend, closed = false) =
concat(
[
for(i = 0; i < iend; i = i + 1)
(points[i] + points[i + 1]) / 2
],
closed ? [(points[iend] + points[0]) / 2] : []
);
function midpt_smooth(points, n, closed = false) =
let(
smoothed = _midpt_smooth_sub(points, len(points) - 1, 0, closed)
smoothed = _midpt_smooth_sub(points, len(points) - 1, closed)
)
n == 1 ? smoothed : midpt_smooth(smoothed, n - 1, closed);