public class Segment
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private Vector2D |
end
End point of the segment.
|
private Line |
line
Line containing the segment.
|
private Vector2D |
start
Start point of the segment.
|
Constructor and Description |
---|
Segment(Vector2D start,
Vector2D end,
Line line)
Build a segment.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(Vector2D p)
Calculates the shortest distance from a point to this line segment.
|
Vector2D |
getEnd()
Get the end point of the segment.
|
Line |
getLine()
Get the line containing the segment.
|
Vector2D |
getStart()
Get the start point of the segment.
|
private final Vector2D start
private final Vector2D end
private final Line line
public Vector2D getStart()
public Vector2D getEnd()
public Line getLine()
public double distance(Vector2D 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 (c) 2003-2014 Apache Software Foundation