## Problem:

Let have three points A(x,y), B(x,y), C(x,y). Make code which prints if A->B->C sequence makes clockwise, counter clockwise turn, or A,B,C stay in one line. In the above picture ABC makes counter clockwise turn.

## The rules:

You can code the solution in any programming language during the weekend and have to submit it to info@olimex.com latest on Sunday March 30th.

On Monday we will upload the solutions on GitHub https://github.com/OLIMEX/WPC

You can play with your real name or with nick if you want to be anonymous, we will not disclosure your personal info if you do not want to.

Emiliano Daddario

Mar 28, 2014@ 22:04:28Easy. Cross product of vectors.

Dylan

Mar 29, 2014@ 22:26:41You seem to have confused this programming challenge with the Twitter quiz, Emiliano.

Emiliano Daddario

Mar 30, 2014@ 21:50:05I’m sure I didn’t confuse this with the twitter quiz, since I haven’t even seen the latter. I intentionally didn’t explain what I meant, I’ll do it now. Let x, y and z be the Cartesian (right-handed) axes. Let AB and BC be the “oriented” vectors (oriented this way: A->B and B->C) in the xy plane. Now, let P be the z coordinate of the cross product of vectors AB X BC. Here is the solution in pseudocode.

If P>0 then A->B->C->A is a counterclockwise path. Else if P<0 it's clockwise. Else if P==0 it's a degenerate triangle (three collinear points i.e. neither clockwise nor counterclockwise)

If you choose different vectors the solution could be different.

If you use the more general winding number trick instead, you need to check its sign.

Dylan

Mar 30, 2014@ 22:41:03Yeah yeah. Submit code to info@olimex.com. And if the “challenge” is to trivial for you… let others take it on for themselves. Oh, and visit Project Euler😉

Emiliano Daddario

Mar 28, 2014@ 22:08:58A more general solution for arbitrary polygons (considering a particular polygon among all the possible ones which have these points as vertices) would be the winding number, I used it in the past