Class DirectionalPolyLine

All Implemented Interfaces:
Iterable<Point2d>, Locatable, Drawable<Point2d>, Drawable2d, PolyLine<PolyLine2d,Point2d,Ray2d,DirectedPoint2d,LineSegment2d>, Project<Point2d>

public class DirectionalPolyLine extends OtsLine2d
Adds a direction at the start and end point relative to its super class OtsLine2d, as the first and last segment may not have the same direction as a theoretical line the segments are a numerical approach of. These directions are used in a few methods which alter the result from the super class. The most notable addition of this class is directionalOffsetLine.
  • Constructor Details

    • DirectionalPolyLine

      public DirectionalPolyLine(PolyLine2d line, Direction startDirection, Direction endDirection)
      Constructor.
      Parameters:
      line - base line
      startDirection - start direction
      endDirection - end direction
  • Method Details

    • directionalOffsetLine

      public DirectionalPolyLine directionalOffsetLine(double offset)
      Returns line at a fixed offset, adhering to end-point directions.
      Parameters:
      offset - offset
      Returns:
      offset line
    • directionalOffsetLine

      public DirectionalPolyLine directionalOffsetLine(double startOffset, double endOffset)
      Returns line at a fixed offset, adhering to end-point directions.
      Parameters:
      startOffset - offset at start
      endOffset - offset at end
      Returns:
      offset line
    • extractFractional

      public DirectionalPolyLine extractFractional(double start, double end)
      Description copied from class: OtsLine2d
      Construct a new OtsLine2d covering the indicated fraction of this OtsLine2d.
      Specified by:
      extractFractional in interface PolyLine<PolyLine2d,Point2d,Ray2d,DirectedPoint2d,LineSegment2d>
      Overrides:
      extractFractional in class OtsLine2d
      Parameters:
      start - starting point, valid range [0..end)
      end - ending point, valid range (start..1]
      Returns:
      the new OtsLine2d
    • getLocationFraction

      public Ray2d getLocationFraction(double fraction)
    • projectFractional

      public double projectFractional(double x, double y, OtsLine2d.FractionalFallback fallback)
      Fractional projection applied with the internal start and end direction.
      Parameters:
      x - x-coordinate
      y - y-coordinate
      fallback - fallback method
      Returns:
      fraction along line which it the projection of the given coordinate
    • getStartDirection

      public Direction getStartDirection()
      Returns the start direction.
      Returns:
      start direction
    • getEndDirection

      public Direction getEndDirection()
      Returns the end direction.
      Returns:
      end direction