Posted: 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?
Sponsor Sponsor
Tony
Posted: Mon Nov 15, 2004 6:26 pm Post subject: (No subject)
use an equation of the circle
code:
x**2 + y**2 = r**2
btw, Earth is not at the center of the world, make it orbit the sun
Posted: Mon Nov 15, 2004 6:40 pm Post subject: (No 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)
bass_maniac
Posted: Mon Nov 15, 2004 7:00 pm Post subject: (No subject)
Thank you Coutsos. Just for interest's sake, here's what I've come up with so far,
code:
View.Set ("graphics:max;max,offscreenonly")
var earthX := maxx div 2
var earthY := maxy div 2
var moonX : real := earthX + 100
var moonY : real := earthY
var angle := 0.0