1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-17 20:11:50 +02:00

refactor deps

This commit is contained in:
Justin Lin
2020-01-27 15:16:38 +08:00
parent 9a3767ccbd
commit 61922a3f64
2 changed files with 16 additions and 13 deletions

View File

@@ -0,0 +1,14 @@
function _midpt_smooth_sub(points, iend, closed) =
concat(
[
for(i = 0; i < iend; i = i + 1)
(points[i] + points[i + 1]) / 2
],
closed ? [(points[iend] + points[0]) / 2] : []
);
function _midpt_smooth_impl(points, n, closed) =
let(
smoothed = _midpt_smooth_sub(points, len(points) - 1, closed)
)
n == 1 ? smoothed : _midpt_smooth_impl(smoothed, n - 1, closed);

View File

@@ -8,17 +8,6 @@
*
**/
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] : []
);
use <_impl/_midpt_smooth_impl.scad>;
function midpt_smooth(points, n, closed = false) =
let(
smoothed = _midpt_smooth_sub(points, len(points) - 1, closed)
)
n == 1 ? smoothed : midpt_smooth(smoothed, n - 1, closed);
function midpt_smooth(points, n, closed = false) = _midpt_smooth_impl(points, n, closed);