]> git.scottworley.com Git - nt3d/blobdiff - medusa.html
Rings alternate twirl directions
[nt3d] / medusa.html
index 87e9301b9d7723652f06a77ea3e425b74e9a59d9..7a4babd9e69a8eaca8940dd1a4c998c694e6f091 100644 (file)
@@ -3,10 +3,10 @@
     <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 finger(params, finger_crosssection, ring_radius, finger_angle) {
+      function finger(params, finger_crosssection, ring_num, ring_radius, finger_angle) {
         var path = [];
         var path = [];
-        var twirl_angle = params.finger_twirl_distance / (ring_radius * 2 * Math.PI);
-        console.log(twirl_angle);
+        var twirl_amplitute = Math.cos((ring_num * 2 * Math.PI) / params.finger_twirl_period);
+        var twirl_angle = twirl_amplitute * params.finger_twirl_distance / (ring_radius * 2 * Math.PI);
         for (var finger_point = 0; finger_point <= params.finger_points; finger_point++) {
           var angle = (finger_angle + twirl_angle * finger_point / params.finger_points) * 2 * Math.PI;
           var x = ring_radius * Math.cos(angle);
         for (var finger_point = 0; finger_point <= params.finger_points; finger_point++) {
           var angle = (finger_angle + twirl_angle * finger_point / params.finger_points) * 2 * Math.PI;
           var x = ring_radius * Math.cos(angle);
@@ -23,7 +23,7 @@
           var num_fingers = Math.round((ring_radius * 2 * Math.PI) / params.finger_spacing);
           for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
             var finger_angle = finger_num / num_fingers;
           var num_fingers = Math.round((ring_radius * 2 * Math.PI) / params.finger_spacing);
           for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
             var finger_angle = finger_num / num_fingers;
-            fingers = fingers.concat(finger(params, finger_crosssection, ring_radius, finger_angle));
+            fingers = fingers.concat(finger(params, finger_crosssection, ring_num, ring_radius, finger_angle));
           }
         }
 
           }
         }
 
@@ -37,6 +37,7 @@
                     ["finger_faces", 3],
                     ["finger_points", 20],
                     ["finger_twirl_distance", 50],
                     ["finger_faces", 3],
                     ["finger_points", 20],
                     ["finger_twirl_distance", 50],
+                    ["finger_twirl_period", 2, "Finger Twirl Period (1=same, 2=alternating)"],
                     ["finger_height", 100]];
     </script>
   </head>
                     ["finger_height", 100]];
     </script>
   </head>