# How to find the maximum & minimum possible Location within a graph?

For example, I have a graph having size of 480 width x 300 height. I am able to calculate the center point ( & that is 240,150 ).

Now my question is as follows.

• I have a location/vertex on that graph. ( as follows. )

• I want to calculate the possible max & min co-ordinate detail within graph if I draw a edge using both vertex ( illustrated as follows )
Edit : This is just a sample vertex. Vertex can be anywhere in the graph.

• I want to determine the max co-ordinate and min co-ordinate.

( I am from commerce background & have less knowledge of maths. Requesting you to improve question, if needed )

-

Referencing the diagram shown below, where the origin is at the lower left hand corner of the rectangle:

Let's say the coordinates of the top point are $(a,b)$ and that $q=(x_q,y_q)$ is the point of intersection "on the left" of the diagonal and the rectangle.

Draw the right triangle whose hypotenuse is the line segment between the points $(a,b)$ and $(240,150)$, whose vertical side intersects $(a,b)$, and whose horizontal side intersects $(240,150)$. Let's call that triangle $T$.

Draw the right triangle whose hypotenuse is the line segment between the points $(a,b)$ and $q$, whose vertical side intersects $(240,150)$, and whose horizontal side intersects $q$. Let's call that triangle $B$.

For triangle $T$, we know the height of the vertical side is $|b-150|$. We also know the width of the horizontal side $|a-240|$.

For triangle $B$, we know the height of the vertical side is $|150 -q_y|$. And we know the width of the horizontal side $|240-q_x|$.

These two triangles are similar, so corresponding ratios of sides are equal: $$\tag{1}{|b-150|\over |a-240|}={ |150-q_y|\over|240-q_x|}.$$

Now, depending on whether the diagonal intersects the top/bottom or left/right sides of the rectangle, you will either know the value of $q_x$ or $q_y$. Then you can use equation (1) to find the value of the other coordinate.

Of course, you could just find the equation of the line formed by the diagonal and use that...

In fact, the equation would be $$\tag{2}{y-150\over x-240}={b-150\over a-240}.$$

You know either the $x$ or $y$ coordinate of $q$; so, you can use equation (2) to find the unknown coordinate.

(Note, incidentally, the similar triangle argument essentially tells you why the equation of the line is as given in (2).)

Not to scale

-
Well ! Your answer would surely help me to findout xCo-ordinate, but what about finding yCo-ordinate? how to evaluate it ( as location (a,b) may be any location in the graph.) – Sagar R. Kothari Dec 6 '11 at 10:07
Ah, thanks for pointing this out. It's, the same argument; but you would draw triangles "on top of the diagonal". If that makes sense... – David Mitra Dec 6 '11 at 10:13
If the points are where David has drawn them, the max and min $y$-coordinates will be 300 and zero, respectively. So I think the first thing you have to do is decide where that second point is relative to the diagonals of the rectangle, so you know whether your line meets the top and bottom of the rectangle, or the left and right sides. – Gerry Myerson Dec 6 '11 at 11:44