Search code examples
computational-geometry

A line that is not parallel


Suppose that n points are given. Call the set of lines determined by them S. Can you find a line that is not parallel to any of the lines in S in better than quadratic time?


Solution

  • Sort all n points by increasing abscissa. It is clear that the largest slope occurs between two consecutive points. So pick the largest slope among the n-1 possibilities and use a yet larger slope.

    enter image description here


    The case of points vertically aligned is harmless: ignore these infinite slopes and stay with the largest among the finite ones.