Package org.djutils.draw.curve
Class Clothoid2d
java.lang.Object
org.djutils.draw.curve.Clothoid2d
- All Implemented Interfaces:
Curve<DirectedPoint2d,,Double, Point2d, Flattener2d, PolyLine2d> Curve2d,Flattener.FlattableCurve<Point2d,,Double> OffsetCurve2d
Continuous definition of a clothoid in 2d. The following definitions are available:
- A clothoid between two
DirectedPoint2ds. - A clothoid originating from a
DirectedPoint2dwith start curvature, end curvature, andlengthspecified. - A clothoid originating from a
DirectedPoint2dwith start curvature, end curvature, andA-valuespecified.
- Dale Connor and Lilia Krivodonova (2014) "Interpolation of two-dimensional curves with Euler spirals", Journal of Computational and Applied Mathematics, Volume 261, 1 May 2014, pp. 320-332.
- D.J. Waltona and D.S. Meek (2009) "G1 interpolation with a single Cornu spiral segment", Journal of Computational and Applied Mathematics, Volume 223, Issue 1, 1 January 2009, pp. 86-96.
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.
-
Constructor Summary
ConstructorsConstructorDescriptionClothoid2d(DirectedPoint2d startPoint, double a, double startCurvature, double endCurvature) Create clothoid from one point based on curvature and A-value.Clothoid2d(DirectedPoint2d startPoint, DirectedPoint2d endPoint) Create clothoid between two directed points. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetA()Return A, the clothoid scaling parameter.Returns whether the shape was applied as a Clothoid, an Arc, or as a Straight, depending on start and end position and direction.getDirection(double fraction) Returns the direction at the given fraction.doublegetDirection(double fraction, ContinuousPiecewiseLinearFunction of) Returns the direction at the given fraction.doubleEnd curvature of this Clothoid.End point of this Curve.doubleEnd radius of this Clothoid.doubleReturn the length of this Curve.getPoint(double fraction) Returns the point at the given fraction of this Curve.getPoint(double fraction, ContinuousPiecewiseLinearFunction of) Returns the point at the given fraction.doubleStart curvature of this Clothoid.Start point of this Curve.doubleStart radius of this Clothoid.toPolyLine(Flattener2d flattener) Flatten a Curve into a PolyLine.toPolyLine(OffsetFlattener2d flattener, ContinuousPiecewiseLinearFunction offsets) Flatten a Curve2d while offsetting with the provided continuous offset into a PolyLine2d.toString()static Clothoid2dwithLength(DirectedPoint2d startPoint, double length, double startCurvature, double endCurvature) Create clothoid from one point based on curvature and length.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.draw.curve.Curve2d
getEndDirection, getStartDirectionMethods inherited from interface org.djutils.draw.curve.OffsetCurve2d
getT
-
Constructor Details
-
Clothoid2d
Create clothoid between two directed points. This constructor is based on the procedure in:
Dale Connor and Lilia Krivodonova (2014) "Interpolation of two-dimensional curves with Euler spirals", Journal of Computational and Applied Mathematics, Volume 261, 1 May 2014, pp. 320-332.
Which applies the theory proven in:
D.J. Waltona and D.S. Meek (2009) "G1 interpolation with a single Cornu spiral segment", Journal of Computational and Applied Mathematics, Volume 223, Issue 1, 1 January 2009, pp. 86-96.
This procedure guarantees that the resulting line has the minimal angle rotation that is required to connect the points. If the points approximate a straight line or circle, with a tolerance of up 1/10th of a degree, those respective lines are created. The numerical approximation of the underlying Fresnel integral is different from the paper. SeeClothoid.fresnel().- Parameters:
startPoint- start pointendPoint- end point- Throws:
NullPointerException- whenstartPoint, orendPointisnull- See Also:
-
Clothoid2d
Create clothoid from one point based on curvature and A-value.- Parameters:
startPoint- start pointa- A-valuestartCurvature- start curvatureendCurvature- end curvature- Throws:
NullPointerException- whenstartPointisnullIllegalArgumentException- whena ≤ 0.0
-
-
Method Details
-
withLength
public static Clothoid2d withLength(DirectedPoint2d startPoint, double length, double startCurvature, double endCurvature) Create clothoid from one point based on curvature and length. This method calculates the A-value as sqrt(L/|k2-k1|), where L is the length of the resulting clothoid, and k2 and k1 are the end and start curvature.- Parameters:
startPoint- start point.length- Length of the resulting clothoid.startCurvature- start curvature.endCurvature- end curvature- Returns:
- clothoid based on curvature and length.
- Throws:
NullPointerException- whenstartPointisnullIllegalArgumentException- whenlength ≤ 0.0
-
getStartPoint
Description copied from interface:CurveStart point of this Curve.- Specified by:
getStartPointin interfaceCurve<DirectedPoint2d,Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getStartPointin interfaceCurve2d- Returns:
- start point of this Curve
-
getEndPoint
Description copied from interface:CurveEnd point of this Curve.- Specified by:
getEndPointin interfaceCurve<DirectedPoint2d,Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getEndPointin interfaceCurve2d- Returns:
- end point of this Curve
-
getStartCurvature
public double getStartCurvature()Start curvature of this Clothoid.- Returns:
- start curvature of this Clothoid
-
getEndCurvature
public double getEndCurvature()End curvature of this Clothoid.- Returns:
- end curvature of this Clothoid
-
getStartRadius
public double getStartRadius()Start radius of this Clothoid.- Returns:
- start radius of this Clothoid
-
getEndRadius
public double getEndRadius()End radius of this Clothoid.- Returns:
- end radius of this Clothoid
-
getA
public double getA()Return A, the clothoid scaling parameter.- Returns:
- a, the clothoid scaling parameter.
-
getPoint
Description copied from interface:CurveReturns the point at the given fraction of this Curve. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length.- Specified by:
getPointin interfaceCurve<DirectedPoint2d,Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getPointin interfaceFlattener.FlattableCurve<Point2d,Double> - Parameters:
fraction- the fraction- Returns:
- the point at the given
fraction
-
getPoint
Description copied from interface:OffsetCurve2dReturns the point at the given fraction. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length.- Specified by:
getPointin interfaceOffsetCurve2d- Parameters:
fraction- the fractionof- provides fraction-dependent lateral offset to the point- Returns:
- the point at the given
fraction
-
getDirection
Description copied from interface:CurveReturns the direction at the given fraction. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length. The default implementation performs a numerical approach by looking at the direction between the points at fraction, and a point 1e-6 away.- Specified by:
getDirectionin interfaceCurve<DirectedPoint2d,Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getDirectionin interfaceCurve2d- Specified by:
getDirectionin interfaceFlattener.FlattableCurve<Point2d,Double> - Parameters:
fraction- the fraction- Returns:
- the direction at the given
fraction
-
getDirection
Description copied from interface:OffsetCurve2dReturns the direction at the given fraction. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length. The default implementation performs a numerical approach by looking at the direction between the points at fraction, and a point 1e-6 away.- Specified by:
getDirectionin interfaceOffsetCurve2d- Parameters:
fraction- the fractionof- provides fraction-dependent lateral offset to the curve- Returns:
- the direction at the given
fraction
-
toPolyLine
Description copied from interface:CurveFlatten a Curve into a PolyLine. Implementations should use the flattener when relevant and possible.- Specified by:
toPolyLinein interfaceCurve<DirectedPoint2d,Double, Point2d, Flattener2d, PolyLine2d> - Parameters:
flattener- the flattener- Returns:
- approximation of this
Curveas aPolyLine
-
toPolyLine
public PolyLine2d toPolyLine(OffsetFlattener2d flattener, ContinuousPiecewiseLinearFunction offsets) Description copied from interface:OffsetCurve2dFlatten a Curve2d while offsetting with the provided continuous offset into a PolyLine2d. Implementations should use the flattener when relevant and possible.- Specified by:
toPolyLinein interfaceOffsetCurve2d- Parameters:
flattener- OffsetFlatteneroffsets- offset data- Returns:
- approximation of this
curve2dwith offset as aPolyLine2d
-
getLength
public double getLength()Description copied from interface:CurveReturn the length of this Curve.- Specified by:
getLengthin interfaceCurve<DirectedPoint2d,Double, Point2d, Flattener2d, PolyLine2d> - Returns:
- length of this Curve
-
getAppliedShape
Returns whether the shape was applied as a Clothoid, an Arc, or as a Straight, depending on start and end position and direction.- Returns:
- "Clothoid", "Arc" or "Straight"
-
toString
-