We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Awesome Image, but not what i was looking for
Page Index Toggle Pages: 1
Awesome Image, but not what i was looking for (Read 1201 times)
Awesome Image, but not what i was looking for
Jun 23rd, 2005, 7:16pm
 
I just wanted to make a 3D cube with just points, and omitting every other point to make it distinct. What I got was something really strange, but at the same time awesome. If you run the program you'll see what I mean.
---------------------------------------
size(200,200, P3D);
int x=0;
int y=0;
int z=0;
background(255);
for(x=50;x<150;x=x+2)
{
for(y=50;y<150;y=y+2)
{
for(z=50;z<150;z=z+2)
point(x,y,z);
}
}
---------------------------------------
OK could someone explain what's happening, why it takes the fullscreen instead of just 100 pixels, and how the image came about.
THANKS
P.S. With some modifications, like x,y,z=100 instead of 50, I get the bottom-right view of the full picture. ???
Re: Awesome Image, but not what i was looking for
Reply #1 - Jun 23rd, 2005, 8:07pm
 
It looks like a "Z" value of negative is "in front" of the viewer.

If you change it to point(x,y,-z) it looks more like a cube.

http://processing.org/reference/environment/index.html#Coordinates
Re: Awesome Image, but not what i was looking for
Reply #2 - Jun 23rd, 2005, 8:35pm
 
Thanks a lot! Now I know how the picture came about - density from the number of pixels! It's still awesome. Anyway, I made an extension of the same program which turns the cube around and stuff. Thanks again!
----------------------------------------
int x=0;
int y=0;
int z=0;
int a=0;
int b=0;
int c=0;
void setup()
{
size(200,200, P3D);
for(x=50;x<100;x=x+5)
{
for(y=50;y<100;y=y+5)
{
for(z=50;z<100;z=z+5)
point(x,y,-z);
}
}
x=50;
y=50;
z=50;
}
void draw()
{
background(255);
for(x=a;x<a+50;x=x+5)
{
for(y=b;y<b+50;y=y+5)
{
for(z=c;z<c+50;z=z+5)
point(x,y,-z);
}
}
}
void keyPressed()
{
if(key=='q')
a++;
if(key=='w')
a--;
if(key=='a')
b++;
if(key=='s')
b--;
if(key=='z')
c++;
if(key=='x')
c--;
if(key=='p')
println(a+" "+b+" "+c);
}
----------------------------------------
Page Index Toggle Pages: 1