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.
Page Index Toggle Pages: 1
satelitte (Read 1440 times)
satelitte
Jul 23rd, 2009, 11:31am
 
Hi,
What I would like to do seems quite simple but I can't managed to get it to work,

Imagine an invisible circle in 2D first, I want to draw a point or an ellipse moving on the perimeter of that circle. In 2D I get it to work but not in 3D. It is like representing the movement of a satellite.
Any help to do this would be much appreciated.
Alex
Re: satelitte
Reply #1 - Jul 23rd, 2009, 12:22pm
 
2d:

x = cos( a );
y = sin( a );


3d:

x = cos(phi) * sin(theta);
y = cos(theta);
z = sin(phi) * sin(theta);
Re: satelitte
Reply #2 - Jul 27th, 2009, 8:58am
 
Thanks for your reply, can you be a little more specific ?
I tried this:
float a,x,y;

void setup() {
 size(500,500);
 a= TWO_PI;
}

void draw () {
 background(204);
 x=cos(a);
 y=sin(a);
 a+=HALF_PI/18;
 ellipse(x,y,5,5);
}
Re: satelitte
Reply #3 - Jul 27th, 2009, 9:04am
 
OK after modif I have this
float a,x,y,newx,newy;


void setup() {
 size(500,500);
 a= TWO_PI;
}

void draw () {
 background(204);
 x=cos(a);
 y=sin(a);
 a+=HALF_PI/36;
 newx=map(x,-1,1,0,width);
 newy=map(y,-1,1,0,height);
 ellipse(newx,newy,5,5);

}

But this is still not really looking like a satellite turning around something...
Re: satelitte
Reply #4 - Jul 27th, 2009, 11:05am
 
I wish it would make some BEEP sounds...


float x,y,z;

float theta;
float phi;
void setup() {
size(500,500,P3D);

}

void draw () {
background(0);

lightSpecular(104, 104, 204);
directionalLight(102, 102, 102, 0, 0, -1);
specular(155, 155, 155);

int radius = 150;

theta = theta + 0.05;
phi = phi + 0.01;

x = cos(phi) * sin(theta)* radius;
y = cos(theta)* radius;
z = sin(phi) * sin(theta)* radius;

fill(#01132C);
noStroke();
translate(width/2,height/2);
sphere(100);

fill(#ffaa00);
pushMatrix();
translate(x,y,z);
sphere(20);
popMatrix();

}

BEEP...
BEEP...
BEEP...
BEEP...
Re: satelitte
Reply #5 - Jul 27th, 2009, 11:26am
 
Thats even better Smiley

like we all know the sun turns arround the earth...

Code:
float x,y,z;

float theta;
float phi;
void setup() {
size(500,500,P3D);
sphereDetail(90);
}

void draw () {
background(0);
randomSeed(0);
stroke(100);
for(int i=0;i<=250;i++){
point(random(width),random(height));
}
noStroke();
lights();
lightSpecular(204, 204, 204);
specular(155, 155, 155);
int radius = 180;

theta = theta + 0.05;
phi = phi + 0.01;

x = cos(phi) * sin(theta)* radius;
y = cos(theta)* radius;
z = sin(phi) * sin(theta)* radius;
pointLight(255, 255,255, width/2+x,height/2+y,z);


fill(#01132C);
noStroke();
translate(width/2,height/2, 0);
sphere(100);


fill(#ffaa00);
pushMatrix();
translate(x,y,z);

sphere(20);
popMatrix();

}
Page Index Toggle Pages: 1