[Helix][perf] Do not process points outside of the coil area
authorShaheen Gandhi <shaheen@fb.com>
Mon, 19 Aug 2013 01:03:12 +0000 (18:03 -0700)
committerShaheen Gandhi <shaheen@fb.com>
Mon, 19 Aug 2013 01:03:12 +0000 (18:03 -0700)
ShaheenGandhi.pde

index 5e2c88cd1c3bdfeac7a3822ae85bb226335b94f6..ff6ce2edcf82d4ce840eb105eaff462a5bda97a2 100644 (file)
@@ -106,9 +106,16 @@ class HelixPattern extends SCPattern {
     }
 
     color colorOfPoint(final PVector p) {
+      float t = axis.getTValue(p);
+
+      // For performance reasons, cut out points that are outside of
+      // the tube where the toroidal coil lives.
+      if (abs(PVector.dist(p, axis.getPointAt(t)) - radius) > girth*.5f) {
+        return color(0,0,0);
+      }
+
       // Find the appropriate point for the current rotation
       // of the helix.
-      float t = axis.getTValue(p);
       PVector toroidPoint = pointOnToroidalAxis(t);
 
       // The rotated point represents the middle of the girth of