Package org.djutils.draw.curve
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 typeC
- the Curve typePL
- the PolyLine typeP
- the Point typeDIR
- 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 ClassesModifier and TypeInterfaceDescriptionstatic interface
Interface for getPoint and getDirection that hide whether or not an offset is applied. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
loadKnots
(NavigableMap<Double, P> map, C curve) Load the knots into the navigable map (including the start point and the end point).
-
Method Details
-
checkPositionError
Report if the medianPoint is too far from the line segment from prevPoint to nextPoint.- Parameters:
medianPoint
- PprevPoint
- PnextPoint
- PmaxDeviation
- double- Returns:
true
if themedianPoint
is too far from the line segment;false
if themedianPoint
is close enough to the line segment
-
checkLoopBack
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) pointnextDirection
- 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 segmentcurveDirectionAtStart
- direction of the curve at the start of the segmentcurveDirectionAtEnd
- direction of the curve at the end of the segmentmaxDirectionDeviation
- maximum permitted direction difference- Returns:
true
if the direction difference at the start and the end of the segment is smaller thanmaxDirectionDeviation
;false
if the direction difference at the start, or the end of the segment equals or exceedsmaxDirectionDeviation
-
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
- Curve2dprevT
- t of preceding inserted pointmedianT
- t of point currently considered for insertionnextT
- t of following inserted pointprevPoint
- point oncurve
atprevT
nextPoint
- point oncurve
atnextT
- Returns:
true
if there is an inflection point betweenprevT
andnextT
;false
if there is no inflection point betweenprevT
andnextT