/ src / _impl / _midpt_smooth_impl.scad
_midpt_smooth_impl.scad
 1  function _midpt_smooth_sub(points, iend, closed) = 
 2      [
 3          each [
 4              for(i = 0; i < iend; i = i + 1) 
 5                  (points[i] + points[i + 1]) / 2
 6          ],
 7          if(closed) (points[iend] + points[0]) / 2
 8      ];
 9  
10  function _midpt_smooth_impl(points, n, closed) =
11      let(smoothed = _midpt_smooth_sub(points, len(points) - 1, closed))
12      n == 1 ? smoothed : _midpt_smooth_impl(smoothed, n - 1, closed);