1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-16 11:44:50 +02:00

considered angle not matching fn

This commit is contained in:
Justin Lin
2017-05-21 20:37:26 +08:00
parent fd57d562f9
commit fb7884f6e4

View File

@@ -12,18 +12,26 @@
**/
include <__private__/__frags.scad>;
include <__private__/__ra_to_xy.scad>;
module ring_extrude(shape_pts, radius, angle = 360, twist = 0, scale = 1.0, triangles = "SOLID") {
frags = __frags(radius);
angle_step = 360 / frags;
as = [for(a = [0:angle_step:angle]) [90, 0, a]];
angles = as[len(as) - 1][2] == angle ? as : concat(as, [[90, 0, angle]]);
pts = [for(a = angles) [radius * cos(a[2]), radius * sin(a[2])]];
a_step = 360 / __frags(radius);
n = floor(angle / a_step);
function end_r() =
radius * cos(a_step / 2) / cos((n + 0.5) * a_step - angle);
angs = [for(a = [0:a_step:n * a_step]) [90, 0, a]];
pts = [for(a = angs) __ra_to_xy(radius, a[2])];
is_angle_frag_end = angs[len(angs) - 1][2] == angle;
angles = is_angle_frag_end ? angs : concat(angs, [[90, 0, angle]]);
points = is_angle_frag_end ? pts : concat(pts, [__ra_to_xy(end_r(), angle)]);
polysections(
cross_sections(shape_pts, pts, angles, twist, scale),
cross_sections(shape_pts, points, angles, twist, scale),
triangles = triangles
);
}