public class Segment extends Object
Constructor and Description |
---|
Segment(Vector2D startIn,
Vector2D endIn)
Build a segment.
|
Segment(Vector2D startIn,
Vector2D endIn,
Line lineIn)
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 |
getClosestPoint(Vector2D p)
Returns closest point of provided point belonging to segment.
|
Vector2D |
getEnd()
Get the end point of the segment.
|
Vector2D |
getIntersection(Segment segment)
Returns the intersection between two segments, null if there is no intersection.
|
Line |
getLine()
Get the line containing the segment.
|
Vector2D |
getStart()
Get the start point of the segment.
|
public Segment(Vector2D startIn, Vector2D endIn, Line lineIn)
startIn
- start point of the segmentendIn
- end point of the segmentlineIn
- line containing the segmentpublic 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 checkpublic Vector2D getClosestPoint(Vector2D p)
p
- a pointCopyright © 2023 CNES. All rights reserved.