]> git.scottworley.com Git - nt3d/blame - medusa.html
Space fingers uniformly, not by number per ring
[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">
9c6ce9fa
SW
6 function finger(params, finger_crosssection, ring_radius, finger_angle) {
7 var path = [];
8 for (var finger_point = 0; finger_point <= params.finger_points; finger_point++) {
9 var angle = (finger_angle + params.finger_twirl * finger_point / params.finger_points) * 2 * Math.PI;
10 var x = ring_radius * Math.cos(angle);
11 var y = ring_radius * Math.sin(angle);
12 path.push([x, y, params.finger_height * finger_point / params.finger_points]);
13 }
14 return nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0]));
15 }
3bafa9bd
SW
16 function medusa(params) {
17 var finger_crosssection = nt3d.circle(params.finger_radius, params.finger_faces);
00406c26 18 var fingers = [];
3bafa9bd
SW
19 for (var ring_num = 0; ring_num < params.num_rings; ring_num++) {
20 var ring_radius = params.first_ring_radius + ring_num * params.ring_spacing;
bdd7bcc0
SW
21 var num_fingers = Math.round((ring_radius * 2 * Math.PI) / params.finger_spacing);
22 for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
23 var finger_angle = finger_num / num_fingers;
9c6ce9fa 24 fingers = fingers.concat(finger(params, finger_crosssection, ring_radius, finger_angle));
911d073b 25 }
00406c26
SW
26 }
27
28 return fingers;
29 }
3bafa9bd 30 var params = [["first_ring_radius", 20],
c81e16ac 31 ["num_rings", 4],
3bafa9bd 32 ["ring_spacing", 10, "Space Between Rings"],
bdd7bcc0 33 ["finger_spacing", 10],
3bafa9bd 34 ["finger_radius", 3],
c81e16ac 35 ["finger_faces", 3],
3bafa9bd
SW
36 ["finger_points", 20],
37 ["finger_twirl", .1, "Finger Twirl (in turns)"],
38 ["finger_height", 100]];
00406c26
SW
39 </script>
40 </head>
41 <body onload="nt3d.framework(medusa, params)">
42 <h1>Medusa</h1>
43 <p>An artsy thing.</p>
44 </body>
45</html>