D
D
Denis2019-11-24 19:43:47
Mathematics
Denis, 2019-11-24 19:43:47

Formula for the intersection of line segments?

There are two line segments on it. Let's say a straight line from 0 to 15. Examples of segments.
Segment A (2, 5) segment B (6, 9) do not intersect.
Segment A (5, 7) segment B (3, 9) intersect.
Segment A (5, 9) segment B (7, 11) intersect.
I think it's understandable ...
Is there a formula to determine whether the segments intersect or not?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Elvis, 2019-11-24
@Dr_Elvis

umm...
A(x1, x2)
B(y1, y2)
If x2 > y1, then the segments intersect.

H
hint000, 2019-11-25
@hint000

I will take the notation from the previous answer
A(x1, x2)
B(y1, y2)
the segments intersect if any of the four conditions is met:

y1 <= x1 <  y2 или
y1 <  x2 <= y2 или
x1 <= y1 <  x2 или
x1 <  y2 <= x2

If touching at one point is also considered an intersection, then all inequalities must be non-strict.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question