Documentation000_upload
Transform your PDFs into Flipbooks and boost your revenue!
Leverage SEO-optimized Flipbooks, powerful backlinks, and multimedia content to professionally showcase your products and significantly increase your reach.
// Claus Rytter Bruun de Neergaard
// www.clausclaus.com, March, 2013
// Tested in Processing 2.0b8
// RANDOM WALK
import peasy.*;
PeasyCam cam;
int n = 3000;
int step = 5;
int space = 500;
int x = 0, y = 0, z = 0;
int[] posX = new int[n];
int[] posY = new int[n];
int[] posZ = new int[n];
void setup() {
size(500, 500, P3D);
background(235);
stroke(0, 100);
cam = new PeasyCam(this, 900);
compare();
}
void draw() {
background(235);
stroke(0, 100);
strokeWeight(5.0);
for (int i = 0; i < n; i++) {
point(posX[i], posY[i], posZ[i]);
}
noFill();
strokeWeight(0.25);
box(space);
}
void keyPressed() {
if (key == ‘r’) {
x = 0;
y = 0;
z = 0;
compare();
}
}
void compare() {
for (int i = 0; i < n; i++) {
// create random integer for direction
int r = int(random(0, 25));
println(r);
// compare random integer to direction numbers,
// and add position value
if (r == 0) {
x -= step;
y += step;
z += step;
}
else if (r == 1) {
y += step;
z += step;
}
else if (r == 2) {
x += step;
y += step;
z += step;
}
else if (r == 3) {
x += step;
z += step;
}
else if (r == 4) {
x += step;
y -= step;
z += step;
}
else if (r == 5) {
y -= step;
z += step;
}
else if (r == 6) {
x -= step;
y -= step;
z += step;
}
else if (r == 7) {
x -= step;
z += step;
}
else if (r == 8) {
z += step;
}
else if (r == 9) {
x -= step;
y += step;
}
else if (r == 10) {
y += step;
}
else if (r == 11) {
x += step;
y += step;
}
else if (r == 12) {
x += step;
}
else if (r == 13) {
x += step;
y -= step;
}
else if (r == 14) {
y -= step;
}
else if (r == 15) {
x -= step;
y -= step;
}
else if (r == 16) {
x -= step;
}
else if (r == 17) {
x -= step;
y += step;
z -= step;
}
else if (r == 18) {
y += step;
z -= step;
}
else if (r == 19) {
x += step;
y += step;
z -= step;
}
else if (r == 20) {
x += step;
z -= step;
}
else if (r == 21) {
x += step;
y -= step;
z -= step;
}
else if (r == 22) {
y -= step;
z -= step;
}
else if (r == 23) {
x -= step;
y -= step;
z -= step;
}
else if (r == 24) {
x -= step;
z -= step;
}
else if (r == 25) {
z -= step;
}
// write position values to array
posX[i] = x;
posY[i] = y;
posZ[i] = z;
}
}
code studies --- 7 | 29