mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 22:28:16 +01:00
add square_pursuit_curves_3d
This commit is contained in:
parent
858685f22f
commit
b1c6180269
44
examples/square_pursuit_curves_3d.scad
Normal file
44
examples/square_pursuit_curves_3d.scad
Normal file
@ -0,0 +1,44 @@
|
||||
use <hull_polyline3d.scad>;
|
||||
|
||||
length = 100;
|
||||
diff_scale = 0.125;
|
||||
thickness = 2;
|
||||
n = 30;
|
||||
$fn = 6;
|
||||
|
||||
module square_pursuit_curves_3d(length, diff_scale, thickness, n) {
|
||||
function inter_p(p1, p2, leng, d) =
|
||||
let(
|
||||
vp = p2 - p1,
|
||||
u = vp / leng
|
||||
)
|
||||
p1 + u * d;
|
||||
|
||||
module _square_pursuit_curves_3d(pts, diff_scale, thickness, n) {
|
||||
if(n != 0) {
|
||||
vp = pts[1] - pts[0];
|
||||
leng = norm(vp);
|
||||
d = leng * diff_scale;
|
||||
|
||||
npts = [for(i = [0:3]) inter_p(pts[i], pts[(i + 1) % 4], leng, d)];
|
||||
|
||||
hull_polyline3d(concat(npts, [npts[3], npts[0]]), thickness);
|
||||
|
||||
_square_pursuit_curves_3d(npts, diff_scale, thickness, n - 1);
|
||||
}
|
||||
}
|
||||
|
||||
half_length = length / 2;
|
||||
pts = [
|
||||
[0, 0, 0],
|
||||
[length, 0, 0],
|
||||
[half_length, half_length, sqrt(2) * half_length],
|
||||
[0, length, 0]
|
||||
];
|
||||
|
||||
hull_polyline3d(concat(pts, [pts[3], pts[0]]), thickness);
|
||||
|
||||
_square_pursuit_curves_3d(pts, diff_scale, thickness, n - 1);
|
||||
}
|
||||
|
||||
square_pursuit_curves_3d(length, diff_scale, thickness, n);
|
Loading…
x
Reference in New Issue
Block a user