]> git.scottworley.com Git - nt3d/blob - rmm.html
dd212e51c0d901032a3aa23e0e1c31e99e331809
[nt3d] / rmm.html
1 <html>
2 <head>
3 <title>The Thing the Rostock Was Printing in Make Magazine</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
6 function pointy_sin(x) {
7 // Similar to sin(x*pi) over the range [-1,1],
8 // but with more movement towards the extremes.
9 // https://plus.google.com/101508799331795210529/posts/Yg7LmV8BpTw
10 return 3.7*x + (Math.log(1-.95*x)-Math.log(.95*x+1));
11 }
12 function rmm(base_separation, base_offset,
13 width, short_arc_height, tall_arc_height,
14 tube_width, steps_along, steps_around) {
15 var tau = Math.PI*2;
16 var path = [];
17 // Short arc
18 for (var i = 0; i < steps_along; i++) {
19 var progress = i/steps_along;
20 var x_separation = Math.cos(progress*tau/2)*base_separation;
21 var y_offset = -Math.sin(progress*tau/4)*base_offset;
22 var y_arc = Math.sin(progress*tau)*width;
23 var z_arc = -Math.cos(progress*tau)*short_arc_height + short_arc_height;
24 path.push([x_separation, y_offset + y_arc, z_arc]);
25 }
26 // Tall arc
27 for (var i = 0; i < steps_along; i++) {
28 var progress = i/steps_along;
29 var x_arc = -Math.cos(progress*tau*1.5)*base_separation;
30 var y_offset = -Math.cos(progress*tau/4)*base_offset;
31 var y_twist = -pointy_sin(progress*2 - 1)*width/2;
32 var z_arc = -Math.cos(progress*tau)*tall_arc_height + tall_arc_height;
33 path.push([x_arc, y_offset + y_twist, z_arc]);
34 }
35 return nt3d.closed_extrude(
36 path,
37 nt3d.circle(tube_width, steps_around),
38 nt3d.shapenormals_from_closed_path(path),
39 nt3d.pathnormals_from_point(path, [0,0,0]));
40 }
41 var params = [["Base separation", 30],
42 ["Base offset", 10],
43 ["Width", 40],
44 ["Short arc height", 60],
45 ["Tall arc height", 80],
46 ["Tube width", 10],
47 ["Steps along each arc", 70],
48 ["Steps around", 12]];
49 </script>
50 </head>
51 <body onload="nt3d.framework(rmm, params)">
52 <h1>The Thing the Rostock Was Printing in Make Magazine</h1>
53 <p><a href="http://www.flickr.com/photos/jcrocholl/8065968929/sizes/l/in/photostream/">This thing</a>.</p>
54 <!-- My notes after staring at it:
55 x y z
56 1 0 0 Bottom front
57 .5 1 .5s 1/4 up short arc
58 0 0 s Top of short arc
59 -.5 -1 .5s Coming down short arc
60 -1 0 0 Bottom back
61 1 .33 .5t 1/4 up long arc
62 0 0 t Top of tall arc
63 -1 -.33 .5t Coming down tall arc
64 1 0 0 Bottom front (Repeated from above)
65
66 x = cos over 1/2 period for short arc, -cos over 1.5 periods for tall arc
67 y = sin over 1 period for short arc, sin/3 over 1 period for tall arc
68 z = -cos over 1 period for short arc, -cos over 1 period for tall arc
69 -->
70 </body>
71 </html>
72