# Making 3D planets

Hello, so I have made this program where my planet rotates around the sun.

``````final int SUN_SIZE=50;

final int planetSize=SUN_SIZE/2;
float angle=0;
final float SPEED=0.03;

void setup()
{
size(500,500);
}

void draw()
{
background(0);

fill(255,255,0);
ellipse(width/2,height/2,SUN_SIZE,SUN_SIZE);
fill(200);

angle+=SPEED;

}

``````

What I now need to do is to make the diameter of the planet change, depending on angle, using a sin or cos function. If the planet is straight down from the sun, the diameter of the planet should be increased by 10. If the planet is straight up from the sun, decrease its diameter by 10. It should grow and shrink smoothly as it goes around its orbit.

I know I can use the if condition but I want to do without it. Is there any way to do the above?

1 Like

i think you should do it in real 3D…
not try to emulate 3D in 2D by fake size.
also see

Soon, This is just a small Lab exercise for my class and I am stuck here

the 2 sphere version ( but with my PTZ )
just delete what you not need

but here a small rev of your code:

``````  float zplanetSize = planetSize* (2 + sin(angle));