[Math] How to calculate clock-wise and anti-clockwise arc lengths between two points on a circle

circlestrigonometry

I have two points with known coordinates on a circle of known position and radius. I need to calculate two things:

  1. The clockwise arc length between the two points on the circle
  2. The anti-clockwise arc length between the two points on the circle

How would I go about doing this? Note this is 2D.

Best Answer

You already have one good answer, but here are some pointers to a more pedestrian method easily accessible to a student of trigonometry.

Given the Cartesian coordinates $(x_0,y_0)$ of the center of a circle in a Cartesian plane, and the coordinates $(x_1,y_1)$ and $(x_2,y_2)$ of two points on that circle, you first want to find the direction from the circle's center to each point.

In many computer programming environments you can do this with an atan2 function; as already explained in an answer to another question, the formula for the first of the points is

$$ \theta_1 = \mbox{atan2}(y_1 - y_0, x_1 - x_0).$$

Alternatively, using more traditional trigonometry you can write

$$ \theta_1 = \begin{cases} \tan^{-1} \left(\frac{y_1 - y_0}{x_1 - x_0}\right) & \mbox{if } x_1 - x_0 > 0, \\ \tan^{-1} \left(\frac{y_1 - y_0}{x_1 - x_0}\right) + \pi & \mbox{if } x_1 - x_0 < 0, \\ \frac\pi2 & \mbox{if } x_1 - x_0 = 0 \mbox{ and } y_1 - y_0 > 0, \\ -\frac\pi2 & \mbox{if } x_1 - x_0 = 0 \mbox{ and } y_1 - y_0 < 0, \\ \end{cases} $$

The reason this is so complicated is that $\tan^{-1}$ gives answers only in the range $(-\frac\pi2, \frac\pi2),$ which gives you the directions to points only on a semicircle, not the whole circle, so we need to do something to get the points on the other semicircle; and of course we cannot do anything at all with $\frac{y_1 - y_0}{x_1 - x_0}$ when the denominator of that ratio would be zero.

Either of these methods gives you an angle measured in the anti-clockwise sense from the direction of the positive $x$-axis to the direction from $(x_0,y_0)$ to $(x_1,y_1)$.

Once you have such angles for both points, $\theta_1$ and $\theta_2$, subtract the angle of the point you are coming from from the angle of the point you are going to, and this will give you the angle of the anti-clockwise arc from one point to the other ...

... with one small hitch, which is that the answer should be in the range $[0, 2\pi)$ since you don't need to go around the circle more than once to reach the desired point, but subtracting two angles from either of the methods above will not always be in that range.

So after computing the difference of the angles, $\theta$, if you don't have $0 \leq \theta < 2\pi$ you "normalize" the angle by adding or subtracting a whole multiple of $2\pi$ to get a result $\theta'$ that is in the range $[0, 2\pi)$.

Once you have a normalized angle $\theta'$ (measured in radians, of course!), the anti-clockwise arc length is $\theta' r$,

To get the clockwise arc length, subtract the anti-clockwise arc from $2\pi r.$