public class Segment extends Object
Constructor and Description |
---|
Segment(Vector2D start,
Vector2D end,
double tolerance)
Build a segment.
|
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.
|
double |
getLength()
Get the length of the line segment.
|
Line |
getLine()
Get the line containing the segment.
|
Vector2D |
getStart()
Get the start point of the segment.
|
public Segment(Vector2D start, Vector2D end, double tolerance)
start
- start point of the segmentend
- end point of the segmenttolerance
- of the line.public Vector2D getStart()
public Vector2D getEnd()
public Line getLine()
public double getLength()
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 © 2016-2021 CS GROUP. All rights reserved.