planitary motion

i wan to make a program that will simulate the earth orbiting the sun. i have all the opengl experience i just don't get the physics behind it. can anyone help me get an orbit going?
thanks in advance.
Do you want to simulate Newtonian laws (simple) or Einstein's relativity (hard)?
Last edited on
If this is just an OpenGL class project, you should keep in mind that the Earth and Sun are so vastly far apart that you won't be able to see both at the same time in your window, unless you really distort their sizes and the distances involved. Just use a simple circle or ellipse.
Or unless the camera is behind the Earth, with the Sun in the background, kinda like in 2001: A Space Odyssey.
Duoas wrote:
Earth and Sun are so vastly far apart that you won't be able to see both at the same time in your window, unless you really distort their sizes and the distances involved. Just use a simple circle or ellipse.
The OP doesn't say that size/distance must be kept with the same scale
You can go at this from a couple angles, with varying degrees of complexity.

General Relativity is overkill for something as relatively (no pun intended) simplistic as simulating a planetary orbit, so just sticking to Newtonion physics is fine for a simple simulator at that.

From there though, you have a couple angles of attack and some options for simplifying the calculations or more accurately simulating the orbit.

For just determining the orbital path of the earth around the sun, you can use Kepler's laws of planetary motion. If you want to assume a circular orbit, the calculations can be simplified, and the Earth's orbit is only slightly eccentric so it would still be a pretty close approximation.

That only allows you to calculate orbital paths, not simulate them. For that you need to use Newton's law of universal gravitation to simulate the forces acting upon the planetary bodies, perhaps using Kepler's laws to determine the starting points/velocities. You can use a simple Euler integration to drive the simulation, and with small time intervals should be accurate for a while, perhaps resetting the simulation every year to avoid any noticeable drift
helios wrote:
Or unless the camera is behind the Earth, with the Sun in the background, kinda like in 2001: A Space Odyssey.
A very geocentric POV; and otherwise quite rare. Besides which, OpenGL cannot handle distances in that way without some fancy trickery behind the scenes.

Bazzy wrote:
The OP doesn't say that size/distance must be kept with the same scale
Yes, but this is a common class assignment for introduction to 3d computer graphics courses. The instructor is far more interested in seeing little colored spheres circling each other on the display than mathematical precision.

Hence, the subjunctive nature of my response. If I am mistaken, then it can be ignored.
Topic archived. No new replies allowed.