Orbit of a planet based upon time?

Started by
10 comments, last by EternalOne2004 20 years, 3 months ago
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
Advertisement
Circular motion

in your case

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.

Everything is better with Metal.

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]
[teamonkey] [blog] [tinyminions]
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..
you just structure your systems as a hierarchy.

Everything is better with Metal.

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]
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]
[teamonkey] [blog] [tinyminions]
he just wants planets orbiting in circle I don''t think he fancies solving differential equations for that :D

Everything is better with Metal.

Just have them attract each other with gravity. Then it will almost be like real life.
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

This topic is closed to new replies.

Advertisement