]> git.scottworley.com Git - nt3d/blob - medusa.html
58319c006613cbe07b7ae80a088030499de7b65a
[nt3d] / medusa.html
1 <html>
2 <head>
3 <title>Medusa</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
6 function medusa(base_ring_radius, num_fingers, finger_radius, finger_faces, finger_points, finger_twirl, finger_height) {
7 var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
8 var fingers = [];
9 for (var i = 0; i < num_fingers; i++) {
10 var finger_angle = i / num_fingers;
11 var path = [];
12 for (var j = 0; j <= finger_points; j++) {
13 var angle = (finger_angle + finger_twirl * j / finger_points) * 2 * Math.PI;
14 var x = base_ring_radius * Math.cos(angle);
15 var y = base_ring_radius * Math.sin(angle);
16 path.push([x, y, finger_height * j / finger_points]);
17 }
18 var finger = nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0]));
19 fingers = fingers.concat(finger);
20 }
21
22 return fingers;
23 }
24 var params = [["Base ring radius", 100],
25 ["Number of fingers", 5],
26 ["Finger radius", 3],
27 ["Finger faces", 10],
28 ["Finger points", 20],
29 ["Finger twirl (in turns)", .1],
30 ["Finger height", 100]];
31 </script>
32 </head>
33 <body onload="nt3d.framework(medusa, params)">
34 <h1>Medusa</h1>
35 <p>An artsy thing.</p>
36 </body>
37 </html>