forked from KitWallace/openscad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrolling-knot-cone.scad
More file actions
34 lines (29 loc) · 810 Bytes
/
rolling-knot-cone.scad
File metadata and controls
34 lines (29 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// rolling knot code with thanks to mathgrrl and nop head
module disc_p2p(p1, p2, r) {
assign(p = p2 - p1)
translate(p1 + p/2)
rotate([0, 0, atan2(p[1], p[0])])
rotate([0, atan2(sqrt(pow(p[0], 2)+pow(p[1], 2)),p[2]), 0])
render() cylinder(h = 0.1, r1 = r, r2 = 0);
};
function f(t) = // rolling knot
[ a * cos (3 * t) / (1 - b* sin (2 *t)),
a * sin( 3 * t) / (1 - b* sin (2 *t)),
1.8 * b * cos (2 * t) /(1 - b* sin (2 *t))
];
module tube(r, step) {
for (t=[0: step: 359])
assign (p0 = f(t),
p1 = f(t + step ),
p2 = f(t + 2 * step))
render() hull() {
disc_p2p (p0,p1,r);
disc_p2p (p1,p2,r);
}
};
$fn=20;
a = 0.8;
b = sqrt (1 - a * a);
r = 0.3;
step = 2;
scale(15) tube (r, step);