mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-09-25 13:59:04 +02:00
refactored
This commit is contained in:
20
src/__private__/__shape_pie.scad
Normal file
20
src/__private__/__shape_pie.scad
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
function __shape_pie(radius, angle) =
|
||||||
|
let(
|
||||||
|
frags = __frags(radius),
|
||||||
|
a_step = 360 / frags,
|
||||||
|
leng = radius * cos(a_step / 2),
|
||||||
|
angles = __is_vector(angle) ? angle : [0:angle],
|
||||||
|
m = floor(angles[0] / a_step) + 1,
|
||||||
|
n = floor(angles[1] / a_step),
|
||||||
|
edge_r_begin = leng / cos((m - 0.5) * a_step - angles[0]),
|
||||||
|
edge_r_end = leng / cos((n + 0.5) * a_step - angles[1]),
|
||||||
|
shape_pts = concat(
|
||||||
|
[[0, 0], __ra_to_xy(edge_r_begin, angles[0])],
|
||||||
|
m > n ? [] : [
|
||||||
|
for(i = [m:n])
|
||||||
|
let(a = a_step * i)
|
||||||
|
__ra_to_xy(radius, a)
|
||||||
|
],
|
||||||
|
angles[1] == a_step * n ? [] : [__ra_to_xy(edge_r_end, angles[1])]
|
||||||
|
)
|
||||||
|
) shape_pts;
|
@@ -15,24 +15,7 @@
|
|||||||
include <__private__/__frags.scad>;
|
include <__private__/__frags.scad>;
|
||||||
include <__private__/__is_vector.scad>;
|
include <__private__/__is_vector.scad>;
|
||||||
include <__private__/__ra_to_xy.scad>;
|
include <__private__/__ra_to_xy.scad>;
|
||||||
|
include <__private__/__shape_pie.scad>;
|
||||||
|
|
||||||
function shape_pie(radius, angle) =
|
function shape_pie(radius, angle) =
|
||||||
let(
|
__shape_pie(radius, angle);
|
||||||
frags = __frags(radius),
|
|
||||||
a_step = 360 / frags,
|
|
||||||
leng = radius * cos(a_step / 2),
|
|
||||||
angles = __is_vector(angle) ? angle : [0:angle],
|
|
||||||
m = floor(angles[0] / a_step) + 1,
|
|
||||||
n = floor(angles[1] / a_step),
|
|
||||||
edge_r_begin = leng / cos((m - 0.5) * a_step - angles[0]),
|
|
||||||
edge_r_end = leng / cos((n + 0.5) * a_step - angles[1]),
|
|
||||||
shape_pts = concat(
|
|
||||||
[[0, 0], __ra_to_xy(edge_r_begin, angles[0])],
|
|
||||||
m > n ? [] : [
|
|
||||||
for(i = [m:n])
|
|
||||||
let(a = a_step * i)
|
|
||||||
__ra_to_xy(radius, a)
|
|
||||||
],
|
|
||||||
angles[1] == a_step * n ? [] : [__ra_to_xy(edge_r_end, angles[1])]
|
|
||||||
)
|
|
||||||
) shape_pts;
|
|
Reference in New Issue
Block a user