# Detecting whether directed cycle is clockwise or counterclockwise

Given a directed cycle in the plane I need to walk it and detect whether it is clockwise or counterclockwise.

My first idea is to gather the sum of the turn angles, where a "left" turn is a negative angle, and a "right" turn is a positive angle. If I go with this one, I need a good way to calculate the angle between two vectors, and also which sign this angle should have (+/-).

Even if I had the right tools to calculate the (+/-) angle I feel like this could be done simpler.c

-
Looks like a homework problem. – Tunococ Oct 29 '10 at 10:16
So it does! It's not, though. (depending on a fitting definition of homework) – Andy Storck Oct 29 '10 at 10:24
Assuming the cycle is embedded: Walk along the cycle once to find any rightmost vertex, $v$. At $v$, the exiting edge is (above) below the entering edge iff the cycle is (counter) clockwise. – Sam Nead Oct 29 '10 at 11:24
Ok, it is more precise to say that the entering and exiting edges form two angles, one of these angles is "to the left" and the arrangement of the edges about the left angle tells you what you want. – Sam Nead Oct 29 '10 at 11:28

The orientation of a triangle (clockwise/counterclockwise) is the sign of the determinant $\begin{bmatrix} 1&x_1&y_1\\\\ 1&x_2&y_2\\\\ 1&x_3&y_3 \end{bmatrix}$, where $(x_1,y_1), (x_2,y_2), (x_3,y_3)$ are the Cartesian coordinates of the three vertices of the triangle.