1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-04-21 14:41:51 +02:00

scale accepts vector

This commit is contained in:
Justin Lin 2017-05-02 20:15:07 +08:00
parent 7be4b1da37
commit 26139a0f0d

View File

@ -13,7 +13,7 @@
*
**/
module path_extrude(shape_pts, path_pts, triangles = "RADIAL", twist = 0, scale = 1.0) {
module path_extrude(shape_pts, path_pts, triangles = "RADIAL", twist = 0, scale = [1.0, 1.0]) {
function first_section() =
let(
p1 = path_pts[0],
@ -29,9 +29,16 @@ module path_extrude(shape_pts, path_pts, triangles = "RADIAL", twist = 0, scale
rotate_p(p, [0, ay, az]) + p1
];
len_path_pts = len(path_pts);
scale_step = (scale - 1) / (len_path_pts - 1);
twist_step = twist / (len_path_pts - 1);
len_path_pts = len(path_pts);
len_path_pts_minus_one = len_path_pts - 1;
scale_step_vt = len(scale) == 2 ?
[(scale[0] - 1) / len_path_pts_minus_one, (scale[1] - 1) / len_path_pts_minus_one] :
[(scale - 1) / len_path_pts_minus_one, (scale - 1) / len_path_pts_minus_one];
scale_step_x = scale_step_vt[0];
scale_step_y = scale_step_vt[1];
twist_step = twist / len_path_pts_minus_one;
function section(p1, p2, i) =
let(
@ -44,11 +51,11 @@ module path_extrude(shape_pts, path_pts, triangles = "RADIAL", twist = 0, scale
)
[
for(p = shape_pts)
let(scaled_p = [p[0] * (1 + scale_step_x * i), p[1] * (1 + scale_step_y * i), p[2]])
rotate_p(
rotate_p(p * (1 + scale_step * i), twist_step * i) + [0, 0, length],
rotate_p(scaled_p, twist_step * i) + [0, 0, length],
[0, ay, az]
) + p1
//rotate_p(p * (1 + scale_step * i) + [0, 0, length], [0, ay, az]) + p1
];