1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 01:22:27 +01:00
This commit is contained in:
Justin Lin 2019-06-15 21:14:16 +08:00
parent 2110b9cb31
commit 03ac58acaa

View File

@ -18,7 +18,6 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
len_path_pts = len(pth_pts);
len_path_pts_minus_one = len_path_pts - 1;
module axis_angle_path_extrude() {
twist_step_a = twist / len_path_pts;
@ -47,16 +46,16 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
// get rotation matrice for sections
function local_ang_vects(j) =
j == 0 ? [] : local_ang_vects_sub(j);
function local_ang_vects_sub(j) =
let(
vt0 = pth_pts[j] - pth_pts[j - 1],
vt1 = pth_pts[j + 1] - pth_pts[j],
a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1))),
v = cross(vt0, vt1)
)
concat([[a, v]], local_ang_vects(j - 1));
[
for(i = j; i > 0; i = i - 1)
let(
vt0 = pth_pts[i] - pth_pts[i - 1],
vt1 = pth_pts[i + 1] - pth_pts[i],
a = acos((vt0 * vt1) / (norm(vt0) * norm(vt1))),
v = cross(vt0, vt1)
)
[a, v]
];
rot_matrice = [
for(ang_vect = local_ang_vects(len_path_pts - 2))
@ -132,27 +131,25 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
let(
fst_section =
translate_pts(local_rotate_section(0, 0, [1, 1, 1]), pth_pts[0]),
end_i = len_path_pts - 1,
remain_sections = [
for(i = [0:len_path_pts - 2])
for(i = 0; i < end_i; i = i + 1)
translate_pts(
local_rotate_section(i, i * twist_step_a, [1, 1, 1] + scale_step_vt * i),
pth_pts[i + 1]
)
]
) concat([fst_section], remain_sections);
sects = sections();
function calculated_sections() =
calculated_sections =
closed && pth_pts[0] == pth_pts[len_path_pts_minus_one] ?
concat(sects, [sects[0]]) : // round-robin
sects;
polysections(
calculated_sections(),
calculated_sections,
triangles = triangles
);
@ -187,28 +184,24 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
) + p1
];
function path_extrude_inner(index) =
index == len_path_pts ? [] :
concat(
[section(pth_pts[index - 1], pth_pts[index], index)],
path_extrude_inner(index + 1)
);
path_extrude_inner =
[
for(i = 1; i < len_path_pts; i = i + 1)
section(pth_pts[i - 1], pth_pts[i], i)
];
function calculated_sections() =
let(sections = path_extrude_inner(1))
calculated_sections =
closed && pth_pts[0] == pth_pts[len_path_pts_minus_one] ?
concat(sections, [sections[0]]) : // round-robin
concat([section(pth_pts[0], pth_pts[1], 0)], sections);
sections = calculated_sections();
concat(path_extrude_inner, [path_extrude_inner[0]]) : // round-robin
concat([section(pth_pts[0], pth_pts[1], 0)], path_extrude_inner);
polysections(
sections,
calculated_sections,
triangles = triangles
);
// hook for testing
test_path_extrude(sections);
test_path_extrude(calculated_sections);
}
if(method == "AXIS_ANGLE") {
@ -219,7 +212,6 @@ module path_extrude(shape_pts, path_pts, triangles = "SOLID", twist = 0, scale =
}
}
// override to test
module test_path_extrude(sections) {