From 5e66f02abf02dec9975aa5be26a11df6bd5b4722 Mon Sep 17 00:00:00 2001 From: Shaheen Gandhi Date: Sun, 18 Aug 2013 20:22:06 -0700 Subject: [PATCH] [Helix][perf] Reduce toroidal coil point calculations for spokes by half --- ShaheenGandhi.pde | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ShaheenGandhi.pde b/ShaheenGandhi.pde index 09f513f..b757f40 100644 --- a/ShaheenGandhi.pde +++ b/ShaheenGandhi.pde @@ -180,14 +180,12 @@ class HelixPattern extends SCPattern { float t = h1.getAxis().getTValue(pt) + spokePhase; float spokeAxisTValue = floor(((t + spokePeriod/2) / spokePeriod)) * spokePeriod; PVector h1point = h1.pointOnToroidalAxis(spokeAxisTValue); - PVector h2point = h2.pointOnToroidalAxis(spokeAxisTValue); - PVector spokeVector = PVector.sub(h2point, h1point); + // TODO(shaheen) investigate why h1.getAxis().getPointAt(spokeAxisTValue) doesn't quite + // have the same value as finding the middle between h1point and h2point. + PVector spokeCenter = h1.getAxis().getPointAt(spokeAxisTValue); + PVector spokeVector = PVector.sub(h1point, spokeCenter); spokeVector.normalize(); Line spokeLine = new Line(h1point, spokeVector); - float spokeLength = PVector.dist(h1point, h2point); - // TODO(shaheen) investigate why h1.getAxis().getPointAt(spokeAxisTValue) doesn't quite - // have the same value. - PVector spokeCenter = PVector.add(h1point, PVector.mult(spokeVector, spokeLength/2.f)); PVector pointOnSpoke = spokeLine.projectPoint(pt); float b = ((PVector.dist(pt, pointOnSpoke) < spokeGirth) && (PVector.dist(pointOnSpoke, spokeCenter) < spokeRadius)) ? 100.f : 0.f; return color(100, 80.f, b); -- 2.34.1