1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-01 04:20:27 +02:00

delegated to rotate_extrude directly

This commit is contained in:
Justin Lin
2017-05-24 18:09:03 +08:00
parent e9d4e3dd2b
commit a86e7eda89

View File

@@ -15,43 +15,49 @@ 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") {
if(angle == 360 && twist == 0 && scale == 1.0) {
rotate_extrude()
translate([radius, 0, 0])
polygon(shape_pts);
} else {
a_step = 360 / __frags(radius);
a_step = 360 / __frags(radius);
angles = __is_vector(angle) ? angle : [0, angle];
angles = __is_vector(angle) ? angle : [0, angle];
m = floor(angles[0] / a_step) + 1;
n = floor(angles[1] / a_step);
m = floor(angles[0] / a_step) + 1;
n = floor(angles[1] / a_step);
leng = radius * cos(a_step / 2);
leng = radius * cos(a_step / 2);
begin_r =
leng / cos((m - 0.5) * a_step - angles[0]);
begin_r =
leng / cos((m - 0.5) * a_step - angles[0]);
end_r =
leng / cos((n + 0.5) * a_step - angles[1]);
end_r =
leng / cos((n + 0.5) * a_step - angles[1]);
angs = concat(
[[90, 0, angles[0]]],
m > n ? [] : [for(i = [m:n]) [90, 0, a_step * i]]
);
pts = concat(
[__ra_to_xy(begin_r, angles[0])],
m > n ? [] : [for(i = [m:n]) __ra_to_xy(radius, a_step * i)]
);
angs = concat(
[[90, 0, angles[0]]],
m > n ? [] : [for(i = [m:n]) [90, 0, a_step * i]]
);
pts = concat(
[__ra_to_xy(begin_r, angles[0])],
m > n ? [] : [for(i = [m:n]) __ra_to_xy(radius, a_step * i)]
);
is_angle_frag_end = angs[len(angs) - 1][2] == angles[1];
all_angles = is_angle_frag_end ?
angs :
concat(angs, [[90, 0, angles[1]]]);
is_angle_frag_end = angs[len(angs) - 1][2] == angles[1];
all_points = is_angle_frag_end ?
pts :
concat(pts, [__ra_to_xy(end_r(), angles[1])]);
all_angles = is_angle_frag_end ?
angs :
concat(angs, [[90, 0, angles[1]]]);
all_points = is_angle_frag_end ?
pts :
concat(pts, [__ra_to_xy(end_r(), angles[1])]);
polysections(
cross_sections(shape_pts, all_points, all_angles, twist, scale),
triangles = triangles
);
polysections(
cross_sections(shape_pts, all_points, all_angles, twist, scale),
triangles = triangles
);
}
}