repositories
/
SugarCubes.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ffb4b60
)
[Helix] Remove unnecessary calculations.
author
Shaheen Gandhi
<shaheen@fb.com>
Sun, 18 Aug 2013 23:18:11 +0000
(16:18 -0700)
committer
Shaheen Gandhi
<shaheen@fb.com>
Mon, 19 Aug 2013 00:09:02 +0000
(17:09 -0700)
ShaheenGandhi.pde
patch
|
blob
|
blame
|
history
diff --git
a/ShaheenGandhi.pde
b/ShaheenGandhi.pde
index a842fcf4a343b423a61e813353211e10ae4a0e47..4b61ca03c8aa9750d6b13cbfd48d5316f35adbf7 100644
(file)
--- a/
ShaheenGandhi.pde
+++ b/
ShaheenGandhi.pde
@@
-88,11
+88,6
@@
class HelixPattern extends SCPattern {
phaseNormal.mult(radius);
}
phaseNormal.mult(radius);
}
- private void setPhase(float phase) {
- this.phase = phase;
- setPhaseNormalFromPhase();
- }
-
Line getAxis() {
return axis;
}
Line getAxis() {
return axis;
}
@@
-100,31
+95,30
@@
class HelixPattern extends SCPattern {
void step(int deltaMs) {
// Rotate
if (rotationPeriod != 0) {
void step(int deltaMs) {
// Rotate
if (rotationPeriod != 0) {
-
setPhase(phase + (deltaMs /
rotationPeriod) * TWO_PI);
+
this.phase = (phase + ((float)deltaMs / (float)
rotationPeriod) * TWO_PI);
}
}
PVector pointOnToroidalAxis(float t) {
PVector p = axis.getPointAt(t);
PVector middle = PVector.add(p, phaseNormal);
}
}
PVector pointOnToroidalAxis(float t) {
PVector p = axis.getPointAt(t);
PVector middle = PVector.add(p, phaseNormal);
- return axis.rotatePoint(middle, (t / period) * TWO_PI);
+ return axis.rotatePoint(middle, (t / period) * TWO_PI
+ phase
);
}
color colorOfPoint(final PVector p) {
// Find the appropriate point for the current rotation
// of the helix.
}
color colorOfPoint(final PVector p) {
// Find the appropriate point for the current rotation
// of the helix.
- float t = axis.getTValue(p
rojectedPoint
);
+ float t = axis.getTValue(p);
PVector toroidPoint = pointOnToroidalAxis(t);
// 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);
PVector toroidPoint = pointOnToroidalAxis(t);
// 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);
- boolean inToroid = d < girth;
- // Soften edges by fading brightness
+ // Soften edges by fading brightness
.
float b = constrain(100*(1 - ((d-.5*girth)/(girth*.5))), 0, 100);
float b = constrain(100*(1 - ((d-.5*girth)/(girth*.5))), 0, 100);
- return color((lx.getBaseHuef() + (360*(phase / TWO_PI)))%360,
(inToroid ? 80 : 0)
, b);
+ return color((lx.getBaseHuef() + (360*(phase / TWO_PI)))%360,
80
, b);
}
}
}
}
@@
-141,16
+135,16
@@
class HelixPattern extends SCPattern {
addParameter(helix2On);
h1 = new Helix(
addParameter(helix2On);
h1 = new Helix(
- new Line(new PVector(100, 50,
70
), new PVector(1,0,0)),
-
7
00, // period
-
5
0, // radius
+ new Line(new PVector(100, 50,
45
), new PVector(1,0,0)),
+
1
00, // period
+
4
0, // radius
30, // girth
0, // phase
10000); // rotation period (ms)
h2 = new Helix(
new Line(new PVector(100, 50, 70), new PVector(1,0,0)),
30, // girth
0, // phase
10000); // rotation period (ms)
h2 = new Helix(
new Line(new PVector(100, 50, 70), new PVector(1,0,0)),
-
7
00,
-
5
0,
+
1
00,
+
4
0,
30,
PI,
10000);
30,
PI,
10000);