title: opencv: how to clusterize by angle using kmeans()
body: <p>Question is, how to clusterize pairs of some units by their angle? Problem is that, kmeans operates on the notion of Euclidean space distance and does not know about periodic nature of angles. So to make it work, one needs to translate the angle to Euclidean space but hold the following true:</p>
  
  <ol>
  <li>close angles are close values in Euclidean space;</li>
  <li>far angles are far in Euclidean space.</li>
  </ol>
  
  <p>Which means, that, 90 and -90 are distant values, 180 and -180 is the same, 170 and -170 are close (angles come from left up and to right: 0 - +180 and from left down to the right: 0 - -180)</p>
  
  <p>I tried to use various <code>sin()</code> functions but they all have issues mentioned in points 1 and 2. Most perspective one is <code>sin(x * 0.5f)</code> but also having the problem that 180 and -180 are distant values in Euclidean space.</p>