# Is there a formula for a planet's orbit in a 3D space?

I'm trying to model the orbits of Earth and Mars and their positions at a given point in time. But I can only find 2D equations of elliptic orbits, which only contain the x and y variables. I have to find formulae or equations for the two orbits that also contain the z variable.

Thank you!

• A pure Kepler ellipse is planar. The orbital elements include info about the 3D orientation of an orbit. You can use matrices to transform coordinates. The diagrams in my answer here might be helpful. astronomy.stackexchange.com/a/43350/16685 Aug 6 at 0:53
• Welcome to Stack Exchange! Modeling orbits is a lot of fun! What are you using to calculate? Pen + paper? Excel? A computer? In addition to using equations for motion in Kepler orbits, you can also do some simple numerical simulations. If you can add some more to your question post about what kinds of calculations you like to do, it will be easier to write an answer that you'll find helpful/useful.
– uhoh
Aug 6 at 10:50
• Additionally this practical approach may help. mathworks.com/matlabcentral/answers/… Exactly, depends on the used tool. Still the more theory posted above might come an easy way to a solution. Aug 6 at 11:05
• Hi @uhoh! I'm using pen&paper + graphic calculator + Mathematica online. Aug 11 at 11:47