# Finding the point on a rotated ellipse corresponding to a given tangential angle

I was going to initially ask for the solution to this problem here, but I have come upon a solution by some hand derivation and wanted to verify it here. Please note that after high-school I have had no formal training in mathematics so the proof is not rigorous and sort of umbral, since I'm just feeling my way through to what the truth should be.

So since I'm supposed to ask a question on this forum, here goes: How is the following derivation of a formula valid? I will draw your attention to the specific part of the derivation I am doubtful about. An alternate question would be: is there a more proper rigorous derivation for the following solution:

Problem: Given an ellipse centered at the origin with major radius $a$ and minor radius $b$ and (whose major axis is) rotated w.r.t. the X axis by an angle of $\alpha$, find the point on the ellipse where the tangential angle is $\psi$.

Solution:

First rotate the ellipse by $-\alpha$ to simplify things. At the end, we can just rotate the point back by $\alpha$ and it will be OK. Now the required tangential angle will also be $\psi - \alpha = \phi$ (say).

The parametric form of the unrotated ellipse centered at the origin is $x = a \cos t$ and $y = b \sin t$. If we find out the parameter $t$ corresponding to the tangential angle $\phi$ we can calculate $x$ and $y$.

Now from the parametric form:

$$x = a \cos t ; y = b \sin t$$

Differentiating to find the velocity (tangent) vector:

$${ dx \over dt } = -a \sin t ; { dy \over dt } = b \cos t$$

The angle $\phi$ the above vector subtends with the positive x axis is:

$$\phi = atan2 ( b \cos t, -a \sin t )$$

where $atan2$ is the computer-style function with appropriate quadrant detection, and which takes the y part first.

Now the above implies:

$${{ b \cos t } \over { -a \sin t }} = \tan \phi$$

$$\Rightarrow {b\over{-a}} \cot t = \tan \phi$$

$$\Rightarrow {b\over{-a}} \tan ( { \pi \over 2 } - t ) = \tan \phi$$

$$\Rightarrow \tan ( { \pi \over 2 } - t ) = {{-a}\over b} \tan \phi$$

$$\Rightarrow { \pi \over 2 } - t = atan2 ( -a \sin \phi, b \cos \phi )$$

$$\Rightarrow t = { \pi \over 2 } - atan2 ( -a \sin \phi, b \cos \phi )$$

However, using this formula in my program (OK that's where it's going finally but this is really about the formula) I found that I had to move that $-$ from the y part to the x part otherwise my calculation was off by $180^\circ$ and this is what I am seriously having doubts about:

$$\Rightarrow t = { \pi \over 2 } - atan2 ( a \sin \phi, -b \cos \phi )$$

So substituting this $t$ value, one can get the point from the generic parametric equation by additionally rotating back by $\alpha$:

$$x = a \cos t \cos \alpha - b \sin t \sin \alpha ; y = a \cos t \sin \alpha + b \sin t \cos \alpha$$

So again the question: how does the above solution work, or what is a better more proper rigorous derivation of a solution to the problem?

I should also note that http://mathworld.wolfram.com/Ellipse.html eqn 60 gives the relation between $phi$ and $t$ as:

$$\phi = \tan ^{-1} ( {a \over b} \tan t )$$

which however means:

$$\tan \phi = {a \over b} \tan t$$

$$\Rightarrow {b \over a} \tan \phi = \tan t$$

$$\Rightarrow t = \tan ^{-1} ( {b \over a} \tan \phi ) = atan2 ( b \sin \phi, a \cos \phi )$$

which does not tally with my above result and does not work correctly if I use in my program. Please help. Thank you!

-

# What I'd do

I read up to $\phi=\psi-\alpha$ and agree with that. I'm spinning my own thoughts from that point on. For the moment I'd like to think of your tangent direction not as an angle but as a direction vector instead, namely the vector

$$v_1 = \begin{pmatrix} \cos\phi \\ \sin\phi \end{pmatrix}$$

Now you can take your whole scene and scale all $x$ coordinates by $a$ and all $y$ coordinates by $b$. This will turn your ellipsis into a unit circle, and the tangent direction will become

$$v_2 = \begin{pmatrix} \frac{\cos\phi}a \\ \frac{\sin\phi}b \end{pmatrix}$$

Now you're looking for the point on the unit circle with this tangent. This is particularly easy, since tangents to the unit circle are perpendicular to radii. Simply take your vector, swap $x$ and $y$ coordinate and also swap one sign. That will result in a perpendicular vector

$$v_3 = \begin{pmatrix} \frac{\sin\phi}b \\ -\frac{\cos\phi}a \end{pmatrix}$$

Now you have to change the length of that vector to $1$ so you get a point on the unit circle.

$$v_4 = \frac{v_3}{\lVert v_3\rVert} = \frac{1}{\sqrt{\left(\frac{\sin\phi}b\right)^2 + \left(\frac{\cos\phi}a\right)^2}} \begin{pmatrix} \frac{\sin\phi}b \\ -\frac{\cos\phi}a \end{pmatrix} = \begin{pmatrix} x_4 \\ y_4 \end{pmatrix}$$

Note that at this point, the opposite point $-v_4$ is a second valid solution. Now you can scale your coordinates back by $a$ and $b$ and end up with

$$v_5 = \begin{pmatrix} a\cdot x_4 \\ b\cdot y_4 \end{pmatrix}$$

Last you'd apply the rotation by $\alpha$ to that (and possibly $-v_5$ as well).

# What you did

So now that I've thought about how I'd think about this, I'll have a look at the rest of what you did. It seems that your computations look a lot shorter than mine, so they might be more efficient for practical uses. Nevertheless, my approach might yield some insight as to what the individual steps do, so I'll leave it in place and even refer to it.

I found that I had to move that $−$ from the $y$ part to the $x$ part otherwise my calculation was off by $180°$

If your tangents are unoriented lines, then a change in $180°$ in that argument will give an equally valid result. This is the $v_4$/$-v_4$ ambiguity in my solution. The “velocity vector” you used is oriented, pointing in a given direction, but if you move along your circle in the opposite direction, you'd get opposite velocities at the same points.

So again the question: how does the above solution work, or what is a better more proper rigorous derivation of a solution to the problem?

Your solution looks good. You might want to consider $t$ and $t+180°$, and if you do, then it shouldn't matter where you place your minus sign. If you still have doubts, however, feel free to implement my approach as an alternative and compare the results. They should agree.

I should also note that http://mathworld.wolfram.com/Ellipse.html eqn 60 gives the relation between $\phi$ and $t$ as […]

Their $\phi$ is the “polar angle” of a point on the ellipsis. Look at the line connecting the center of the ellipsis with a given point on the ellipsis. The angle that line makes with the $x$ axis is their $\phi$.

-

I tested your method and it did work correctly. In fact, it would be computationally faster than my method as it only involves a $sqrt$ whereas mine involves an $atan2$ and then a $\sin$ and $\cos$. So thank you very much and I accepted your answer!

For comparison (and anyone else's benefit) here's the Asymptote code:

pair jamadagniMethod ( real a, real b, real alpha, real psi )
{
real phi = psi - alpha ;
real t = atan2 ( -b * Cos(phi), a * Sin(phi) ) ;
return rotate ( alpha ) * ( a * cos(t), b * sin(t) ) ;
}

pair mvgMethod ( real a, real b, real alpha, real psi )
{
real phi = psi - alpha ;
pair u = unit ( (Sin(phi) / b, -Cos(phi) / a) ) ;
return rotate ( alpha ) * scale ( a, b ) * u ;
}


(Note that in Asymptote, Sin and Cos with capital S and C take their arguments in degrees.)

You mention swapping $x$ and $y$ and changing one sign. To be more precise, the sign of $y$ i.e. the new $y$ which is the old $x$, must be changed. This is actually complex multiplication by $-i$ which has the effect of rotating clockwise 90°. For instance $(2,3) \times -i = (3,-2)$.

Also, note that MathWorld clearly says that their $\phi$ is the tangential angle. They denote the polar angle by $\theta$. And I am suspecting that in the formula 60 they actually meant to write ${ a \over b \tan t}$ rather than ${a \over b} \tan t$ since the latter is simply wrong and would not work out. Notice for instance that at $t = 0$ for an unrotated ellipse which they are considering, the tangential angle should be $\pi \over 2$ but ${a \over b} \tan t$ would evaluate to zero and the arctan would then also be zero. I just sent them a message asking them to correct this (wow I found an error in MathWorld!). Wikipedia quotes them on this, but I'll have to change that, except that the formulae there also involve $e$ and $g$ so I'll have to do it carefully.

But I still couldn't rest without figuring out how my earlier umbral logic works. The arbitrary switching of signs I did also didn't please me. So I sat and thought and got this more logical derivation.

Considering the parameteric form of the unrotated ellipse:

$$x = a \cos t ; \\ y = b \sin t$$

Differentiating, we get the velocity/tangent vector $v$ as:

$${ dx \over dt } = -a \sin t ; \\ { dy \over dt } = b \cos t$$

The unit tangent vector is then $\frac {v}{\lVert v \rVert}$ i.e.

$$\left ( \frac{-a \sin t}{v_{mag}}, \frac{b \cos t}{v_{mag}} \right )$$

where $v_{mag} = {\lVert v \rVert}$. But if $\phi$ is the tangential angle then the unit tangent vector is also $(\cos \phi, \sin \phi)$, so:

$$\Rightarrow \cos \phi = \frac {-a \sin t } {v_{mag}} ; \\ \sin \phi = \frac{b \cos t}{v_{mag}} \\ \Rightarrow \sin t = \frac {v_{mag}\cos \phi}{-a} ; \\ \cos t = \frac{v_{mag}\sin \phi}{b} \\ \Rightarrow \tan t = \frac { \left ( \frac {v_{mag}\cos \phi}{-a} \right ) } {\left ( \frac{v_{mag}\sin \phi}{b} \right ) }$$

Now we are going to call $atan2$ but before than we cancel $v_{mag}$ from the numerator and denominator and exchange the denominators within the numerator and denominator (since they are all positive -- remember we need to maintain the sign of the numerator and denominator for $atan2$).

$$\Rightarrow t = atan2 ( -b \cos \phi, a \sin \phi)$$

Now this is equivalent to the formula I had earlier postulated:

$$t = { \pi \over 2 } - atan2(a \sin \phi, -b \cos \phi)$$

because if $\theta = atan2(y,x)$, we have

$$\Rightarrow \tan \theta = y/x \\ \Rightarrow \cot \theta = x/y \\ \Rightarrow \tan ( \frac{\pi}{2} - \theta ) = x/y \\ \Rightarrow \frac{\pi}{2} - \theta = atan2(x,y) \\ \Rightarrow \theta = \frac{\pi}{2} - atan2(x,y)$$

Whew! I wish I could have thought of the simpler solution first. Kudos to MvG!

A final note: the parameter $t$ of a point $p$ on the ellipse seems to be nothing but the polar angle on the unit circle of the point $p^\prime$ which corresponds to $p$ by the scaling factor of the ellipse i.e. $(a,b)$. Note that $p = (a \cos t, b \sin t) ; \ p^\prime = (\cos t, \sin t)$.

-