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 class
Flattener that limits the angle difference between theCurve2d
and thePolyLine2d
.static class
Flattener that limits the distance between theCurve2d
and thePolyLine2d
.static class
Flattener that limits the distance and angle difference between theCurve2d
and thePolyLine2d
.static class
Flattener that approximates theCurve2d
with 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 boolean
checkDirectionError
(Double segmentDirection, Double curveDirectionAtStart, Double curveDirectionAtEnd, double maxDirectionDeviation) Check direction difference at the start and end of a segment.default boolean
checkLoopBack
(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
- whencurve
isnull
-
checkLoopBack
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 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:
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 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:
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
-