3
$\begingroup$

What's the parametric equation for the general form of an ellipse rotated by any amount?

Preferably, as a computer scientist, how can this equation be derived from the three variables: coordinate of the center/two foci and eccentricity of an ellipse?

I need to generate completely random eclipses within certain bounds. The variables I described above are most convenient. This is for a personal project of mine and I can't find anybody who can help me.

$\endgroup$

1 Answer 1

6
$\begingroup$

For a given center $(h,k)$, semimajor and semiminor axes length $a$ and $b$ respectively, and rotation angle $\varphi$ as measured counterclockwise about the positive $x$-axis, one parametrization of the ellipse is given by $$\begin{align*} x(\theta) &= a \cos \varphi \cos \theta + b \sin \varphi \sin \theta + h, \\ y(\theta) &= b \cos \varphi \sin \theta - a \sin \varphi \cos \theta + k, \end{align*}$$ for $\theta \in [0,2 \pi)$. Given the foci and eccentricity, the equations are more difficult to write because you would have to solve for the center, then solve for $a$ and $b$, then solve for $\varphi$. It can be done, but I suggest that you try to do it yourself first.


Suppose we are given the eccentricity $e$ and the distance between foci, which we will call $2c$, so that the distance from one focus to the center is $c$. Now we have the relationships $$c^2 + b^2 = a^2,$$ where $a > b > 0$, and $$e^2 = 1 - \frac{b^2}{a^2}.$$ Solving for $a^2$ and $b^2$ in terms of $c$ and $e$ easily yields $$a = c/e, \quad b = c \sqrt{e^{-2}-1}.$$ To obtain $c$ given the coordinates of the foci, suppose our foci are located at $(x_1, y_1), (x_2, y_2)$. Then $c = \frac{1}{2}\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2}$ via the distance formula, and the center is located at $$(h,k) = \left( \frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2} \right),$$ the midpoint of the line joining the foci. Now the remaining issue is to consider the tilt of the ellipse. This is easily addressed by computing the angle of the line joining the foci relative to the $x$-axis; i.e., $\varphi$ satisfies $$\tan \varphi = -\frac{y_2 - y_1}{x_2 - x_1},$$ for the choice of parametrization I provided above. Of course, if $x_2 - x_1 = 0$, then $\varphi = \frac{\pi}{2}$. In any other case, we can always find an appropriate $\varphi \in (-\pi/2, \pi/2)$ that satisfies the above.

The explicit parametrization given all of this information is $$\begin{align*} x(\theta) &= \frac{1}{2} \left( \frac{x_2 - x_1}{e} \cos \theta + (y_1 - y_2) \sqrt{e^{-2}-1} \sin \theta + (x_1 + x_2) \right), \\ y(\theta) &= \frac{1}{2} \left( \frac{y_2 - y_1}{e} \cos \theta + (x_2 - x_1) \sqrt{e^{-2} - 1} \sin \theta + (y_1 + y_2)\right). \end{align*}$$ Note that we must have $0 < e < 1$: if $e = 0$ and $(x_1, x_2) \ne (y_1, y_2)$, then the result is a "circle" with infinite radius. If $e = 1$, we get a degenerate line segment.

$\endgroup$
2
  • $\begingroup$ Oh, I see. What input to the equation controls the coordinates of the center of two foci, and the eccentricity of the ellipse? A bunch of grad students couldn't figure it out. Thanks. $\endgroup$
    – augbar94
    Sep 19, 2014 at 2:21
  • 1
    $\begingroup$ I should hope these are not graduate students in mathematics, because such a simple calculation ought to be well within the grasp of any competent mathematics undergraduate. $\endgroup$
    – heropup
    Sep 19, 2014 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.