mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-02-24 09:33:26 +01:00
refactor
This commit is contained in:
parent
002711ae3e
commit
057ad863af
@ -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);
|
Loading…
x
Reference in New Issue
Block a user