A point set is given to find the maximum Triangle Area of the vertex in the point set.
We know that the three points of the Triangle must be on the convex hull. After finding the convex hull, we cannot enumerate it. Because N is a large question, the order of magnitude of O (N ^ 3) is required for enumeration, so the practice of rotating the card shell:
First, enumerate the first vertex I of a triangle, initialize the second vertex J = I + 1 and the third vertex K = J + 1, and cycle K, until the first K is found to make cross (I, j, k)> Cross (I, j, k + 1). If K = I, it enters the next loop.
Rotate J and K, update the maximum value before each loop, and fix a J. Similarly, find a k so that cross (I, j, k)> Cross (I, j, k + 1 ). Perform the ++ operation on J and continue the next operation. We know that J = K' (until j, k is rotated (k + 1) % N) or k = I.
Double rotating_calipers (vector <point> & points) {vector <point> P = convexhull (points); int n = P. size (); p. push_back (P [0]); double ans = 0; For (INT I = 0; I <n; ++ I) {Int J = (I + 1) % N; int K = (J + 1) % N; // when area (P [I], p [J], p [k + 1]) <= Area (P [I], p [J], p [k]) Stop rotation // that is, cross (P [J]-P [I], P [k + 1]-P [I])-cross (P [J]-P [I], p [k]-P [I]) <= 0 // according to cross (a, B)-cross (a, c) = cross (A, B-C) // simplify cross (P [J]-P [I], p [k + 1]- P [k]) <= 0 while (K! = I & cross (P [J]-P [I], p [k + 1]-P [k])> 0) k = (k + 1) % N; If (k = I) continue; int KK = (k + 1) % N; while (J! = KK & K! = I) {ans = max (ANS, cross (P [J]-P [I], p [k]-P [I]); While (K! = I & cross (P [J]-P [I], p [k + 1]-P [k])> 0) k = (k + 1) % N; j = (J + 1) % N ;}return ans * 0.5 ;}