# Math Help - Cartesian Coordinates of Planets in Orbit Relative to Time

1. ## Cartesian Coordinates of Planets in Orbit Relative to Time

Hello everyone,

I've been searching for days to find a simple method of calculating the X,Y,Z coordinates of a planet that is in orbit at any point in time around another planet/star/sun. All of the related resources I've found are heavily focused on finding values based on observing actual planets in motion and calculating parameters such as eccentricity, etc, but my situation seems slightly different and I don't know exactly how to tackle it. I'm wanting to simulate a random orbit that I create in a software application, not calculate values based on observing a planet in orbit. In my mind, this should be easier to do, but I'm still struggling with the math.

To put it more precisely, here's what I would like to do.

1. Create a stationary "sun" at point $X_c,Y_c,Z_c$
2. Create multiple "planets" at points $X_n,Y_n,Z_n$ where n is the number of the planet from 1 to infinity
3. Generate all of the necessary parameters to define each planet's orbit around the sun while only looking to avoid collisions at intersection points (if possible)
4. For each computer cycle, calculate the new position of each planet based on their calculated orbits

I'm hoping to avoid using physics altogether (no mass, force, etc needed) as accuracy is not nearly as important as efficiency in terms of CPU cycles of my simulation.

Can anyone lead me in the right direction?

Thanks,
Marc

2. Originally Posted by bytescape
Hello everyone,

I've been searching for days to find a simple method of calculating the X,Y,Z coordinates of a planet that is in orbit at any point in time around another planet/star/sun.
...

To put it more precisely, here's what I would like to do.
1.Create a stationary "sun" at point $X_c,Y_c,Z_c$
2.Create multiple "planets" at points $X_n,Y_n,Z_n$ where n is the number of the planet from 1 to infinity
3.Generate all of the necessary parameters to define each planet's orbit around the sun while only looking to avoid collisions at intersection points (if possible)
4.For each computer cycle, calculate the new position of each planet based on their calculated orbits

Can anyone lead me in the right direction?

Thanks,
Marc
If you are excluding ALL problems associated with mass, then for each planet create your elliptical parameters.
You can place the Planet(X,Y,Z,T,eccentricity) anywhere and then as the time variable changes you can adjust the coordinates.

If the orbits are not affected by other objects, then the orbit will always be constant. As such you can determine ALL possible intersection points ahead of time. This will greatly reduce your need to check for intersection/collisions. For each planet you will have a very limited number of points for possible intersections. Planet A might have an intersection with Planet C & Planet H. After you have adjusted all coordinates (for all the planets), check the distance between planet A & planet C ; then check the distance between A & H. If the distance exceeds the radius of the collision limit then there will not be a wonderful fireworks display.

It is really more fun to use the interaction that gravity plays with the entities.

3. Originally Posted by aidan
If you are excluding ALL problems associated with mass, then for each planet create your elliptical parameters.
You can place the Planet(X,Y,Z,T,eccentricity) anywhere and then as the time variable changes you can adjust the coordinates.

If the orbits are not affected by other objects, then the orbit will always be constant. As such you can determine ALL possible intersection points ahead of time. This will greatly reduce your need to check for intersection/collisions. For each planet you will have a very limited number of points for possible intersections. Planet A might have an intersection with Planet C & Planet H. After you have adjusted all coordinates (for all the planets), check the distance between planet A & planet C ; then check the distance between A & H. If the distance exceeds the radius of the collision limit then there will not be a wonderful fireworks display.

It is really more fun to use the interaction that gravity plays with the entities.
Thanks for the reply. I pretty much came to the same conclusion yesterday and started coding for the solution provided by Wikipedia. The only part that troubled me was calculating the eccentric anomaly using the Newton-Raphson method. It wouldn't be so bad if E didn't have to be calculated every cycle. Newton's method seems to take the same number of iterations as the precision of the final result that you are seeking, and I am worried that ignoring the precision of E will cause the orbit to vary over time (but maybe that isn't the case?)

I've seen other examples in Java applets, etc, that seem to use a tangent velocity to calculate the next position of the planet each cycle. While this seems that it would be the most efficient method, it seems to me that it would break down if the frames per second were to drop, thereby causing the updates to occur at different intervals.

Regarding the physics aspects of the problem, don't get me wrong. I would love to give the system a mind of its own and let it run free, but it would essentially make it impossible for me to generate a completely random universe simulation while still avoiding collisions and "near misses" from sending planets off into space. At least from my experiments. lol.

Maybe my math is off, but I still can't seem to find the "best" solution to my problem.