Which way do you turn
transcript
Three points on a plane. Do they turn left or right? One whole number answers it.
Compute the cross product. Twelve means a left turn. Zero means one line. Minus twelve means a right turn.
It uses only products and sums. There is no division and no angle. So there is no rounding error.
With coordinates up to a million, values reach eight trillion. That does not fit in 32 bits. Use 64-bit integers.
A hull pops points that do not turn left. A point on an edge gives exactly zero. Pop it too, or the hull has an extra corner. Corners need a strict left turn.
The hull pops points that do not turn left. The zone problem tests the side of each edge. Sweeps and strips use the same sign to order shapes. One exact test serves them all.
Use the sign of the cross product. Then sort the points. Full breakdown in the lecture.