X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ShaheenGandhi.pde;h=86ead55757e830e9ee4fed4bfa56a23efcb766c0;hb=e034041e0651b6e57ebb2d2399df8a560c92b231;hp=d562e3bd3fed0b12357611d46d4bb8072c76ebd6;hpb=b8f61125ba62e4d775afff07ce1cf6ca2b6dd394;p=SugarCubes.git diff --git a/ShaheenGandhi.pde b/ShaheenGandhi.pde index d562e3b..86ead55 100644 --- a/ShaheenGandhi.pde +++ b/ShaheenGandhi.pde @@ -115,6 +115,13 @@ class HelixPattern extends SCPattern { PVector middle = PVector.add(p, phaseNormal); return axis.rotatePoint(middle, (t / period) * TWO_PI + phase); } + + private float myDist(PVector p1, PVector p2) { + final float x = p2.x-p1.x; + final float y = p2.y-p1.y; + final float z = p2.z-p1.z; + return sqrt(x*x + y*y + z*z); + } color colorOfPoint(final PVector p) { final float t = axis.getTValue(p); @@ -122,7 +129,7 @@ class HelixPattern extends SCPattern { // For performance reasons, cut out points that are outside of // the tube where the toroidal coil lives. - if (abs(PVector.dist(p, axisPoint) - radius) > girth*.5f) { + if (abs(myDist(p, axisPoint) - radius) > girth*.5f) { return color(0,0,0); } @@ -135,7 +142,7 @@ class HelixPattern extends SCPattern { // The rotated point represents the middle of the girth of // the helix. Figure out if the current point is inside that // region. - float d = PVector.dist(p, toroidPoint); + float d = myDist(p, toroidPoint); // Soften edges by fading brightness. float b = constrain(100*(1 - ((d-.5*girth)/(girth*.5))), 0, 100);