Class DirectionalPolyLine

java.lang.Object
org.djutils.draw.line.PolyLine2d
org.opentrafficsim.base.geometry.OtsLine2d
org.opentrafficsim.base.geometry.DirectionalPolyLine
All Implemented Interfaces:
Serializable, nl.tudelft.simulation.dsol.animation.Locatable, org.djutils.draw.Drawable<org.djutils.draw.point.Point2d>, org.djutils.draw.Drawable2d, org.djutils.draw.line.PolyLine<org.djutils.draw.line.PolyLine2d,org.djutils.draw.point.Point2d,org.djutils.draw.line.Ray2d,org.djutils.draw.line.LineSegment2d>, org.djutils.draw.line.Project<org.djutils.draw.point.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.
See Also:
  • Constructor Details

    • DirectionalPolyLine

      public DirectionalPolyLine(org.djutils.draw.line.PolyLine2d line, org.djunits.value.vdouble.scalar.Direction startDirection, org.djunits.value.vdouble.scalar.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 org.djutils.draw.line.PolyLine<org.djutils.draw.line.PolyLine2d,org.djutils.draw.point.Point2d,org.djutils.draw.line.Ray2d,org.djutils.draw.line.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 org.djutils.draw.line.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 org.djunits.value.vdouble.scalar.Direction getStartDirection()
      Returns the start direction.
      Returns:
      start direction
    • getEndDirection

      public org.djunits.value.vdouble.scalar.Direction getEndDirection()
      Returns the end direction.
      Returns:
      end direction