Sort Points by clockwise Angle
Points[4] = {...}; Point origin; ... // Sort Points by Angles for(int m=0; m<3; m++) for (int i = m + 1; i < 4; i++) { if (GetClockwiseAngle(Points[i], origin) < GetClockwiseAngle(Points[m], origin);) { SwapPoint(Points, i, m); } } ... double GetClockwiseAngle(Point point, Point origin) { double angle = 0.0; angle = atan2(point.Y - origin.Y, point.X - origin.X) * 180 / M_PI;; ...