public class Segment extends Object
| Constructor | Description |
|---|---|
Segment(Cartesian2D start,
Cartesian2D end,
Line line) |
Build a segment.
|
| Modifier and Type | Method | Description |
|---|---|---|
double |
distance(Cartesian2D p) |
Calculates the shortest distance from a point to this line segment.
|
Cartesian2D |
getEnd() |
Get the end point of the segment.
|
Line |
getLine() |
Get the line containing the segment.
|
Cartesian2D |
getStart() |
Get the start point of the segment.
|
public Segment(Cartesian2D start, Cartesian2D end, Line line)
start - start point of the segmentend - end point of the segmentline - line containing the segmentpublic Cartesian2D getStart()
public Cartesian2D getEnd()
public Line getLine()
public double distance(Cartesian2D p)
If the perpendicular extension from the point to the line does not cross in the bounds of the line segment, the shortest distance to the two end points will be returned.
Algorithm adapted from: Thread @ Codegurup - to checkCopyright © 2003–2017 The Apache Software Foundation. All rights reserved.