0
$\begingroup$

I need to find out the points of intersection of two straight lines/rectangles.

Given following example with sample coordinates:

Red line intersect black rectangle at green points

The red line intersects the black rectangle in two points. I need to find out at which coordinates they intersect. I understand that I can get the angle of a line segment via (coming from a computer based environment):

angle = atan2 (y2 - y1, x2 - x1)

or the distance between two points of the line via

distance = sqrt ( (x2 - x1)² + (y2 - y1)² )

But I don't understand how I could apply this information to find out the coordinates of the two intersection points A and B.

What formula can I use to find out these points?

$\endgroup$
0

1 Answer 1

0
$\begingroup$

Use two point form $\frac {(y - y1)}{( x - x1)} = \frac {(y2 - y1)}{(x2 - x1)}$ where x1 = 0.5, y1 = 0.25; and x2 = 1.5, y2 = 1.25 to set up an equation.

The other (horizontal, black) line has the equation y = 1.

Solve these two equations and get the co-ordinates for point A, which is (?, 1).

Repeat the process to find the co-ordinates of B, which is (2, ??). (The other (vertical, black) line has the equation x = 2.)

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .