We are about to switch to a new forum software. Until then we have removed the registration on this forum.
While trying to build a completely different effect, I noticed a few blips on the screen that looked like an old TV. Thought I would share. Click to "change channels"
Edit: Thanks Quark. I flipped the comparison at the top of the for-loop. HTML and greater than/less than symbols do not always get along.
PVector v;
PVector p;
PVector rx;
PVector rz;
int C = 64;
int LIM = C - 1;
int posrange = 64;
int subrange = 32;
float angx = 0; // degrees
float angz = 0; // degrees
int BUNCHATIMES = 16000; //how much static
void setup() {
size(512,512,P3D);
angx = 321;
angz = 280;
v = new PVector(-17, -19, 26);
//Using vectors of unit length will let us rotate without changing speed
rz = new PVector(cos(angx*PI/180), sin(angx*PI/180), 0);
rx = new PVector(0, sin(angz*PI/180), cos(angz*PI/180));
p = new PVector(0, 0, 0);
frameRate(30);
}
void mouseClicked() {
v.set(random(posrange)-subrange, random(posrange)-subrange, random(posrange)-subrange);
p.set(0, 0, 0); //start point could be random too
if (random(1) > 0.5) { //not necessary but seems to change the behavior
v.normalize();
}
angx = random(360); // degrees
angz = random(360); // degrees
rz.set(cos(angx*PI/180), sin(angx*PI/180), 0);
rx.set(0, sin(angz*PI/180), cos(angz*PI/180));
//if you want to save a pattern for later
println("V: " + v);
println("angx: " + angx);
println("angz: " + angz);
}
void rotz(PVector vec, PVector ro) {
float x = vec.x*ro.x - vec.y*ro.y;
float y = vec.x*ro.y + vec.y*ro.x;
vec.x = x;
vec.y = y;
}
void rotx(PVector vec, PVector ro) {
float z = vec.z*ro.z - vec.y*ro.y;
float y = vec.z*ro.y + vec.y*ro.z;
vec.z = z;
vec.y = y;
}
void draw() {
background(20);
loadPixels();
for (int i=0; BUNCHATIMES>i; i++) {
rotz(v, rz);
rotx(v, rx);
p.add(v);
if (p.x > LIM) p.x = p.x - LIM+1;
if (p.y > LIM) p.y = p.y - LIM+1;
if (p.z > LIM) p.z = p.z - LIM+1;
if (p.x < 0) p.x = p.x + LIM;
if (p.y < 0) p.y = p.y + LIM;
if (p.z < 0) p.z = p.z + LIM;
translate(width/2, height/2);
//map x,y,z to somewhere in x,y only
int counter = (int(p.z) << 12) | (int(p.y) << 6) | int(p.x);
if ( (counter < pixels.length) && (counter >= 0)) {
pixels[counter] = color(255);
}
}
updatePixels();
}
I've found a few interesting patterns, replace lines in setup():
angx = 0; angz = 1; v = new PVector(-0.6633987, 0.6191721, -0.4201525);
angx = 14; angz = 4; v = new PVector(-31, 7, -3);
v = new PVector( -31.0, 11.0, 10.0 ); angx = 310.0; angz = 60.0;
v = new PVector( -17.0, -19.0, 26.0 ); angx = 321.0; angz = 280.0;
v = new PVector( 19.0, -28.0, -19.0 ); angx = 0.0; angz = 299.0;
v = new PVector( 26.0, 18.0, 29.0 ); angx = 194.0; angz = 257.0;
v = new PVector( -15.703075, 0.044879913, -27.758442 ); angx = 10.141991; angz = 292.61026;
Comments
There are errors on line 69