Interface Flattener<F extends Flattener<F,C,PL,P,DIR>,C extends Curve<?,?,P,F,PL>,PL extends PolyLine<?,P,?,?,?>,P extends Point<P>,DIR>

Type Parameters:
F - the Flattener type
C - the Curve type
PL - the PolyLine type
P - the Point type
DIR - the Direction type
All Known Subinterfaces:
Flattener2d, Flattener3d, OffsetFlattener2d
All Known Implementing Classes:
Flattener2d.MaxAngle, Flattener2d.MaxDeviation, Flattener2d.MaxDeviationAndAngle, Flattener2d.NumSegments, Flattener3d.MaxAngle, Flattener3d.MaxDeviation, Flattener3d.MaxDeviationAndAngle, Flattener3d.NumSegments, OffsetFlattener2d.MaxAngle, OffsetFlattener2d.MaxDeviation, OffsetFlattener2d.MaxDeviationAndAngle, OffsetFlattener2d.NumSegments

public interface Flattener<F extends Flattener<F,C,PL,P,DIR>,C extends Curve<?,?,P,F,PL>,PL extends PolyLine<?,P,?,?,?>,P extends Point<P>,DIR>
Flattens a Curve in to a PolyLine.

Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Interface for getPoint and getDirection that hide whether or not an offset is applied.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    checkDirectionError(DIR segmentDirection, DIR curveDirectionAtStart, DIR curveDirectionAtEnd, double maxDirectionDeviation)
    Check direction difference at the start and end of a segment.
    default boolean
    checkInflectionPoint(Flattener.FlattableCurve<P,DIR> curve, double prevT, double medianT, double nextT, P prevPoint, P nextPoint)
    Check for an inflection point by computing additional points at one quarter and three quarters.
    boolean
    checkLoopBack(DIR prevDirection, DIR nextDirection)
    Check for a direction change of more than 90 degrees.
    default boolean
    checkPositionError(P medianPoint, P prevPoint, P nextPoint, double maxDeviation)
    Report if the medianPoint is too far from the line segment from prevPoint to nextPoint.
    default void
    loadKnot(NavigableMap<Double,P> map, double knot, C curve)
    Load one knot in the map of fractions and points.
    default void
    Load the knots into the navigable map (including the start point and the end point).
  • Method Details

    • loadKnot

      default void loadKnot(NavigableMap<Double,P> map, double knot, C curve)
      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
    • loadKnots

      default void loadKnots(NavigableMap<Double,P> map, C curve)
      Load the knots into the navigable map (including the start point and the end point).
      Parameters:
      map - the navigable map
      curve - the curve that can yield a Point for every knot position
    • checkPositionError

      default boolean checkPositionError(P medianPoint, P prevPoint, P nextPoint, double maxDeviation)
      Report if the medianPoint is too far from the line segment from prevPoint to nextPoint.
      Parameters:
      medianPoint - P
      prevPoint - P
      nextPoint - P
      maxDeviation - double
      Returns:
      true if the medianPoint is too far from the line segment; false if the medianPoint is close enough to the line segment
    • checkLoopBack

      boolean checkLoopBack(DIR prevDirection, DIR nextDirection)
      Check for a direction change of more than 90 degrees. If that happens, the MaxDeviation flattener must zoom in closer.
      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

      boolean checkDirectionError(DIR segmentDirection, DIR curveDirectionAtStart, DIR curveDirectionAtEnd, double maxDirectionDeviation)
      Check direction difference at the start and end of a segment.
      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
    • checkInflectionPoint

      default boolean checkInflectionPoint(Flattener.FlattableCurve<P,DIR> curve, double prevT, double medianT, double nextT, P prevPoint, P nextPoint)
      Check for an inflection point by computing additional points at one quarter and three quarters. If these are on opposite sides of the curve2d from prevPoint to nextPoint; there must be an inflection point. This default implementation is only for the 2d case. https://stackoverflow.com/questions/1560492/how-to-tell-whether-a-point-is-to-the-right-or-left-side-of-a-line
      Parameters:
      curve - Curve2d
      prevT - t of preceding inserted point
      medianT - t of point currently considered for insertion
      nextT - t of following inserted point
      prevPoint - point on curve at prevT
      nextPoint - point on curve at nextT
      Returns:
      true if there is an inflection point between prevT and nextT; false if there is no inflection point between prevT and nextT