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

supported scale

This commit is contained in:
Justin Lin
2017-05-19 13:42:34 +08:00
parent a3ce67b128
commit 06da003c66

View File

@@ -12,14 +12,26 @@
**/ **/
include <__private__/__angy_angz.scad>; include <__private__/__angy_angz.scad>;
include <__private__/__is_vector.scad>;
module along_with(points, angles, twist = 0) { module along_with(points, angles, twist = 0, scale = 1.0) {
leng_points = len(points); leng_points = len(points);
leng_points_minus_one = leng_points - 1;
twist_step_a = twist / leng_points; twist_step_a = twist / leng_points;
echo(twist_step_a);
function scale_step() =
let(s = (scale - 1) / leng_points_minus_one)
[s, s, s];
scale_step_vt = __is_vector(scale) ?
[
(scale[0] - 1) / leng_points_minus_one,
(scale[1] - 1) / leng_points_minus_one,
scale[2] == undef ? 0 : (scale[2] - 1) / leng_points_minus_one
] : scale_step();
function _path_angles(i = 0) = function _path_angles(i = 0) =
i == leng_points - 1 ? i == leng_points_minus_one ?
[] : [] :
concat( concat(
[__angy_angz(points[i], points[i + 1])], [__angy_angz(points[i], points[i + 1])],
@@ -39,22 +51,18 @@ module along_with(points, angles, twist = 0) {
module align(i) { module align(i) {
translate(points[i]) translate(points[i])
rotate(angs[i]) rotate(angs[i])
if(angles_defined) { rotate(angles_defined ? [0, 0, 0] : [90, 0, -90])
rotate(twist_step_a * i) rotate(twist_step_a * i)
scale([1, 1, 1] + scale_step_vt * i)
children(0); children(0);
} else {
rotate([90, 0, -90])
rotate(twist_step_a * i)
children(0);
}
} }
if($children == 1) { if($children == 1) {
for(i = [0:len(points) - 1]) { for(i = [0:leng_points_minus_one]) {
align(i) children(0); align(i) children(0);
} }
} else { } else {
for(i = [0:min(len(points), $children) - 1]) { for(i = [0:min(leng_points, $children) - 1]) {
align(i) children(i); align(i) children(i);
} }
} }