Intersection of two line segments
Given two line segments in the plane, each by its two endpoints, decide whether they intersect and return the intersection point (or the overlapping piece when they are collinear and overlap). Handle parallel segments, segments that only touch at an endpoint, vertical segments and collinear overlaps, and say how you deal with floating-point error.
No answer yet. Write the first one; the best answer gets endorsed.
