# How to determine if three points on unit circle are in cyclical order?

Given three vectors $$a, b,$$ and $$c$$ on the unit circle, and given a positive direction of rotation (say counter clockwise), how can I compute a property $$\mathcal{C}$$ that determines whether $$a, b,$$ and $$c$$ are in cyclical order?

For this property, it would hold that $$\mathcal{C}(a, b, c) = \mathcal{C}(b, c, a) = \mathcal{C}(c, a, b) = True,$$ (i.e. $$True$$ for any cyclical permutation), but $$False$$ otherwise.

A simple solution, i.e. using atan2 and comparing the angles would use lots of conditional statements (both in atan2 itself aswell as in the algorithm for $$\mathcal{C}$$). Instead, I am looking for a more algebraic solution.

An approach that feels correct is embedding the 2D-vectors into a 3D space and using the sign of the Triple Product, which satisfies the cyclical property nicely. But I couldn't manage to come up with a formula using the sign and the triple product without using many conditional expressions.

Here's a visual example:

• You should decide whether Property is named C or P, to avoid confusion. Please edit the question accordingly. – xax May 10 at 14:20
• Use atan2 to find out the angles. Once you have found them, assign them to 3 variables and just sort them. You'll immediately be able to find out if property is valid. – Ritam_Dasgupta May 10 at 14:24

• Perfect, thanks. Actually, if you see it as an embedding into 3d space by adding a $z=1$ component to each vector, this is exactly taking the triple product of the resulting vectors, which is the parallel I've been looking for. – Romeo Valentin May 10 at 14:46
Stand upright on the $$xy$$-plane at point $$A$$ and look towards point $$B$$. Now turn to look towards point $$C$$, never turning your back entirely to the circle; that is, turn less than $$180^\circ$$. I think you want to know if you turned left or turned right. By the so-called right-hand rule, the sign of the vector cross product of $$\vec{B-A}$$ and $$\vec{C-A}$$ should tell you. If it's positive, you turned left; if negative, right.
You can compute the angle of each one using atan2. Calling the angles $$A,B,C$$, first check if $$C \gt A$$. If not, add $$2\pi$$ to it. Then they are in order if $$A \lt B \lt C$$.