Final version of Graham's scan algorithm.