Class Segment
java.lang.Object
org.hipparchus.geometry.euclidean.twod.Segment
Simple container for a two-points segment.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
Segment
Build a segment.- Parameters:
start
- start point of the segmentend
- end point of the segmenttolerance
- of the line.
-
Segment
Build a segment.- Parameters:
start
- start point of the segmentend
- end point of the segmentline
- line containing the segment
-
-
Method Details
-
getStart
Get the start point of the segment.- Returns:
- start point of the segment
-
getEnd
Get the end point of the segment.- Returns:
- end point of the segment
-
getLine
Get the line containing the segment.- Returns:
- line containing the segment
-
getLength
public double getLength()Get the length of the line segment.- Returns:
- line segment length.
-
distance
Calculates the shortest distance from a point to this line segment.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 @ Codeguru- Parameters:
p
- to check- Returns:
- distance between the instance and the point
-