Interface OffsetFlattener2d

All Superinterfaces:
Flattener<Flattener2d,Curve2d,PolyLine2d,Point2d,Double>
All Known Implementing Classes:
OffsetFlattener2d.MaxAngle, OffsetFlattener2d.MaxDeviation, OffsetFlattener2d.MaxDeviationAndAngle, OffsetFlattener2d.NumSegments

public interface OffsetFlattener2d extends Flattener<Flattener2d,Curve2d,PolyLine2d,Point2d,Double>
Flattens a Curve2d with piece-wise linear offset in to a PolyLine2d.

Copyright (c) 2023-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Method Details

    • flatten

      Flatten a OffsetCurve2d curve into a PolyLine2d while applying lateral offsets.
      Parameters:
      curve - the curve
      of - the lateral offset to apply
      Returns:
      flattened curve
    • loadKnot

      default void loadKnot(NavigableMap<Double,Point2d> map, double knot, OffsetCurve2d curve, ContinuousPiecewiseLinearFunction of)
      Load one knot in the map of fractions and points.
      Parameters:
      map - the map
      knot - the fraction where the knot occurs
      curve - the curve that can compute the point for each knot position
      of - offset data
      Throws:
      NullPointerException - when map is null, knot is null, curve is null, or of is null
      IllegalArgumentException - when knot < 0.0, or knot > 1.0
    • loadKnots

      default void loadKnots(NavigableMap<Double,Point2d> map, OffsetCurve2d curve, ContinuousPiecewiseLinearFunction of)
      Load the knots into the navigable map (including the start point and the end point).
      Parameters:
      map - the navigable map
      curve - the curve
      of - the offset data
    • checkLoopBack

      default boolean checkLoopBack(Double prevDirection, Double nextDirection)
      Description copied from interface: Flattener
      Check for a direction change of more than 90 degrees. If that happens, the MaxDeviation flattener must zoom in closer.
      Specified by:
      checkLoopBack in interface Flattener<Flattener2d,Curve2d,PolyLine2d,Point2d,Double>
      Parameters:
      prevDirection - the direction at the preceding (already added) point
      nextDirection - the direction at the succeeding (already added) point
      Returns:
      true if the curve changes direction by more than 90 degrees; false if the curve does not change direction by more than 90 degrees
    • checkDirectionError

      default boolean checkDirectionError(Double segmentDirection, Double curveDirectionAtStart, Double curveDirectionAtEnd, double maxDirectionDeviation)
      Description copied from interface: Flattener
      Check direction difference at the start and end of a segment.
      Specified by:
      checkDirectionError in interface Flattener<Flattener2d,Curve2d,PolyLine2d,Point2d,Double>
      Parameters:
      segmentDirection - direction of the segment
      curveDirectionAtStart - direction of the curve at the start of the segment
      curveDirectionAtEnd - direction of the curve at the end of the segment
      maxDirectionDeviation - maximum permitted direction difference
      Returns:
      true if the direction difference at the start and the end of the segment is smaller than maxDirectionDeviation; false if the direction difference at the start, or the end of the segment equals or exceeds maxDirectionDeviation
    • makeFlattableCurve

      Make a FlattableCurve object.
      Parameters:
      curve - the curve
      of - the offset function
      Returns:
      the flattable curve