Find maximum and minimum intersections between two points on a 2D graph

1.1k Views Asked by At

I'm having a hard time figuring out the maximum and minimum X and Y values that a line can have which intersects 2 points on a graph.

Here's an example of what I mean, please excuse the shoddy MSPaint work, it's the best way I can think to visualise what I mean:

Click here

Given the above simple graph with the minimum possible value (0,0) and the maximum (10,10), I would logically know that given two points (1,1) and (2,2) the maximum and minimum value points for a line which fully intersects these to points would be (0,0) and (10,10), here's that as an example:

Click here

I know in this case that the gradient is 1. I'm just having a hard time being able to use this knowledge in more complex cases, is there a standard method of fully extrapolating a line between two points to its maximum and minimum values?

Many thanks.

I've updated my post to reflect a question asked by saulspatz.

Click here

In this case, logically I know the Y value of the minimum point is 0, and the X value of the maximum point is 0 (as I have bounded the original graph between X and Y values of 0-10). But I wonder how we can calculate this as a function?

1

There are 1 best solutions below

0
On BEST ANSWER

You need to start by calculating the equation of the line through the two points. If the points are $(x_1, y_1), (x_2, y_2),$ the equation of the line joining them is $$ {y-y_1\over x-x_1} = {y_2-y_1 \over x_2 - x1} \tag{1}$$ In the case $(x_1, y_1)=(3,5), (x_2, y_2) = (5,3),\ (1)$ gives $$ {y-5\over x-3} = {3-5 \over 5 - 3} \tag{2}\implies y-5=3-x\implies y=8-x$$

Now, the top of the square has equation $y=10,$ the bottom has equation $y=0,$ the left side has equation $x=0,$ and the right equation $x=10.$ In general, the line will intersect two of these sides, although it could intersect more if it passes through the corners, and so you may have to test them all. For example, to test whether the line passes through the right side, we'd substitute $x=10$ in $(2)$. This gives $y=-2,$ which is no good, since we have $0\leq x \leq 10, 0 \leq y \leq 10.$ So, it doesn't intersect the right side. To test whether it intersects the bottom, we substitute $y=0$ in $(2)$ and get $x=8,$ which satisfies the constraints, so we know $(8,0)$ is one of the points of intersection.

I think you'll be able to find the other intersection yourself now.