#### Archived

This topic is now archived and is closed to further replies.

# Orbit of a planet based upon time?

This topic is 5305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m looking for a way to do planetary orbits based upon time. If I know it takes x seconds for a complete orbit, how would I figure out where it should be at time y? Thanks! EternalOne

##### Share on other sites
Circular motion

angular_velocity = 2 * PI / orbit_time;

also, you can try

angle = start_angle + GetCurrentTime() * angular_velocity;
x = circle_centre_x + circle_radius_x * cos(angle);
y = circle_centre_y + circle_radius_y * sin(angle);

GetCurrentTime() is the current time in the game.
start angle is angle when time = 0.

##### Share on other sites
That''s assuming that the central star doesn''t move. If you want both the star and the planet to move, things get a bit more complex. If you want to find the general formula for the positions of more than two bodies as a function of time, you can''t

[teamonkey]

##### Share on other sites
quote:
Original post by teamonkey
That''s assuming that the central star doesn''t move. If you want both the star and the planet to move, things get a bit more complex. If you want to find the general formula for the positions of more than two bodies as a function of time, you can''t

Sure you can... just need to make circle_centre_x & circle_centre_y a function of time..

##### Share on other sites
you just structure your systems as a hierarchy.

##### Share on other sites
http://www.astronomynotes.com/gravappl/s8.htm

EDIT: Do proceed to the following sections where you'll meet Mr. Kepler.

[edited by - CWizard on January 6, 2004 9:23:39 AM]

##### Share on other sites
quote:
Original post by SpaceDude
Sure you can... just need to make circle_centre_x & circle_centre_y a function of time..

Yeah, but only if you know those functions. A three-body system is chaotic. You can determine a set of functions for, say, the Earth-Moon-Sun system for a certain set of initial conditions. Change the conditions even a little bit, and you have to create a new set of functions. Traditionally, the orbit of the Earth-Moon-Sun system as a function of time is calculated by setting the mass of the moon to zero, because that way you can use the general two-body equations for any set of starting conditions.

[teamonkey]

##### Share on other sites
he just wants planets orbiting in circle I don''t think he fancies solving differential equations for that :D

##### Share on other sites
Just have them attract each other with gravity. Then it will almost be like real life.

##### Share on other sites
Yup! Thanks all, I got it working perfectly now.

My planets were already in a hierarchy, and by using the system that oliii posted, I was able to get a galaxy where planets orbit the sun, and moons orbit the planets, all based upon a function of time. (So if my client/server agree that its tick 400, time index 20 -- they both know where all the planets and moons are located that the current time.)

Plus, to make things even cooler, I''m adding in ships orbiting planets/moons. It was overall a very simplistic solution, once I had the time functions. Thank you very much!

E1

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 30
• 41
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631741
• Total Posts
3001979
×