Source
bool isConvex() { int length = points.length; if (length <= 3) return true; for(int i = 0; i < length; i++) { Point<num> p1 = points[(i + 0) % length]; Point<num> p2 = points[(i + 1) % length]; Point<num> p3 = points[(i + 2) % length]; if(!_convex(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y)) return false; } return true; }