Wrote a function to detect if two line segments intersect