How to stop one segment of a line from crossing another?

After a while, the geometry code gets tedious, but I want to finish this library, so here it goes.

Basically, what is the most efficient way to move one segment of line A so that it no longer intersects with another, B?

Both segments of segments are defined with a starting point (x, y) and a vector describing how the segment passes from this point (eX, eY). The following is an example of how a line segment is described:

enter image description here

The solution I'm looking for is where the line segment moves (its size does not change in any way) to the nearest place where it does not intersect. Example:

enter image description here

What is the most effective way to get this result?

EDIT: , "move" - (x, y) . .

, x/y .

+3
2

: : , , . .

+4

, , , .

, (x, y) (eX, eY). , [0,1] * (eX, eY) + (x, y).

. , a * (eX1, eY1) + (x1, y1) = (eX2, eY2) + (x2, y2) a [0,1].

, , -, , .

(x1 ', y1') = (x1, y1) - a * (eX1, eY1)

, , , , .

0

All Articles