]> git.scottworley.com Git - nt3d/blobdiff - medusa.html
Twirl the fingers
[nt3d] / medusa.html
index 9099f6a086b53c8f7a1c9183a7d15a67088661c5..58319c006613cbe07b7ae80a088030499de7b65a 100644 (file)
@@ -3,14 +3,18 @@
     <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_height) {
+      function medusa(base_ring_radius, num_fingers, finger_radius, finger_faces, finger_points, finger_twirl, finger_height) {
         var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
         var fingers = [];
         for (var i = 0; i < num_fingers; i++) {
         var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
         var fingers = [];
         for (var i = 0; i < num_fingers; i++) {
-          var base_x = base_ring_radius * Math.cos(i * (2 * Math.PI / num_fingers));
-          var base_y = base_ring_radius * Math.sin(i * (2 * Math.PI / num_fingers));
-          console.log(base_x, base_y);
-          var path = [[base_x, base_y, 0], [base_x, base_y, finger_height]];
+          var finger_angle = i / num_fingers;
+          var path = [];
+          for (var j = 0; j <= finger_points; j++) {
+            var angle = (finger_angle + finger_twirl * j / 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 * j / 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);
         }
@@ -21,6 +25,8 @@
                     ["Number of fingers", 5],
                     ["Finger radius", 3],
                     ["Finger faces", 10],
                     ["Number of fingers", 5],
                     ["Finger radius", 3],
                     ["Finger faces", 10],
+                    ["Finger points", 20],
+                    ["Finger twirl (in turns)", .1],
                     ["Finger height", 100]];
     </script>
   </head>
                     ["Finger height", 100]];
     </script>
   </head>