3D rotation of an ellipse Let’s say we want to represent an ellipse in the three-dimensional space. If it’s centered at the origin and in the $(x, y)$ plane, then its equation is obviously
$$\frac{x^2}{a^2}+\frac{y^2}{b^2}+z=1$$
where $z$ would be zero if it’s on the $(x, y)$ plane and any real number if it’s parallel to the $(x, y)$ plane.
Now, let’s rotate and move our ellipse on the $(x, y)$ plane or parallel to it, by $(X, Y)$ and angle $\theta$. (This is equivalent to a rotation around the $z$ axis.) We thus have:
$$\frac{(x - x _{0}) \cos \theta + (y - y_0) \sin \theta}{a^2} + \frac{(x - x _0) \sin \theta + (y - y_0) \cos \theta}{b^2} + z = 1$$
But what if our ellipse is also rotated around the $x$ axis or around the $y$ axis? Or even around both of these axes. Let’s call these angles $\phi$ (rotation around the $x$ axis) and $\xi$ (rotation around the $y$ axis).
What would we get? My math skills fail me at that point, so I would appreciate any help possible.
 A: An ellipse in 3D space cannot be described with a single cartesian equation: your equation is in fact that of a surface (an elliptic paraboloid).
To describe a curve in space it's better to use a parametric representation. In your case, for instance, you can start from the polar equation of an ellipse, with its center at a focus:
$$
r(\theta)={a(1-e^2)\over1+e\cos\theta}.
$$
Then you should find from your data a unit vector $\hat {\mathbf x}$ directed from a focus (primary star) to the periastron, a unit vector $\hat {\mathbf n}$ perpendicular to the plane of the ellipse, and a unit vector $\hat {\mathbf y}=\hat {\mathbf n}\times\hat {\mathbf x}$ perpendicular to the other two. You can then write a parametric equation for the ellipse:
$$
\vec {\mathbf r}=r(\theta)\cos\theta\ \hat {\mathbf x}+
r(\theta)\sin\theta\ \hat {\mathbf y}.
$$
EDIT.
If one really wants a cartesian equation, then an ellipse can be described by two equations. For instance, the ellipse in the $xy$ plane whose 2D equation is
$$
\tag{1}
{x^2\over a^2}+{y^2\over b^2}=1
$$
is described in 3D by that same equation (which in space is the equation of an elliptic cylinder) and by the equation of the plane onto which the ellipse lies, that is:
$$
\tag{2}
z=0.
$$
We want now to find the equation of the same ellipse after these rotations are applied:

*

*first, a rotation  by an angle $\theta$ about $z$ axis;


*then a rotation  by an angle $\phi$ about $x$ axis;


*finally a rotation  by an angle $\xi$ about $y$ axis.
(Note that changing the order of the rotations will change the result: I'm sticking to the order the OP confirmed in a comment below).
To find the equation after these rotations, we just need to replace
$\pmatrix{x\\ y\\ z}$ in the equations with
$$
R_z(-\theta)R_x(-\phi)R_y(-\xi)\pmatrix{x\\ y\\ z},
$$
where $R_z(\theta)$ is the rotation matrix about $z$ axis by angle $\theta$, and so on.
I used Mathematica to make these tedious computations. Here is the transformed of equation $(1)$ after these rotations:
$$
\tag{$1'$}
\frac{1}{4} \sin ^2\theta \left(\left(2 a^2-b^2\right) (\cos2\xi (x-z) (x+z)
-2 x z \sin2\xi)+2 a^2 \left(x^2+z^2\right)+b^2\left(x^2+2 y^2+z^2\right)
+2 b^2 \cos2\phi (-x \sin\xi +y-z \cos\xi) (x \sin\xi +y+z \cos\xi)
+4 b^2 y \sin 2 \phi (x \sin\xi +z \cos\xi )\right)
\\
+\cos ^2\theta  \left(\cos ^2\xi\left(a^2 z^2 \sin ^2\phi+b^2 x^2\right)
+z \cos\xi \left(a^2 y\sin2\phi-2 x\sin\xi\left(b^2-a^2 \sin ^2\phi\right)\right)
\\
+a^2 (x \sin\xi  \sin\phi +y \cos\phi )^2+b^2 z^2 \sin ^2\xi\right)
\\
-(a^2-b^2)\sin2\theta (x \cos\xi -z\sin\xi ) 
(\sin \phi (x  \sin \xi +z \cos\xi )+y \cos\phi)=a^2 b^2;
$$
and the transformed of equation $(2)$:
$$
\tag{$2'$}
x \sin\xi \cos\phi -y \sin\phi +z \cos\xi\cos\phi = 0.
$$
The rotated ellipse is then described by eqs. $(1')$ and $(2')$.
Finally, to have an ellipse centred at $(x_0,y_0,z_0)$, substitute everywere in the above formulas $x$ with $x-x_0$, $y$ with $y-y_0$ and $z$ with $z-z_0$.
