# Patterns while zooming using PeasyCam

Hello
I’m kinda new to the community so i hope this is the right place to ask.
I played a little with 3D Chaos game to create fractals, while doing so i tried to make a 2d shape in 3d space made of dots.
I was surprised to see that i get different patterns in the 2d shape while zooming.
Does anyone knows why this is happening? maybe it has something to do with PeasyCam itself or computer graphics in general? I just find it interesting so id like to know.

here is an example:

and my code:

``````import peasy.*;

PeasyCam cam;

PVector[][] globe;
PVector[][] colo;
int total = 400;
int r = 200;
int flag = 0;

void setup() {
size(600, 600, P3D);
cam = new PeasyCam(this, 500);
globe = new PVector[r+1][(r+1)];
colo = new PVector[r+1][(r+1)];
createChaos();
}

void draw() {
background(0);

stroke(255);
if (flag == 1)
{
for (int i = 0; i <= r; i++) {
for (int j = 0; j <= (r-i); j++) {
stroke(colo[i][j].x,colo[i][j].y,colo[i][j].z);
point(globe[i][j].x,globe[i][j].y,globe[i][j].z);
}
}
}
}

void createChaos(){
float x = 0;
float y = 0;
float z = 0;
int i,j,k = 0;
int a = 0,b = 0,c = 0;

for (i = 0; i <= r; i++) {
for (j = 0; j <= r-i; j++) {

a = 255;
b = 0;
c = 0;

globe[i][j] = new PVector(x, y, z);
colo[i][j] = new PVector (a,b,c);
k++;
x = i;
y = j;

}
k = 0;
}
flag = 1;
}
``````

hi,
moiré patterns you get here is not linked to PeasyCam it will be the same using scale()/rotate()
to draw you use
`point(globe[i][j].x,globe[i][j].y,globe[i][j].z);`
in default 2d, point(x,y) will precisely draw x,y pixel but in 3d, when you zoom or rotate this point is projected on your flat 2D screen, it will not precisely fall anymore on one of your screen image pixel (integer positions in 2d position will be real numbers after projection) then videocard have to decide what to do when you ask to draw something like x=50.3333 y=34.236673 .
Point doesn’t have dimension so in 3d it s better to play with 3d objects, lines boxes…

however all the patterns you get here is from this videocard interpretation, i mean createChaos() doesn’t look very chaotic to me , i suggest you to look what value will be put in globe[][] for some values of i and j and same for colo[][], i’m not sure it does what you expect

Hope it help, i 've hard time to be more clear with my poor english…

oh you can ignore the names of the function, i just played with some stuff i did before with fractals and got into this.
I wanted to know whats going on and i guess i got an answer. thanks