[Math] Finding the orientation (Clockwise vs Anticlockwise) of a well-defined arc

geometry

Given an arc, with two endpoints, a known radius, and a known center, is it possible to arbitrarily choose an endpoint as the start point, and determine if the motion of drawing the arc from that start point to the other endpoint is Clockwise or Anticlockwise.

That's my general question, I'm working on writing a geometry program, and this program will take in the radius, end point, and start point of an arc. It will then determine the two (or one/zero in some cases) arcs that fit the givens. Finally, based on a Clockwise/Anticlockwise option, it will draw the appropriate arc. I've (with some help from another question here) already derived the formula for finding the center points, and now I just need the Clockwise versus Anticlockwise calculation. Unlike the center of the arc derivation, I have no idea where to begin. I think I've bitten of a bit more than I can chew, as I getting into topics that I've yet to learn in school. (I feel like any knowledge of calculus would make this indefinitely easier).

Anyway, thanks for any help!

Best Answer

Let us assume you are given the start point $A:(a_1,a_2)$, the endpoint $B:(b_1,b_2)$ and the radius $r$ ($2r$ being bigger than the distance from $A$ to $B$). Let us assume that from that data you have correctly computed the wo possible centers, namely $C:(c_1,c_2)$ and $D:(d_1,d_2)$.

You need to take the vectors $u=\vec{CA}:(u_1,u_2)$ and $v=\vec{CB}:(v_1,v_2)$ and compute the following determinant: $$K = \begin{vmatrix}u_1 & u_2 \\ v_1 & v_2\end{vmatrix}$$ Then check the sign of $K$:

  • If $K<0$, then $C$ is the center you are looking for.
  • If $K>0$, you are going from $A$ to $B$ anticlockwisely and, thus, the center should be D.
  • If $K=0$, then $A$, $B$ and $C$ are on the same line. Since we were assuming that the distance from both $A$ and $B$ to $C$ is $r>0$, there are two possibilities: either $A=B$ or $dist(A,B)=r$ and $C$ is the midpoint between $A$ and $B$.
Related Question