[Helix][perf] Reduce number of point calculations.
authorShaheen Gandhi <shaheen@fb.com>
Mon, 19 Aug 2013 03:50:27 +0000 (20:50 -0700)
committerShaheen Gandhi <shaheen@fb.com>
Tue, 20 Aug 2013 07:18:30 +0000 (00:18 -0700)
ShaheenGandhi.pde

index dcdb90800a84c754aa4bbb9a2f20a327d6ab0b24..d562e3bd3fed0b12357611d46d4bb8072c76ebd6 100644 (file)
@@ -117,11 +117,12 @@ class HelixPattern extends SCPattern {
     }
 
     color colorOfPoint(final PVector p) {
-      float t = axis.getTValue(p);
+      final float t = axis.getTValue(p);
+      final PVector axisPoint = axis.getPointAt(t);
 
       // 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) {
+      if (abs(PVector.dist(p, axisPoint) - radius) > girth*.5f) {
         return color(0,0,0);
       }