Check if points are sorted in circular order

271 Views Asked by At

How do you check if points are sorted in circular order (regardless of clockwise or counter-) (assuming they don't exactly form one whole circle, what matters is the points are sorted in a circular order)?

enter image description here

1

There are 1 best solutions below

0
On

Let $c$ be the barycenter of the points $p_1,p_2,\dots,p_n$. Then the points are sorted in circular order when $ccw(c,p_i,p_{i+1}) > 0 $ for all $i$, with $p_{n+1}=p_1$. Here $ccw$ is the standard geometric primitive.

Any point in the convex hull works as a center $c$. For instance, the lowest point among the given points.