What is the equation describing earth's orbit around the sun in 3 dimensional space? I'm trying to draw a 2d ellipse in 3d space, which describes earth's orbit around the sun. such as image of a 2d ellipse in 3d space or the same image but different perspective. I'd like to be able to get the z y x coordinates of the planet at any give time. What would be the best way to go about it?
 A: The best approach may well depends on what your specific use case is.
Typically you need two things: a description of an ellipse in a plane, and a relationship between that orbital plane and the 3d coordinate system.
Since the ellipse will have the sun as a focus, you might go with a description in terms of polar coordinates. So you would have a function $r(\theta)$ to describe the distance from the sun as a function of angle. Then you could combine the conversion from polar coordinates into Cartesian coordinates with the switch from 2d to 3d and do both at the same time.
$$
\overrightarrow x(\theta)=r(\theta)\cdot\cos(\theta)\cdot\overrightarrow v_1+r(\theta)\cdot\sin(\theta)\cdot\overrightarrow v_2
$$
where $\overrightarrow v_{1,2}$ would be two orthogonal 3d unit vectors spanning your orbital plane. They would represent the axes of your 2d coordinate system in terms of 3d coordinates. A third vector $\overrightarrow v_3$ orthogonal to both of these would make that coordinate system (or vector space basis) complete but won't be needed for orbital positions.
Depending on how your orbits are given (i.e. which orbital elements) different methods would be used to compute the basis vectors of the coordinate system for a specific celestial body as well as the details of the parametric equations. For example you might pick $\theta=0$ to represent the perihelion position. That would make the polar formula symmetric and thus a bit easier, and for 3d it's typically as good a choice as any.
Keep in mind with the parametric description using angle that bodies on elliptical and not circular orbits don't cover equal angle in equal time. So an animation with constant change of angle would not correctly represent physical speed.
