The whole discussion is on two-dimensional only. Suppose the 2 line segments are defined by points and . The 2 segments can either be parallel or non-parallel.
Non-parallel case. There are at least 2 methods to determine, straightforward thinking is to construct the equation of the 2 lines using the 2 segments
solve for the parameters . One way is using bull force to solve it. Another way is the area ratio:
The nominator is the area of the triangle . The denominator is the area of the whole area . The whole area is
The simplification uses the identity .Similarly.
The intersect condition is
In the case of parallel, there are 2 cases: with offset or without offset
In the case of offset, the “whole” area , geometrically, the cross-product as it is clockwise. Since the 2 segments are parallel, the perpendicular distances from or to line are the same. So, the area
When the 2 segments are “co-planar”, the nominator becomes zero too. To check if the two segments overlap or not, simply check x- or y-component is enough.
Leave a comment