Given a circle with center $(a,b)$ and radius $r$, oriented counter-clockwise, and two points that sit along the circle, $(x_1,y_1)$ and $(x_2,y_2)$, what the is the great circle distance (GCD) between them.

I have something like

$\theta_1=\arccos\left(\frac{x_1-a}{\sqrt{(x_1-a)^2+(y_1-b)^2}}\right)$ and $\theta_2=\arccos\left(\frac{x_2-a}{\sqrt{(x_2-a)^2+(y_2-b)^2}}\right)$

$\theta^* = \theta_1-\theta_2$

$GCD=r \theta^*$

This is assuming that $(x_1,y_1)$ comes before $(x_2,y_2)$ along the circle (in the given orientation). However, this formulation is incorrect. It does not take into account that the range of arccosine is $0 \leq \theta \leq \pi$, and I'm not even sure if I'm orienting my angle properly. As a matter of fact, please include if you have a way to test which point comes first in the orientation.

For example, can you handle the following case for me: Say you have $(2,3)$ and $(4,5)$ sitting on a circle with center $(3,4)$. What is the central angle between them?


Translate your circle to the origin. The coordinates of $(x_{i},y_{i})$ become $(x_{i}-a,y_{i}-b)$ for $i=1,2$.

You know that if $X_{1}$ and $X_{2}$ are two vectors of the euclidean space $\mathbb{R}^{2}$, the angle $\theta$ formed by $X_{1}$ and $X_{2}$ is obtained as follows (see the remark at the bottom of this answer):

$$\langle X_{1},X_{2}\rangle=\Vert X_{1}\Vert\cdot\Vert X_{2}\Vert\cdot\cos(\theta)$$

where $\langle\cdot\,,\,\cdot\rangle$ denotes the scalar product and $\Vert\cdot\Vert$ the norm derived from this scalar product.

It gives:


And you have to solve the previous equation. As you look for the GCD, take the greatest value for $\theta$.

enter image description here

Here, you have $(2-3,3-4)=(-1,-1)$, whose norm is $\sqrt{2}$ and $(4-3,5-4)=(1,1)$, whose norm is $\sqrt{2}$. For this points, it is easy to know what is $\theta$ because they are symmetric with respect to the origin, but let's try the previous "method".

$$\langle(-1,1),(1,1)\rangle=-1\cdot 1+(-1)\cdot 1=-2=\sqrt{2}\sqrt{2}\cos(\theta)$$

so that $\cos(\theta)=-1$, which means $\theta=\pi+2k\pi$ ($k\in\mathbb{Z}$) and here we only consider $\theta\in]0,2\pi[$, so that $\theta = \pi$. Note that I take $\theta$ in the open interval $]0,2\pi[$ because $\theta=2k\pi$ only if $X_{1}=X_{2}$ but the GCD is not well defined in this case, as far as I know.

Of course, there are often two possible values lying in $]0,2\pi[$ for $\theta$. Take the bigger one as you look for the GCD.

Suppose you want to test whether $X_{1}$ or $X_{2}$ "comes first" when running along the circle counter-clockwise. Let $X_{i}=(x_{i}-a,y_{i}-b)$ ($i=1,2$) Take a look at

$$\frac{X_{i}}{\Vert X_{i}\Vert}=\frac{X_{i}}{r} \tag{$i=1,2$}$$

It lies on a circle of radius $1$ and center $(0,0)$. It can be considered as the trigonometric circle. Then, the abscissa of $\frac{X_{i}}{r}$ is $\cos(\alpha)$ and its ordinate is $\sin(\alpha)$ or equivalently $X_{i}=(r\cos(\alpha),r\sin(\alpha))$. Solve for $\alpha\in[0,2\pi]$, which is the angle as considered in the following representation:


Calculate the angle for $X_{2}$. The one with the smallest angle is "the first".

Remark: in general, the angle $\theta$ formed by two vectors is considered (by convention) as the "smallest one". Here, we are interested in $2\pi-\text{ the smallest one }$

  • $\begingroup$ Great answer @MoebiusCorzer! I was adding a slight edit as you posted your comment though: Do you have a way to test whether $(x_1,y_1)$ or $(x_2,y_2)$ comes first in the orientation? Thanks! $\endgroup$ – nycguy92 Nov 23 '15 at 15:35
  • $\begingroup$ @nycguy92 I edited it accordingly :) $\endgroup$ – MoebiusCorzer Nov 23 '15 at 15:53
  • $\begingroup$ As I look over your comment, @MoebiusCorzer, you say "take the bigger angle." However, arccosine will only output $\theta \in (0, \pi)$. So there is no bigger angle to take, in some sense. How can you use your formulation to get an obtuse angle? $\endgroup$ – nycguy92 Nov 23 '15 at 16:10
  • $\begingroup$ There is no use of $\arccos$, which is a function. You need to solve equation like $r\cos(\alpha)=x_{1}-a$ along with $r\sin(\alpha)=y_{1}-b$ and it has no particular link with $\arccos$ a priori. When you solve $\cos(a)=\sqrt{2}/2$, the solutions for $a$ are $\pi/4+2k\pi$ and $-\pi/4+2k\pi$, there is no $\arccos$. Of course, in a calculator, you'll use $\arccos$ but you need to consider all possibilities by adding other solutions accordingly. $\endgroup$ – MoebiusCorzer Nov 23 '15 at 16:13
  • $\begingroup$ You use arccosine in what you labeled $(1)$. Then you say, "And you have to solve the previous equation. As you look for the GCD, take the greatest value for $\theta$." That's the arccosine to which I refer. Thanks @MoebiusCorzer. $\endgroup$ – nycguy92 Nov 23 '15 at 16:15

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.