org.locationtech.jts:jts-core 1.17.0
org.locationtech.jts.algorithm

## Class Distance

• ```public class Distance
extends Object```
Functions to compute distance between basic geometric structures.
Author:
Martin Davis
• ### Constructor Summary

Constructors
Constructor and Description
`Distance()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static double` ```pointToLinePerpendicular(Coordinate p, Coordinate A, Coordinate B)```
Computes the perpendicular distance from a point p to the (infinite) line containing the points AB
`static double` ```pointToSegment(Coordinate p, Coordinate A, Coordinate B)```
Computes the distance from a point p to a line segment AB Note: NON-ROBUST!
`static double` ```pointToSegmentString(Coordinate p, Coordinate[] line)```
Computes the distance from a point to a sequence of line segments.
`static double` ```segmentToSegment(Coordinate A, Coordinate B, Coordinate C, Coordinate D)```
Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### Distance

`public Distance()`
• ### Method Detail

• #### segmentToSegment

```public static double segmentToSegment(Coordinate A,
Coordinate B,
Coordinate C,
Coordinate D)```
Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!
Parameters:
`A` - a point of one line
`B` - the second point of (must be different to A)
`C` - one point of the line
`D` - another point of the line (must be different to A)
• #### pointToSegmentString

```public static double pointToSegmentString(Coordinate p,
Coordinate[] line)```
Computes the distance from a point to a sequence of line segments.
Parameters:
`p` - a point
`line` - a sequence of contiguous line segments defined by their vertices
Returns:
the minimum distance between the point and the line segments
• #### pointToSegment

```public static double pointToSegment(Coordinate p,
Coordinate A,
Coordinate B)```
Computes the distance from a point p to a line segment AB Note: NON-ROBUST!
Parameters:
`p` - the point to compute the distance for
`A` - one point of the line
`B` - another point of the line (must be different to A)
Returns:
the distance from p to line segment AB
• #### pointToLinePerpendicular

```public static double pointToLinePerpendicular(Coordinate p,
Coordinate A,
Coordinate B)```
Computes the perpendicular distance from a point p to the (infinite) line containing the points AB
Parameters:
`p` - the point to compute the distance for
`A` - one point of the line
`B` - another point of the line (must be different to A)
Returns:
the distance from p to line AB