# Sun Orbit (from earth pov)

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

## Recommended Posts

i've a problem. i'm writing a simulation wich shows a terrain ( on a planet ) and the sun, moon, stars etc.. but realistic ( so the "orbit" of everything depends on the latitude of the terrain ) but i don't know how i can calc the coordinates for the sun / moon. i've already calculated the earth rotationmatrix, wich will be useful for rotation the starbox, but how can i create an orbit for the inner solar objects? i've no idea how to do that.

##### Share on other sites
Are the sun/earth/moon supposed to move under the influence of gravity?
If yes, you are actually trying to solve the "n body problem" which is far too complicated for three objects. (in fact it may not even have an analytic solution)
Expressing the trajectory of a celestial body as a function of some parameter, is not that easy as it seems.
If you want the actual trajectories, I suppose the only way is to come up with them in real time. Thus, you should set up a dynamic simulation and let three point-masses move under the influence of their own weight. Start the simulation, and let it drive your animation. However there are still issues to consider; e.g. how will you come up with the rotations around their own axes? You'll have to cheat somewhere...

If you would settle for a good approximation, you can always use the parametric equations for a circle or ellipse and simulate the orbits of the earth and moon around the sun. However, there are still issues with that too. E.g. you'll have to find a parametrization that represents actual time in your equations, and to derive such a parameter you'll have to know the actual speed of the body at any point on its orbit...

It's not a trivial problem as it looks first glance...
If you want this to be as realistic as possible, go for the realtime dynamics simulation.

##### Share on other sites
Frame-Based Hierarchy Systems are really good for this sort of thing, or anything requiring additive transformations. Each object would have a separate frame of reference, and therefore a separate matrix. I can't go into the details at the moment, but it's something you might want to look into.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634059
• Total Posts
3015292
×