How to find shortest distance from triangle to point in 2D space?

1.3k Views Asked by At

I have a triangle with three corners located at $(-6,7), (2,5)$ and $(-4,8)$. I need to calculate shortest distance from nearest edge of triangle to the point $(-4,7)$. I can't figure out how to do that, could I have some advise?

1

There are 1 best solutions below

1
On BEST ANSWER

You find the equations of the 3 lines that make the triangle: $$m = \frac {y_2-y_1} {x_2-x_1} \\ y - y_1 = m(x-x_1)$$ Then you can simplify, and use this formula to find distance between $(-4,7)$ and each line, for a line of equation $ax+by+c=0$: $$\operatorname{distance}= \frac {ax+by+c} {\sqrt {a^2 + b^2}}$$