Package org.djutils.draw.curve
Interface Flattener2d
- All Superinterfaces:
Flattener<Flattener2d,Curve2d, PolyLine2d, Point2d, Double>
- All Known Implementing Classes:
Flattener2d.MaxAngle,Flattener2d.MaxDeviation,Flattener2d.MaxDeviationAndAngle,Flattener2d.NumSegments
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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classFlattener that limits the angle difference between theCurve2dand thePolyLine2d.static classFlattener that limits the distance between theCurve2dand thePolyLine2d.static classFlattener that limits the distance and angle difference between theCurve2dand thePolyLine2d.static classFlattener that approximates theCurve2dwith a specified number of segments.Nested classes/interfaces inherited from interface org.djutils.draw.curve.Flattener
Flattener.FlattableCurve<P,DIR> -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancheckDirectionError(Double segmentDirection, Double curveDirectionAtStart, Double curveDirectionAtEnd, double maxDirectionDeviation) Check direction difference at the start and end of a segment.default booleancheckLoopBack(Double prevDirection, Double nextDirection) Check for a direction change of more than 90 degrees.Flatten a Curve2d into a PolyLine2d.Methods inherited from interface org.djutils.draw.curve.Flattener
checkInflectionPoint, checkPositionError, loadKnot, loadKnots
-
Method Details
-
flatten
Flatten a Curve2d into a PolyLine2d.- Parameters:
curve- the curve- Returns:
- flattened line
- Throws:
NullPointerException- whencurveisnull
-
checkLoopBack
Description copied from interface:FlattenerCheck for a direction change of more than 90 degrees. If that happens, the MaxDeviation flattener must zoom in closer.- Specified by:
checkLoopBackin interfaceFlattener<Flattener2d,Curve2d, PolyLine2d, Point2d, Double> - Parameters:
prevDirection- the direction at the preceding (already added) pointnextDirection- the direction at the succeeding (already added) point- Returns:
trueif the curve changes direction by more than 90 degrees;falseif 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:FlattenerCheck direction difference at the start and end of a segment.- Specified by:
checkDirectionErrorin interfaceFlattener<Flattener2d,Curve2d, PolyLine2d, Point2d, Double> - 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:
trueif the direction difference at the start and the end of the segment is smaller thanmaxDirectionDeviation;falseif the direction difference at the start, or the end of the segment equals or exceedsmaxDirectionDeviation
-