1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-22 06:13:10 +02:00

add slices param

This commit is contained in:
Justin Lin
2020-03-01 16:48:04 +08:00
parent bcee3a899d
commit 22664ba0f8
2 changed files with 24 additions and 7 deletions

View File

@@ -1,12 +1,13 @@
use <shape_starburst.scad>;
use <rotate_p.scad>;
use <util/reverse.scad>;
use <experimental/loft.scad>;
sects = [
for(i = [4:20])
[
for(p = shape_starburst(15, 12, i % 2 == 1 ? i : i - 1)) rotate_p([p[0], p[1], 3 * (i - 4)], i * 10)
]
for(i = [4:10])
reverse([
for(p = shape_starburst(15, 12, i % 2 == 1 ? i : i - 1)) rotate_p([p[0], p[1], 5 * (i - 4)], i * 10)
])
];
loft(sects);
loft(sects, slices = 3);

View File

@@ -1,6 +1,6 @@
use <experimental/sweep.scad>;
module loft(sections) {
module loft(sections, slices = 1) {
function gcd(m, n) = n == 0 ? m : gcd(n, m % n);
function lcm(m, n) = m * n / gcd(m, n);
@@ -30,11 +30,27 @@ module loft(sections) {
n <= 1 ? sect : _interpolate(sect, len(sect), n);
module _loft(sect1, sect2) {
function inter_sects(s1, s2, s_leng, slices) =
slices == 1 ? [] :
let(
dps = [
for(i = [0:lcm_n - 1])
(s2[i] - s1[i]) / slices
]
)
[for(i = [1:slices - 1]) s1 + dps * i];
lcm_n = lcm(len(sect1), len(sect2));
new_sect1 = interpolate(sect1, lcm_n / len(sect1));
new_sect2 = interpolate(sect2, lcm_n / len(sect2));
sweep([new_sect1, new_sect2]);
sweep(
concat(
[new_sect1],
inter_sects(new_sect1, new_sect2, lcm_n, slices),
[new_sect2]
)
);
}
for(i = [0:len(sections) - 2]) {