I would like to find the intersection point of a vector or its extension with the surrounding rectangle, that is, in the image (1) and (2), given (x1, y1), (x2, y2), (a1, a2), (b1, b2), we would like to obtain the point (c1, c2).
I have found the article Find collision point between vector and fencing rectangle but, since the positive y-axis is downward in python/windows, I could not manage the equations and parameters to acheive the correct result. The two following links are also related.
intersection between a line and square
Get intersection point of rectangle and line.
But they do not include the extension of the vector/line segment. How should the equations change to obtain the correct result?
