We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Saw a video on a device used by ships to avoid objects under water. Moire pattern appears on the device. The idea is that an 'arrow' changes depending where you are standing.
This is a simplified version of it. I think the real one has a different pattern inside.
If you are directly in front of it, the lines are parallel (ideally anyway). I have reversed the rotation so it points in the direction to move the mouse in order to center the lines, instead of where to move your point of view.
void setup()
{
size(256,256,P3D);
noFill();
stroke(255);
}
void draw()
{
background(0);
int STP = 9; // Spacing of lines
float ROT = PI/32; // Angle of lines
translate(width/2,height/2, -200);
rotateY(-mouseX*TAU/width);
pushMatrix();
rotateX(ROT);
for (int x=0; x<width; x+=STP)
{
line(x-width/2,-height/2, x-width/2,height/2);
}
popMatrix();
pushMatrix();
rotateX(-ROT);
for (int x=0; x<width; x+=STP)
{
line(x-width/2,-height/2, x-width/2,height/2);
}
popMatrix();
scale(1,1,0.25);
box(height);
}
Comments
I changed line 26 to introduce a second degree of freedom:
rotateX(map(mouseY,0,height,-ROT-0.5,-ROT+0.5));
So right now, moving along X gives you the impression of viewing either from the side or right from the front. Moving the mouse along the Y, you can adjust the rotation between the two line planes by a small amount.
Cool demo, thxs for sharing.
Kf