]> git.scottworley.com Git - nt3d/commitdiff
Multiple rings
authorScott Worley <scottworley@scottworley.com>
Fri, 9 May 2014 06:53:39 +0000 (23:53 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 9 May 2014 06:53:39 +0000 (23:53 -0700)
medusa.html

index e077aff227a07f776bc2f764c8ca790175535eb7..e82d9e53e75ba13949961beae30a1059c9c22031 100644 (file)
@@ -3,28 +3,33 @@
     <title>Medusa</title>
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
     <title>Medusa</title>
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
-      function medusa(base_ring_radius, num_fingers, finger_radius, finger_faces, finger_points, finger_twirl, finger_height) {
+      function medusa(first_ring_radius, num_rings, ring_spacing, num_fingers, finger_radius, finger_faces, finger_points, finger_twirl, finger_height) {
         var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
         var fingers = [];
         var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
         var fingers = [];
-        for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
-          var finger_angle = finger_num / num_fingers;
-          var path = [];
-          for (var finger_point = 0; finger_point <= finger_points; finger_point++) {
-            var angle = (finger_angle + finger_twirl * finger_point / finger_points) * 2 * Math.PI;
-            var x = base_ring_radius * Math.cos(angle);
-            var y = base_ring_radius * Math.sin(angle);
-            path.push([x, y, finger_height * finger_point / finger_points]);
+        for (var ring_num = 0; ring_num < num_rings; ring_num++) {
+          var ring_radius = first_ring_radius + ring_num * ring_spacing;
+          for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
+            var finger_angle = finger_num / num_fingers;
+            var path = [];
+            for (var finger_point = 0; finger_point <= finger_points; finger_point++) {
+              var angle = (finger_angle + finger_twirl * finger_point / finger_points) * 2 * Math.PI;
+              var x = ring_radius * Math.cos(angle);
+              var y = ring_radius * Math.sin(angle);
+              path.push([x, y, finger_height * finger_point / finger_points]);
+            }
+            var finger = nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0]));
+            fingers = fingers.concat(finger);
           }
           }
-          var finger = nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0]));
-          fingers = fingers.concat(finger);
         }
 
         return fingers;
       }
         }
 
         return fingers;
       }
-      var params = [["Base ring radius", 100],
+      var params = [["First ring radius", 20],
+                    ["Number of rings", 10],
+                    ["Space between rings", 10],
                     ["Number of fingers", 5],
                     ["Finger radius", 3],
                     ["Number of fingers", 5],
                     ["Finger radius", 3],
-                    ["Finger faces", 10],
+                    ["Finger faces", 5],
                     ["Finger points", 20],
                     ["Finger twirl (in turns)", .1],
                     ["Finger height", 100]];
                     ["Finger points", 20],
                     ["Finger twirl (in turns)", .1],
                     ["Finger height", 100]];