Package org.djutils.draw.line
Interface LineSegment<P extends Point<P>,D extends Directed> 
- Type Parameters:
- P- The point type (2d or 3d)
- D- The directed type (2d or 3d)
- All Superinterfaces:
- Drawable<P>,- Iterable<P>,- Project<P>,- Serializable
- All Known Implementing Classes:
- LineSegment2d,- LineSegment3d
public interface LineSegment<P extends Point<P>,D extends Directed> 
extends Drawable<P>, Serializable, Project<P>
LineSegment is the interface for a line segment bound by 2 end points. A line segment stores the order in which it has been
 created, so the end points are known as 'start' and 'end'.
 
 Copyright (c) 2020-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 
 BSD-style license. See DJUTILS License.
 
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- 
Method SummaryModifier and TypeMethodDescriptionclosestPointOnSegment(P point) Project a Point on this LineSegment.Get the end point of this LineSegment.doubleGet the length (distance from start point to end point) of this LineSegment.default DgetLocation(double position) Create a DirectedPoint at the specified position along this LineSegment.getLocationExtended(double position) Create a DirectedPoint at the specified position along this LineSegment.Get the start point of this LineSegment.reverse()Construct a new LineSegment with the points of this LineSegment in reverse order.Methods inherited from interface org.djutils.draw.DrawablegetDimensions, getPointList, size, toString, toString, toString, toStringMethods inherited from interface java.lang.IterableforEach, iterator, spliteratorMethods inherited from interface org.djutils.draw.line.ProjectprojectOrthogonal, projectOrthogonalExtended, projectOrthogonalFractional, projectOrthogonalFractionalExtended
- 
Method Details- 
getStartPointP getStartPoint()Get the start point of this LineSegment.- Returns:
- the start point of this LineSegment
 
- 
getEndPointP getEndPoint()Get the end point of this LineSegment.- Returns:
- the end point of this LineSegment
 
- 
getLengthdouble getLength()Get the length (distance from start point to end point) of this LineSegment.- Returns:
- (distance from start point to end point) of this LineSegment
 
- 
closestPointOnSegmentProject a Point on this LineSegment. If the the projected points lies outside the line segment, the nearest end point of the line segment is returned. Otherwise the returned point lies between the end points of the line segment.
 Adapted from example code provided by Paul Bourke.- Parameters:
- point- the point to project onto this segment
- Returns:
- either the start point, or the end point of this segment or a Point that lies somewhere in between those two.
- Throws:
- NullPointerException- when- pointis- null
 
- 
reverseLineSegment<P,D> reverse()Construct a new LineSegment with the points of this LineSegment in reverse order.- Returns:
- the new LineSegment
 
- 
getLocationCreate a DirectedPoint at the specified position along this LineSegment.- Parameters:
- position- the distance from the start point of this LineSegment.
- Returns:
- a DirectedPoint beginning at the specified position
- Throws:
- ArithmeticException- when- positionis- NaN
- IllegalArgumentException- when- position < 0, or- position > lengthof this LineSegment
 
- 
getLocationExtendedCreate a DirectedPoint at the specified position along this LineSegment.- Parameters:
- position- the distance from the start point of this LineSegment.
- Returns:
- a DirectedPoint at the specified position
- Throws:
- ArithmeticException- when- positionis- NaN
- IllegalArgumentException- when- positionis- infinite
 
 
-