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
DirectedPoint2d
s. - A clothoid originating from a
DirectedPoint2d
with start curvature, end curvature, andlength
specified. - A clothoid originating from a
DirectedPoint2d
with start curvature, end curvature, andA-value
specified.
- 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 TypeMethodDescriptiondouble
getA()
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.double
End curvature of this Clothoid.End point of this Curve.double
End radius of this Clothoid.double
Return 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.double
Start curvature of this Clothoid.Start point of this Curve.double
Start 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 Clothoid2d
withLength
(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, wait
Methods inherited from interface org.djutils.draw.curve.Curve2d
getEndDirection, getStartDirection
Methods inherited from interface org.djutils.draw.curve.OffsetCurve2d
getDirection, 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
, orendPoint
isnull
- 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
- whenstartPoint
isnull
IllegalArgumentException
- 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
- whenstartPoint
isnull
IllegalArgumentException
- whenlength ≤ 0.0
-
getStartPoint
Description copied from interface:Curve
Start point of this Curve.- Specified by:
getStartPoint
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getStartPoint
in interfaceCurve2d
- Returns:
- start point of this Curve
-
getEndPoint
Description copied from interface:Curve
End point of this Curve.- Specified by:
getEndPoint
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getEndPoint
in 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:Curve
Returns 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:
getPoint
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getPoint
in interfaceFlattener.FlattableCurve<Point2d,
Double> - Parameters:
fraction
- the fraction- Returns:
- the point at the given
fraction
-
getPoint
Description copied from interface:OffsetCurve2d
Returns 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:
getPoint
in 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:Curve
Returns 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:
getDirection
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getDirection
in interfaceCurve2d
- Specified by:
getDirection
in interfaceFlattener.FlattableCurve<Point2d,
Double> - Parameters:
fraction
- the fraction- Returns:
- the direction at the given
fraction
-
toPolyLine
Description copied from interface:Curve
Flatten a Curve into a PolyLine. Implementations should use the flattener when relevant and possible.- Specified by:
toPolyLine
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Parameters:
flattener
- the flattener- Returns:
- approximation of this
Curve
as aPolyLine
-
toPolyLine
public PolyLine2d toPolyLine(OffsetFlattener2d flattener, ContinuousPiecewiseLinearFunction offsets) Description copied from interface:OffsetCurve2d
Flatten a Curve2d while offsetting with the provided continuous offset into a PolyLine2d. Implementations should use the flattener when relevant and possible.- Specified by:
toPolyLine
in interfaceOffsetCurve2d
- Parameters:
flattener
- OffsetFlatteneroffsets
- offset data- Returns:
- approximation of this
curve2d
with offset as aPolyLine2d
-
getLength
public double getLength()Description copied from interface:Curve
Return the length of this Curve.- Specified by:
getLength
in 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
-