I have an array of points, as well as two more points (A and B). The last two points form a line, and I’m trying to find which of the points in my array are furthest from the line. How would I do this in Java?
I’m wondering if it’s something along the lines of finding the distance from A and B, but that doesn’t sit well in my head.
Additional info:
I think it’s a line segment. Given this is QuickHull, I don’t know if it makes a difference.
I’ve never been the greatest when it comes to math and formulas, so more explanation is better. Thanks!
Note that each 3 points
[a,b,p]for eachpin the array form a trianle, whose area is denoted by:(ab) * h /2[wherehis the distance fromptoab]You can compute the area these trianles create, and select the minimal. Since
abis constant for all – it guarantees that the trianle with the minimal area will also have the minimalh.You can find it [the area of each triangle] using
[where
x_a,x_b,x_pandy_a,y_b,y_pare thex,ycoordinates ofa,b,prespectively].ways to do it.