It seems that this function works as intended for counterclockwise orders of points
vector<P> u;
u.push_back(P(2, 10));
u.push_back(P(3, 14));
u.push_back(P(4, 5));
u.push_back(P(5, 5));
circ(u[3], u[0], u[1], u[2]) // 0
circ(u[3], u[2], u[1], u[0]) // 1
Simple fix: add this before p2 = ...
if(a.cross(b, c)<0)
swap(a, c); // Any swap will do