Archived

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

EternalOne2004

Orbit of a planet based upon time?

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


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

Share this post


Link to post
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

Share this post


Link to post
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.
I remember that we used a very simple trick to solve this problem. Something like the reduced mass. I could look it up...

Share this post


Link to post
Share on other sites
for the two body case, consider the center of gravity which doesn''t move. Remove on body, replace it with the UNMOVABLE cg of a compensated mass.
It''s mathematically equivalent.
Then, once you''ve determined the path of the body you kept, you can analytically determine the path of the body that was removed by writing the balance equation expressing the fact that the CG does not move, and there you go.

Share this post


Link to post
Share on other sites