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 classFlattener that limits the angle difference between theCurve3dand thePolyLine3d.static classFlattener that limits the distance between theCurve3dand thePolyLine3d.static classFlattener that limits the distance and angle difference between theCurve3dand thePolyLine3d.static classFlattener that approximates theCurve3dwith 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(Direction3d segmentDirection, Direction3d curveDirectionAtStart, Direction3d curveDirectionAtEnd, double maxDirectionDeviation) Check direction difference at the start and end of a segment.default booleancheckInflectionPoint(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 booleancheckLoopBack(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- whencurveisnull
-
checkInflectionPoint
default boolean checkInflectionPoint(Flattener.FlattableCurve<Point3d, Direction3d> curve, double prevT, double medianT, double nextT, Point3d prevPoint, Point3d nextPoint) Description copied from interface:FlattenerCheck 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:
checkInflectionPointin 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 oncurveatprevTnextPoint- point oncurveatnextT- Returns:
trueif there is an inflection point betweenprevTandnextT;falseif there is no inflection point betweenprevTandnextT
-
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<Flattener3d,Curve3d, PolyLine3d, Point3d, Direction3d> - 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(Direction3d segmentDirection, Direction3d curveDirectionAtStart, Direction3d curveDirectionAtEnd, double maxDirectionDeviation) Description copied from interface:FlattenerCheck direction difference at the start and end of a segment.- Specified by:
checkDirectionErrorin 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:
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
-