repositories
/
SugarCubes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[Helix][perf] Write replacement distance function for inlining
[SugarCubes.git]
/
ShaheenGandhi.pde
diff --git
a/ShaheenGandhi.pde
b/ShaheenGandhi.pde
index d562e3bd3fed0b12357611d46d4bb8072c76ebd6..86ead55757e830e9ee4fed4bfa56a23efcb766c0 100644
(file)
--- 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);
}
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);
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.
// For performance reasons, cut out points that are outside of
// the tube where the toroidal coil lives.
- if (abs(
PVector.d
ist(p, axisPoint) - radius) > girth*.5f) {
+ if (abs(
myD
ist(p, axisPoint) - radius) > girth*.5f) {
return color(0,0,0);
}
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.
// 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.d
ist(p, toroidPoint);
+ float d =
myD
ist(p, toroidPoint);
// Soften edges by fading brightness.
float b = constrain(100*(1 - ((d-.5*girth)/(girth*.5))), 0, 100);
// Soften edges by fading brightness.
float b = constrain(100*(1 - ((d-.5*girth)/(girth*.5))), 0, 100);