diff --git a/src/__comm__/__shape_arc.scad b/src/__comm__/__shape_arc.scad deleted file mode 100644 index 55e4bf0b..00000000 --- a/src/__comm__/__shape_arc.scad +++ /dev/null @@ -1,29 +0,0 @@ -function __shape_arc(radius, angle, width, width_mode = "LINE_CROSS") = - let( - w_offset = width_mode == "LINE_CROSS" ? [width / 2, -width / 2] : - width_mode == "LINE_INWARD" ? [0, -width] : [width, 0], - a_step = 360 / __frags(radius), - half_a_step = a_step / 2, - angles = is_num(angle) ? [0, angle] : angle, - m = floor(angles[0] / a_step) + 1, - n = floor(angles[1] / a_step), - r_outer = radius + w_offset[0], - r_inner = radius + w_offset[1], - points = concat( - // outer arc path - [__ra_to_xy(__edge_r_begin(r_outer, angles[0], a_step, m), angles[0])], - m > n ? [] : [ - for(i = m; i <= n; i = i + 1) __ra_to_xy(r_outer, a_step * i) - ], - angles[1] == a_step * n ? [] : [__ra_to_xy(__edge_r_end(r_outer, angles[1], a_step, n), angles[1])], - // inner arc path - angles[1] == a_step * n ? [] : [__ra_to_xy(__edge_r_end(r_inner, angles[1], a_step, n), angles[1])], - m > n ? [] : [ - for(i = m; i <= n; i = i + 1) - let(idx = (n + (m - i))) - __ra_to_xy(r_inner, a_step * idx) - - ], - [__ra_to_xy(__edge_r_begin(r_inner, angles[0], a_step, m), angles[0])] - ) - ) points; \ No newline at end of file diff --git a/src/arc.scad b/src/arc.scad index c4b152e2..97542f53 100644 --- a/src/arc.scad +++ b/src/arc.scad @@ -8,11 +8,8 @@ * **/ -include <__comm__/__frags.scad>; -include <__comm__/__ra_to_xy.scad>; -include <__comm__/__edge_r.scad>; -include <__comm__/__shape_arc.scad>; +use ; module arc(radius, angle, width, width_mode = "LINE_CROSS") { - polygon(__shape_arc(radius, angle, width, width_mode)); + polygon(shape_arc(radius, angle, width, width_mode)); } \ No newline at end of file diff --git a/src/shape_arc.scad b/src/shape_arc.scad index 4730620e..cbd1f89a 100644 --- a/src/shape_arc.scad +++ b/src/shape_arc.scad @@ -8,10 +8,36 @@ * **/ -include <__comm__/__frags.scad>; -include <__comm__/__ra_to_xy.scad>; -include <__comm__/__shape_arc.scad>; -include <__comm__/__edge_r.scad> +use <__comm__/__frags.scad>; +use <__comm__/__ra_to_xy.scad>; +use <__comm__/__edge_r.scad> function shape_arc(radius, angle, width, width_mode = "LINE_CROSS") = - __shape_arc(radius, angle, width, width_mode); \ No newline at end of file + let( + w_offset = width_mode == "LINE_CROSS" ? [width / 2, -width / 2] : + width_mode == "LINE_INWARD" ? [0, -width] : [width, 0], + a_step = 360 / __frags(radius), + half_a_step = a_step / 2, + angles = is_num(angle) ? [0, angle] : angle, + m = floor(angles[0] / a_step) + 1, + n = floor(angles[1] / a_step), + r_outer = radius + w_offset[0], + r_inner = radius + w_offset[1], + points = concat( + // outer arc path + [__ra_to_xy(__edge_r_begin(r_outer, angles[0], a_step, m), angles[0])], + m > n ? [] : [ + for(i = m; i <= n; i = i + 1) __ra_to_xy(r_outer, a_step * i) + ], + angles[1] == a_step * n ? [] : [__ra_to_xy(__edge_r_end(r_outer, angles[1], a_step, n), angles[1])], + // inner arc path + angles[1] == a_step * n ? [] : [__ra_to_xy(__edge_r_end(r_inner, angles[1], a_step, n), angles[1])], + m > n ? [] : [ + for(i = m; i <= n; i = i + 1) + let(idx = (n + (m - i))) + __ra_to_xy(r_inner, a_step * idx) + + ], + [__ra_to_xy(__edge_r_begin(r_inner, angles[0], a_step, m), angles[0])] + ) + ) points; \ No newline at end of file