Package org.djutils.draw.curve
Interface Flattener3d
- All Superinterfaces:
Flattener<Flattener3d,
Curve3d, PolyLine3d, Point3d, Direction3d>
- All Known Implementing Classes:
Flattener3d.MaxAngle
,Flattener3d.MaxDeviation
,Flattener3d.MaxDeviationAndAngle
,Flattener3d.NumSegments
Flattens a Curve3d in to a PolyLine3d.
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 theCurve3d
and thePolyLine3d
.static class
Flattener that limits the distance between theCurve3d
and thePolyLine3d
.static class
Flattener that limits the distance and angle difference between theCurve3d
and thePolyLine3d
.static class
Flattener that approximates theCurve3d
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
(Direction3d segmentDirection, Direction3d curveDirectionAtStart, Direction3d curveDirectionAtEnd, double maxDirectionDeviation) Check direction difference at the start and end of a segment.default boolean
checkInflectionPoint
(Flattener.FlattableCurve<Point3d, Direction3d> curve, double prevT, double medianT, double nextT, Point3d prevPoint, Point3d nextPoint) Check for an inflection point by computing additional points at one quarter and three quarters.default boolean
checkLoopBack
(Direction3d prevDirection, Direction3d nextDirection) Check for a direction change of more than 90 degrees.Flatten a Curve3d into a PolyLine3d.Methods inherited from interface org.djutils.draw.curve.Flattener
checkPositionError, loadKnot, loadKnots
-
Method Details
-
flatten
Flatten a Curve3d into a PolyLine3d.- Parameters:
curve
- the curve- Returns:
- flattened line
- Throws:
NullPointerException
- whencurve
isnull
-
checkInflectionPoint
default boolean checkInflectionPoint(Flattener.FlattableCurve<Point3d, Direction3d> curve, double prevT, double medianT, double nextT, Point3d prevPoint, Point3d nextPoint) Description copied from interface:Flattener
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- Specified by:
checkInflectionPoint
in interfaceFlattener<Flattener3d,
Curve3d, PolyLine3d, Point3d, Direction3d> - 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
-
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<Flattener3d,
Curve3d, PolyLine3d, Point3d, Direction3d> - 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(Direction3d segmentDirection, Direction3d curveDirectionAtStart, Direction3d curveDirectionAtEnd, double maxDirectionDeviation) Description copied from interface:Flattener
Check direction difference at the start and end of a segment.- Specified by:
checkDirectionError
in interfaceFlattener<Flattener3d,
Curve3d, PolyLine3d, Point3d, Direction3d> - 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
-