I apologize my math skills are not that stellar. I am trying to find the angle that the arc is occupying. In my head the "central angle" seems to be wherever the chord is positioned. So if an arc is greater than 180 degrees the formula that i am using does not give me the correct angle. This is the formula that I am using currently.


This works fine for Arc1 image, but in Arc2 image, I need the opposite of the 114.11277472. So, the angle should be giving me 245.88723

A little bit more information.. The white line is the arc in question (angle needed)

The purple line is the chord

The green lines are from the center point to chord

The 3 pieces of data that are known in this equation are Start (X,Y), End (X,Y), and Radius. All other math is calulated

Arc 1

enter image description here


2 Answers 2


Presumably you also know the center of the circle. The problem is that with center, radius, start point, and end point, both of the two arcs are solutions to the problem "give me an arc from the start to the finish."

If you're willing to say that the arc should go counterclockwise from the start to the end, THEN you can solve the problem.

I'm going to assume you have a function $atan2(x, y)$ (defined for $(x, y) \ne (0, 0)$ with the property that if $t = atan2(x, y)$, then there's a positive number $c$ with $c \cos t = x$ and $c \sin t = y$. (i.e., an arrow in direction $t$, measured from the $x$-axis, will pass through the point $(x, y)$; let's further assume that atan2 produces values between $-\pi$ and $pi$ (or $-180$ to $180$ degrees).

To generator the arc, let's give names to things: $(cx, cy)$ for the center, $(sx, sy)$ for the start point, $(ex, ey)$ for the end. Then let

$$ u = atan2(sx-cc, sy-cy)\\ v = atan2(ex-cx ey - cy) $$ Now let $v' = v + 2\pi \cdot \text{ceiling}( \frac{v - u}{2 \pi})$.

Then an arc from angle $u$ to $v'$ will solve the problem. We can describe this by

$$ X(t) = (cx + \cos((1-t)u + tv), cy + \sin((1-t)u + tv)) $$ where $t$ ranges from $0$ to $1$.

  • $\begingroup$ Perfect. Thank you sir $\endgroup$
    – joeb
    Sep 20 at 14:11
  • $\begingroup$ This formula is not working out for me. I have added a predicate of the arc direction. So now I know Start, End, Radius, and Direction. How does that simplify the formula? $\endgroup$
    – joeb
    Sep 26 at 17:02
  • $\begingroup$ What programming languages do you know? Perhaps I can just write the solution in code. $\endgroup$ Sep 26 at 19:25
  • $\begingroup$ I know C#, Typescript, PHP. My formulas work mostly but as soon as I surpass 180 degrees on the tangent point, the arc angle takes the major angle not the minor angle. $\endgroup$
    – joeb
    Sep 26 at 20:13
  • $\begingroup$ See second answer that I wrote below. I know a bunch of languages, but of the three you know, I've only used C#, and that was about 10-15 years ago, so I've written in a kind of generic language. :) $\endgroup$ Sep 27 at 11:06

I'm so sorry. I didn't read your original question well enough. If I now understand it correctly, you want to know the smaller of the two angles defined by a center and two points on a circle. For instance, if the center is the origin $(0, 0)$ and one point is $(0, 1)$ and the other is $(-1, 0)$, the two angles are 90 degrees and 270 degrees, and you want $90$ degrees (or $\pi/2$ radians).

Let's call the center $(cx, cy)$, the first point $(px, py)$ and the second $(qx, qy)$.

let vx = px - cx; let vy = py - cy; 
let wx = qx - cx; let wy = qy - cy; 

let dotProd = vx * wx + vy * wy;
let vLen = sqrt(vx * vx + vy * vy);
let wLen = sqrt(wx * wx + wy * wy); 

let angle = Acos(dotProd / (vLen * wLen));

The idea is that $v$ represents an arrow (or "vector") pointing from the center to $P$, and $w$ is a vector from the center to $Q$. The cosine of the angle between two vectors is given by $$ \frac{v \cdot w} {\|v \| \|w \|} $$ where $\|v \|$ is the length of $v$ (computed using Pythagoras) and where $v \cdot w$ is the "dot product", computed by multiplying $x$-coordinates, multiplying $y$-coordinates, and summing up the result.

So my program above (in some generic imagined language) computes the dot products and the two lengths, does the division, and then takes the inverse-cosine. That produces a number between $0$ and $\pi$ in most languages. You probably need to multiply by $180/\pi$ to get a number from $0$ to $180$.

OK, leaving the material above, I'll now try to address the "I don't know the center" version of the question. First, a picture: [![Start and end points, and the two possible circle-centers they define][1]][1]

In this picture, $S$ and $E$ are the start and end of your arc. If we draw the segment between them, then draw the perpendicular bisector of that segment (the long vertical line), the circle center must lie somewhere on that bisector, so that it can have the same distance (the radius, $R$) to both $S$ and $E$. But as I've shown here, there are two possible locations, shown as $C_1$ and $C_2$, where this could be. The good news is that this doesn't matter.

Let's call the midpoint of that picture $M$. Then the triangle $CME$ has an angle, $\theta$ that is half of the angle you're looking for. And the sine of that angle is "opposite over hypotenuse", which is just the distance from $E$ to $M$ divided by $R$. So here goes, once again calling the points $p$ and $q$ instead of $E$ and $S#:

function arcMeasure(px, py, qx, qy, R) {
let xDiff = (px - qx) / 2;
let yDiff = (py - qy) / 2;
pmDistance = sqrt( xDiff * xDiff + yDiff * yDiff);
// that's the distance from one end of the arc to the 
// center point I've been calling M
let theta = Asin(pmDistance/R); // half the angle we're looking for
return (2 * theta);

...and that should do the trick. It'll fail when $R$ is zero, but that case doesn't make sense. Otherwise it should get you what you want. [1]: https://i.stack.imgur.com/yhToK.jpg

  • $\begingroup$ ok i understand that. I currently do not have the center point though. Is there a way to calculate that so it works regardless of arc angle $\endgroup$
    – joeb
    Sep 27 at 12:48
  • $\begingroup$ Suppose that start is $(-1, 0)$ and end is $(1, 0)$, and the radius is sqrt(2). Then the center COULD be $(0, 1)$, or it could be $(0, -1)$. So there's no way to find the center just knowing the start, end, and radius. Nonetheless, it may be possible to find the angle (in the example I just gave, the angle is 90 degrees either way!); let me think about that a bit and follow up sometime in the next day or two. $\endgroup$ Sep 29 at 3:00
  • $\begingroup$ See addition to my answer above. $\endgroup$ Sep 29 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .