How to calculate the distance between two points on a circle in degrees [closed]

$\begingroup$

I've been trying to figure this out for several hours now and am having trouble finding the right solution.

Given two points on a circle and the radius of the circle I need to calculate the distance in degrees between the two points on the circle. Here's a picture of what I'm trying to do.

enter image description here

In this picture I have a point at (-12.2,12.7) which represents the center of the circle. I know the radius of the circle (5.344) and I have two points on the circle. One at (-12.4,7.4) and another at (-17, 13.7). I need to get the length of the arc in degrees. I know if I have the center angle I can calculate the arc length, but I can't find anything about how to determine the center angle without already knowing the arc length.

Any help much appreciated.

EDIT

Updating the image to use real values

$\endgroup$ 10

3 Answers

$\begingroup$

If the included angle is $\theta$ and the radius is $r$ then $$ s= r \theta$$

To find the included angle $\theta$ subtract the two orientation angles you get from an $\arctan(y/x)$ operation

$$ \theta = \arctan\left( \frac{y_2}{x_2} \right) -\arctan\left( \frac{y_1}{x_1} \right) $$

NOTES: You might need to use the ATAN2(dy,dx) function to resolve angles in all the quadrants

$\endgroup$ 2 $\begingroup$

The diagram showing the center at $(0,0)$ is inconsistent with the other points in the diagram, and with the stated form of the problem. So:

Edit: The edited question confirms the assumptions of this solution.

Given two points on a circle and the radius $R$, first calculate the distance $D$ between the two given points, the chord between the two points:$$D=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2} $$

Half this length, $\frac D2$, along with the radius form one side and the hypotenuse of a right-angle triangle. So, the angle at the centre, $\theta$ subtended by the entire chord, is given by:$$\theta=2\times \arcsin \left(\frac{D}{2R} \right)$$

A slightly more complex method is to use the Law of Cosines. With $R$ given, and $D$ calculated:$$\cos({\theta)}=\frac{R^2+R^2-D^2}{2R^2}$$

$\endgroup$ 3 $\begingroup$

Updated to take into account your change of question

(Actually - ignoring your diagram and using my own)

enter image description here

Applying dot product of the two vectors you get:

$$\cos\theta=\frac{(x_1-x_c)(x_2-x_c)+(y_1-y_c)(y_2-y_c)}{\sqrt{(x_1-x_c)^2+(y_1-y_c)^2}\times\sqrt{(x_2-x_c)^2+(y_2-y_c)^2}}$$

so that

$$\theta=\cos^{-1}\left(\frac{(x_1-x_c)(x_2-x_c)+(y_1-y_c)(y_2-y_c)}{\sqrt{(x_1-x_c)^2+(y_1-y_c)^2}\times\sqrt{(x_2-x_c)^2+(y_2-y_c)^2}}\right)$$

Note: The bottoms of these fraction is just the radius times radius of your circle. However your shapes so far have not been circles so this is a general formula that will give you the angle between any two random points compared to a center point.

$\endgroup$ 7

You Might Also Like