/** * Computes the perpendicular distance between the (infinite) line defined * by this line segment and a point. * * @return the perpendicular distance between the defined line and the given point */ public double distancePerpendicular(Coordinate p) { return Distance.pointToLinePerpendicular(p, p0, p1); }
public void testDistancePointLinePerpendicular() { assertEquals(0.5, Distance.pointToLinePerpendicular( new Coordinate(0.5, 0.5), new Coordinate(0,0), new Coordinate(1,0)), 0.000001); assertEquals(0.5, Distance.pointToLinePerpendicular( new Coordinate(3.5, 0.5), new Coordinate(0,0), new Coordinate(1,0)), 0.000001); assertEquals(0.707106, Distance.pointToLinePerpendicular( new Coordinate(1,0), new Coordinate(0,0), new Coordinate(1,1)), 0.000001); }