Computer Science Canada Finding the Moon's position in orbit |
Author: | bass_maniac [ Mon Nov 15, 2004 5:24 pm ] |
Post subject: | Finding the Moon's position in orbit |
I'm trying to make a program in which the Earth (a circle) is at the center of the screen. It has a radius of 25. I want to have the moon orbit the Earth at a distance of 100 pixels from the center of the Earth in a counter-clockwise direction. If the initial values are: earthX := maxx div 2 earthY := maxy div 2 moonX := earthX + 100 moonY := earthY How do I calculate the next position of the moon? |
Author: | Tony [ Mon Nov 15, 2004 6:26 pm ] | ||
Post subject: | |||
use an equation of the circle
btw, Earth is not at the center of the world, make it orbit the sun ![]() |
Author: | Mazer [ Mon Nov 15, 2004 6:40 pm ] |
Post subject: | |
tony wrote: btw, Earth is not at the center of the world, make it orbit the sun
![]() The Earth isn't at the center of the world? Damn. But why would you want the moon to orbit the Sun? From my understanding, you just want to use trig, right? So that for whatever angle you have, the moon's x is equal to 100 * the cosine of the angle. Same goes for the y coord, just replacing cosine with sine. (Don't forget to add half the screen width and height to the coordinates) |
Author: | bass_maniac [ Mon Nov 15, 2004 7:00 pm ] | ||
Post subject: | |||
Thank you Coutsos. Just for interest's sake, here's what I've come up with so far,
|