Interface Flattener2d

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

public interface Flattener2d extends Flattener<Flattener2d,Curve2d,PolyLine2d,Point2d,Double>
Flattens a Curve2d 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

      PolyLine2d flatten(Curve2d curve)
      Flatten a Curve2d into a PolyLine2d.
      Parameters:
      curve - the curve
      Returns:
      flattened line
      Throws:
      NullPointerException - when curve is null
    • 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