From a90c2410fb8b5fab7f0558c75505732fe5e4f77b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 25 May 2017 09:46:36 +0800 Subject: [PATCH] refactored --- src/pie.scad | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/pie.scad b/src/pie.scad index 31923969..a59b3c33 100644 --- a/src/pie.scad +++ b/src/pie.scad @@ -13,30 +13,8 @@ include <__private__/__frags.scad>; include <__private__/__is_vector.scad>; include <__private__/__ra_to_xy.scad>; +include <__private__/__shape_pie.scad>; module pie(radius, angle) { - - a_step = 360 / __frags(radius); - - angles = __is_vector(angle) ? angle : [0, angle]; - - m = floor(angles[0] / a_step) + 1; - n = floor(angles[1] / a_step); - - half_a_step = a_step / 2; - leng = radius * cos(half_a_step); - - function edge_r_begin(a) = - leng / cos((m - 0.5) * a_step - a); - - function edge_r_end(a) = - leng / cos((n + 0.5) * a_step - a); - - points = concat( - [[0, 0], __ra_to_xy(edge_r_begin(angles[0]), angles[0])], - m > n ? [] : [for(i = [m:n]) __ra_to_xy(radius, a_step * i)], - angles[1] == a_step * n ? [] : [__ra_to_xy(edge_r_end(angles[1]), angles[1])] - ); - - polygon(points); + polygon(__shape_pie(radius, angle)); } \ No newline at end of file