# Arc length of ellipse in different quadrants

This question is basically a follow-up or generalization of How to determine the arc length of ellipse?
Given an ellipse with axes a and b, and the start and end angles $$\theta_{start}$$ and $$\theta_{end}$$ of an arc, find the length of the arc.

I can follow the accepted answer on that question, but the solution it gives for finding the integration limits

$$t=\arctan \left( \frac{a}{b}\tan \theta \right)$$

only works when the arc is contained in the first (top-right) quadrant. When the angles are in other quadrants I end up with negative values for t. I'm at a loss what I need to change to correctly handle angles in other quadrants.

• The ellipse is symmetric in the quadrants. Can you use that? – coffeemath Jan 11 '20 at 20:34
• @coffeemath I'm assuming I need to do something similar to math.stackexchange.com/a/22068/741141; flip the sign based on the quadrant. I'm just not sure what to flip the sign of - I thought maybe $tan\theta$, but that doesn't seem to work. – BenV Jan 11 '20 at 21:07
• @coffeemath You even addressed it in a comment on the answer I linked to: first we need to worry about a/btanθ which may need to be adjusted according to quadrant... – BenV Jan 11 '20 at 21:10
• $t=\arctan\left(\frac{a}{b}\tan\theta\right)$ is not the length of the arc! It is the value of the parameter $t$ in the parametric equation for the ellipse for a given $\theta$. The arc length has no simple expression, and must be computed numerically. – TonyK Jan 12 '20 at 11:53
• @TonyK Yes I'm aware, I probably didn't do a good job of contextualizing my question. The linked question/answer has the full formula; my question is just about calculating the beginning and ending t values. – BenV Jan 12 '20 at 20:33

Once the Cartesian coordinates of the point in question have been calculated:

$$(x_p,\,y_p) = \frac{a\,b}{\sqrt{\left(a\,\sin\theta\right)^2 + \left(b\,\cos\theta\right)^2}} \,\left(\cos\theta, \, \sin\theta\right)$$

with $$a, \, b > 0, \, 0 \le \theta < 2\pi$$ known parameters, essentially two cases can arise.

You are interested in an angle $$t \in (-\pi,\,\pi]$$:

$$t = \text{arctan2}\left(x_p/a, \, y_p/b\right)$$

i.e.

$$t = \begin{cases} \arctan\left(\frac{y_p/b}{x_p/a}\right) - \pi & \text{if} \; x_p < 0 \, \land \, y_p < 0 \\ \arctan\left(\frac{y_p/b}{x_p/a}\right) + \pi & \text{if} \; x_p < 0 \, \land \, y_p \ge 0 \\ -\frac{\pi}{2} & \text{if} \; x_p = 0 \, \land \, y_p < 0 \\ \frac{\pi}{2} & \text{if} \; x_p = 0 \, \land \, y_p > 0 \\ \arctan\left(\frac{y_p/b}{x_p/a}\right) & \text{if} \; x_p > 0 \end{cases}$$

{a, b} = {6, 2};

x[θ_] := a b Cos[θ] / Sqrt[(a Sin[θ])^2 + (b Cos[θ])^2]
y[θ_] := a b Sin[θ] / Sqrt[(a Sin[θ])^2 + (b Cos[θ])^2]

Plot[ArcTan[x[θ] / a, y[θ] / b], {θ, 0, 2π}, AxesLabel -> {"θ", "t(θ)"}]


therefore, known the integration extremes $$t_1 \le t_2$$, the length of the ellipse arc is equal to:

• if the arc does not cut the negative semi-axis of x: $$\mathcal{L} = \int_{t_1}^{t_2} \sqrt{\left(a\,\sin t\right)^2+\left(b\,\cos t\right)^2}\,\text{d}t \,;$$

• if the arc cuts the negative half-axis of x: $$\mathcal{L} = \int_{-\pi}^{t_1} \sqrt{\left(a\,\sin t\right)^2+\left(b\,\cos t\right)^2}\,\text{d}t + \int_{t_2}^{\pi} \sqrt{\left(a\,\sin t\right)^2+\left(b\,\cos t\right)^2}\,\text{d}t \,.$$

You are interested in an angle $$t \in [0,\,2\pi)$$:

$$t = \begin{cases} \text{arctan2}\left(x_p/a, \, y_p/b\right) + 2\pi & \text{if} \; \text{arctan2}\left(x_p/a, \, y_p/b\right) < 0 \\ \text{arctan2}\left(x_p/a, \, y_p/b\right) & \text{if} \; \text{arctan2}\left(x_p/a, \, y_p/b\right) \ge 0 \\ \end{cases}$$

i.e.

$$t = \begin{cases} \arctan\left(\frac{y_p/b}{x_p/a}\right) + \pi & \text{if} \; x_p < 0 \\ \frac{3\pi}{2} & \text{if} \; x_p = 0 \, \land \, y_p < 0 \\ \frac{\pi}{2} & \text{if} \; x_p = 0 \, \land \, y_p > 0 \\ \arctan\left(\frac{y_p/b}{x_p/a}\right) + 2\pi & \text{if} \; x_p > 0 \, \land \, y_p < 0 \\ \arctan\left(\frac{y_p/b}{x_p/a}\right) & \text{if} \; x_p > 0 \, \land \, y_p \ge 0 \end{cases}$$

{a, b} = {6, 2};

x[θ_] := a b Cos[θ] / Sqrt[(a Sin[θ])^2 + (b Cos[θ])^2]
y[θ_] := a b Sin[θ] / Sqrt[(a Sin[θ])^2 + (b Cos[θ])^2]

t[x_, y_] := Piecewise[{{ArcTan[x, y] + 2π, ArcTan[x, y] < 0},
{ArcTan[x, y], True}}]

Plot[t[x[θ] / a, y[θ] / b], {θ, 0, 2π}, AxesLabel -> {"θ", "t(θ)"}]


therefore, known the integration extremes $$t_1 \le t_2$$, the length of the ellipse arc is equal to:

• if the arc does not cut the positive semi-axis of x: $$\mathcal{L} = \int_{t_1}^{t_2} \sqrt{\left(a\,\sin t\right)^2+\left(b\,\cos t\right)^2}\,\text{d}t \,;$$

• if the arc cuts the positive half-axis of x: $$\mathcal{L} = \int_{0}^{t_1} \sqrt{\left(a\,\sin t\right)^2+\left(b\,\cos t\right)^2}\,\text{d}t + \int_{t_2}^{2\pi} \sqrt{\left(a\,\sin t\right)^2+\left(b\,\cos t\right)^2}\,\text{d}t \,.$$

• Hmm, I had started down this path but felt like it should be simpler to find t using θ. I'll take another look at this. – BenV Jan 12 '20 at 1:07
• I was able to get this to work. When the arc crosses the origin I had to integrate from $t_1$ to $2\pi$ and then from 0 to $t_2$. – BenV Jan 12 '20 at 2:43