Archived

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

EternalOne2004

Orbit of a planet based upon time?

Recommended Posts

oliii    2196
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
teamonkey    200
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
SpaceDude    208
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
teamonkey    200
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
EternalOne2004    122
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
Cedric    158
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
janos    224
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