# Finding the angle around an ellipse

Jan. 29, 2014

When is the angle around an ellipse, not the around around the an ellipse? This is a problem which tripped me up a few times when working with elliptical orbits and arcs.

## The problem

This problem arises when we use a parametric equation for an ellipse, defining the point on an ellipse as a function of $\theta$ with these two equations.

$x = a \cdot cos(\theta) \\ y = b \cdot sin(\theta)$

Where $a$ is the length of the axis aligned with the x-axis and $b$ is the length of the axis aligned with the y-axis (I'm assuming the ellipse is oriented along the axes).

## The mistake

The temptation is to assume that $\theta$ represents the angle around the ellipse, which it does if your ellipse is a circle, or when $\theta = \{0, \frac{\pi}{2}, \pi, \frac{3\pi}{2}\}$. However, in most circumstances $\theta$ does not represent an angle.

The question then is how to find the angle $\phi$, around the ellipse to point (x, y).

## The solution

The hardest part of the problem is to realise that there is a problem. After that, it's basic trigonometry to find the solution.

\qquad\begin{align} tan(\phi) &= \frac{y}{x} \\ tan(\phi) &= \frac{b \cdot sin(\theta)}{a \cdot cos(\theta)} \\ tan(\phi) &= \frac{b}{a} \cdot tan(\theta) \\ \phi &= atan \left(\frac{b}{a} \cdot tan(\theta)\right) \end{align}

Likewise, you can calculate the inverse with:

$\qquad\theta = atan \left(\frac{a}{b} \cdot tan(\phi)\right)$

This is particularly useful for generating arcs in Processing.js where $\theta$ is used in the calculation for the angles to start and stop.

If you want to find a point on the ellipse which aligns with another point (px, py), and the origin (say placing a planet on an elliptic orbit based on a mouse click), it's even easier.

$\qquad\theta = atan \left(\frac{a \cdot py}{b \cdot px} \right)$

The hardest part of all this was realising that the parametric "angle" I was using to define an elliptic arc was not the angle I expected or really any sort of angle at all.

#### Philip on Jan. 23, 2018, 11:07 p.m.

Hi! Thanks for the hint : ) ) I spent 30 minutes trying to understand why by using theta angle I couldn't find the right dot on the ellipse, I knew I was doing something wrong .. and after googling I immediately found your post and solved the problem immidiately.. Thank you for sharing in your blog!

#### Wade on May 16, 2018, 8:16 p.m.

Can this help to impose the initial nodal points such that the equal arclength between two points on ellipse? If yes, then Given the arclength how to compute the corresponding angle?