# Determine Direction of an Arc (CW/CCW)

I'm trying to write a function that will determine whether a circular arc travels clockwise or counter-clockwise.

Given the X,Y coordinates for the start point, center point, and end point I first calculate the angle in radians from the center point to the start and end points.

I thought if I subtracted the ending line angle from starting line angle I could determine if the direction of the arc like this:

if (angle1 - angle2 <= 0): # Clockwise
else: # Counter-Clockwise


This does work for any cases where the arc doesn't cross the zero-radians line. But if the arc crosses that line the logic doesn't work.

This Illustration shows that the arc S1-C-E1 works but S2-C-E2 doesn't. I'm pretty sure I've got the right idea, I'm just stuck on the logical bit.

I found another question here that seemed to be similar to what I'm trying to do, but its answer involved a matrix which, I'm sad to admit, I've never learned how to work with. I need an answer that I can easily translate into code or enter into a spreadsheet.

Thanks for any and all assistance!

• What do you mean by "whether a circular arc travels clockwise or counter-clockwise"? Are you thinking of the smaller arc determined by the given points? Nov 12, 2015 at 16:35
• No, the arc may be the larger arc. The arc starts at the starting point and ends at the end point going around the center point. Nov 12, 2015 at 16:49
• But in that case how do you decide the arc direction? It could go always counterclockwise, for instance. Nov 12, 2015 at 17:20
• Maybe I wasn't clear how I stated it. Using a drawing compass, you put the metal point on the center. Then place the pencil end on the start point and draw around to the end point. Depending on which end point is the start and which is the end will determine the direction the compass travels. Nov 12, 2015 at 18:47
• You should realize that one can "place the pencil end on the start point and draw around to the end point" in either direction. How do you decide that you have to draw clockwise, for instance? Could you possibly show a picture? Nov 12, 2015 at 19:03

If your question is about the smaller arc determined by the three points $A$ (start point), $O$ (center point) and $B$ (end point) then you can compute $$c=(A_x-O_x)(B_y-O_y)-(A_y-O_y)(B_x-O_x).$$
If $c>0$ the arc is counterclockwise, if $c<0$ it is clockwise, if $c=0$ then $A$, $O$ and $B$ are aligned.