Line Segment Intersection
Given two line segments, determine whether they intersect.
Segment 1 is defined by endpoints $P_1 = (x_1, y_1)$ and $Q_1 = (x_2, y_2)$. Segment 2 is defined by endpoints $P_2 = (x_3, y_3)$ and $Q_2 = (x_4, y_4)$.
The input arg1 is an array of 8 numbers: [x1, y1, x2, y2, x3, y3, x4, y4].
Return 1 if the segments intersect (including the case where an endpoint lies on the other segment or the segments overlap collinearly on a shared interval), otherwise return 0.
Use exact orientation/cross-product arithmetic for integer coordinates.
Examples
Input: [1,2,3]
Output: 0
Input: [2,3,4]
Output: 0
Hints
Compute orientations of triplets using cross products.
General case: segments intersect if each segment straddles the line of the other.
Special case: handle collinear points by checking whether a point lies on the segment bounding box.
Related Problems
Line Segment Intersection
Given two line segments, determine whether they intersect.