]> git.scottworley.com Git - nt3d/blame - medusa.html
Better names for loop index variables
[nt3d] / medusa.html
CommitLineData
00406c26
SW
1<html>
2 <head>
3 <title>Medusa</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
911d073b 6 function medusa(base_ring_radius, num_fingers, finger_radius, finger_faces, finger_points, finger_twirl, finger_height) {
00406c26
SW
7 var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
8 var fingers = [];
78a4b7fa
SW
9 for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
10 var finger_angle = finger_num / num_fingers;
911d073b 11 var path = [];
78a4b7fa
SW
12 for (var finger_point = 0; finger_point <= finger_points; finger_point++) {
13 var angle = (finger_angle + finger_twirl * finger_point / finger_points) * 2 * Math.PI;
911d073b
SW
14 var x = base_ring_radius * Math.cos(angle);
15 var y = base_ring_radius * Math.sin(angle);
78a4b7fa 16 path.push([x, y, finger_height * finger_point / finger_points]);
911d073b 17 }
00406c26
SW
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],
911d073b
SW
28 ["Finger points", 20],
29 ["Finger twirl (in turns)", .1],
00406c26
SW
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>