Archived

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

elliptical orbits

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to create a decent model of a solar system, and when it comes to orbits I''ve been using simple circular orbits based on the average distance away a planet is from the sun. Fine and dandy, if a planet''s orbital distance is 2AU for example, I know how to get the x,y coords of a point on the circle, but I''m not sure of how to manage it for an ellipse. Can anyone point me in the right direction? ------------ - outRider -

Share this post


Link to post
Share on other sites
You could simulate the laws of gravity. This is pretty straightforward, and for realistic orbit times is easy to make accurate.

The law of gravity is that the force between two objects is

GMm
--- = F
r^2

Where the masses are M and m, G is a very small constant and r is the seperation. Because G is very small this force is only noticable if at least one of the objects is very massive: basically planets, moons and large asteroids.

To move an object using this use it with the formula relating force and acceleration:

F = ma

To get

GMm
--- = ma
r^2

and so

GM
--- = a
r^2

This is the acceleration of a mass (m) in orbit around a bigger mass (m), seperated by a distance r from it.

Just work this out every step, and use it to update the mass''s velocity and then position. It should be very accurate as long as the velocity does not change too quickly, and this should be true for realistic, or even very accelerated (e.g. of a few mins), orbits.

Share this post


Link to post
Share on other sites
The parametric equation for an ellipse is x=a*cos(t) and y=b*sin(t). If a=b then you have a circle. If a!=b then you have an ellipse centered at the origin with the minor and major axes being the x and y axes though which is which depends on whether a > b of a < b. If you want a differant center you just add to translate. If you want to rotate by theta then x=a*cos(t)*cos(theta)-b*sin(t)*sin(theta) and y=b*sin(t)*cos(theta)+a*cos(t)*sin(theta). I believe the focal point is a distance of +/-sqrt(a^2-b^2) along the major axis from the center assuming 2a is the length of the major axis and 2b is the length of the minor axis.

Edited by - LilBudyWizer on November 14, 2001 7:21:36 AM

Share this post


Link to post
Share on other sites
Those all seem like good ideas to me, and I am familiar with Kepler''s Laws, but which method would work best? To be honest I have no idea where I''m going with this, so maybe just using the equation of an ellipse would work for simple motion, but on the other hand simulating the sun''s gravity on the planets might me better if I ever planned to add more terrestrial objects and more detail to how the planets behave (comets, prosession, etc.)

Anyhow, thanks for the answers.

------------
- outRider -

Share this post


Link to post
Share on other sites
> ...so maybe just using the equation of an ellipse would work
> for simple motion, ...

The speed or velocity missing from the equations for an ellipse. An object in an elliptical orbit moves faster the closer it is to the mass it is orbiting around, and there''s no way to get this from the parametric ellipse equation: you need to do some extra work with Kepler''s laws to calculate it.

I would still recommend using the law of gravity with the rules for forces and velocities. As you note it generalises into problems with more than one mass easily: in fact it is the only practical approach for such problems. It also lets you add in other forces, such as rocket thrust, or forces due to explosions and collisions, without changing the model.

Share this post


Link to post
Share on other sites
I had the same question a while ago. I wanted to simulate the Solar System accurately, including orbits. However, I wanted my simulation such that:

1. Orbits would not lose accuracy over long periods of time;
2. Simulation could stop, and a simple O(1) (i.e. not depending on the length of time skipped) equation could be applied to work out where to resume.

I decided the best way to achieve this would be to parametrise the movement with time, i.e. the coordinates of the object at time t would be given by equations x = g(t) and y = f(t).

This is easy for a circle:

x = r cos wt
y = r sin wt

but it''s a lot harder for an elliptical orbit. I tried deriving it to no avail. I showed it to one of my maths teachers, whom I''d describe as ''legendary''; he told me to consider Kepler''s Laws, but I never did. Perhaps I''m lazy. Oh well...

But anyway, I thought a bit. It''s worth noting that the Earth takes a whole year to orbit the sun. That''s a long time. The game I''m working on has correct proportions - right from the 6400-km diameter of the Earth to the 4.3-light-year distance to the nearest star (that''s 4.1e+16 metres). As far as I can see, the only fudge in the game is the fact that you can travel at a light-year a second :D That means you''re likely to spend a few minutes - an hour absolute maximum - in one star system, in the context of my game. In that time, the Earth will rotate a bit. Its position relative to the sun will hardly change. So what''s the point of simulating orbits accurately? :rolleyes:

Well that''s how it is for my game. Of course I''m not implying that you shouldn''t be trying to solve this problem - there are many cases where it''s a veritable problem to try to solve. I''m just explaining why I gave up :p However, I should be very interested to see a solution, if anyone has one

Share this post


Link to post
Share on other sites
I was just explaining how to draw an ellipse using a parameteric equation and not suggesting that was how you should do it. I think you should use Kepler''s law. There are many situations where you might need to draw an ellipse so I thought it was worth explaining. Kepler''s law is the correct solution to your problem and mine was just an answer to your question.

Share this post


Link to post
Share on other sites