I need something as simple as
\"Subject 1.02: How do I find the distance from a point to a line?\"
But that works with Lon/Lat.
Ilya Golota's answer is a correct approach but, turns out it always returns a really large number such as "3.0355243098445522e12" even for points that are 2 meters away from the line. I did this for computing the triangle area instead:
double d0 = computeDistanceBetween(p0, p1);
double d1 = computeDistanceBetween(p1, p2);
double d2 = computeDistanceBetween(p2, p0);
(Using Heron's formula)
double area = Math.sqrt(halfP*(halfP-d0)*(halfP-d1)*(halfP-d2));
And then plug in the area value here
double distanceToLine = 2*area/computeDistanceBetween(line.startPoint, line.endPoint)
This works well for me and returns the perpendicular distance from the point to the line in meters.