Clothoid¶
- class pyclothoids.Clothoid(clothoid_curve)¶
An object representing a single clothoid curve. Pickling and unpickling is supported. The class constructor is meant for internal use for interfacing with the C++ layer. To initialize a Clothoid, use one of the classmethods instead.
- classmethod StandardParams(x0, y0, t0, k0, kd, s_f)¶
A method to initialize a Clothoid given a starting point, starting tangent, starting curvature, curvature rate, and final length.
- classmethod G1Hermite(x0, y0, t0, x1, y1, t1, tol=1e-10)¶
A method to numerically compute the solution to the G1 Hermite interpolation problem and initialize a Clothoid object with the solution parameters.
- classmethod Forward(x0, y0, t0, k0, x1, y1, tol=1e-10)¶
A method to numerically compute the solution to the forward problem given a starting point, starting tangent, starting curvature, and final point and initialize a Clothoid object with the solution parameters.
- Parameters¶
Complete data describing the calling Clothoid
- Getter
Returns the initialization parameters of a clothoid, fit to be used as args to StandardParams
- Setter
Parameters cannot be modified
- Type
tuple
- length¶
The total arc length of the Clothoid
- Getter
Returns the arc length of the clothoid
- Setter
Arc length cannot be modified
- Type
float
- dk¶
The curvature rate of the Clothoid
- Getter
Returns the curvature rate of the clothoid
- Setter
Curvature rate cannot be modified
- Type
float
- XStart¶
The X coordinate of the Clothoid at its starting point
- Getter
Returns the initial X coordinate of the clothoid
- Setter
Initial X coordinate cannot be modified
- Type
float
- XEnd¶
The X coordinate of the Clothoid at its end point
- Getter
Returns the final X coordinate of the clothoid
- Setter
Final X coordinate cannot be modified
- Type
float
- YStart¶
The Y coordinate of the Clothoid at its starting point
- Getter
Returns the initial Y coordinate of the clothoid
- Setter
Initial Y coordinate cannot be modified
- Type
float
- YEnd¶
The Y coordinate of the Clothoid at its end point
- Getter
Returns the final Y coordinate of the clothoid
- Setter
Final Y coordinate cannot be modified
- Type
float
- ThetaStart¶
The tangent angle of the Clothoid at its starting point
- Getter
Returns the initial tangent angle of the clothoid in radians
- Setter
Initial angle cannot be modified
- Type
float
- ThetaEnd¶
The tangent angle of the Clothoid at its end point
- Getter
Returns the final tangent angle of the clothoid in radians
- Setter
Final angle cannot be modified
- Type
float
- KappaStart¶
The curvature of the Clothoid at its starting point
- Getter
Returns the initial curvature of the clothoid
- Setter
Initial curvature cannot be modified
- Type
float
- KappaEnd¶
The curvature of the Clothoid at its end point
- Getter
Returns the final curvature of the clothoid
- Setter
Final curvature cannot be modified
- Type
float
- X(s)¶
Returns the X coordinate of the clothoid at arc length s from the initial point
- XD(s)¶
Returns the derivative of the X coordinate of the clothoid at arc length s from the initial point
- XDD(s)¶
Returns the second derivative of the X coordinate of the clothoid at arc length s from the initial point
- XDDD(s)¶
Returns the third derivative of the X coordinate of the clothoid at arc length s from the initial point
- Y(s)¶
Returns the Y coordinate of the clothoid at arc length s from the initial point
- YD(s)¶
Returns the derivative of the Y coordinate of the clothoid at arc length s from the initial point
- YDD(s)¶
Returns the second derivative of the Y coordinate of the clothoid at arc length s from the initial point
- YDDD(s)¶
Returns the third derivative of the Y coordinate of the clothoid at arc length s from the initial point
- Theta(s)¶
Returns the tangent angle of the clothoid at arc length s from the initial point
- ThetaD(s)¶
Returns the derivative of the tangent angle of the clothoid at arc length s from the initial point
- ThetaDD(s)¶
Returns the second derivative of the tangent angle of the clothoid at arc length s from the initial point
- ThetaDDD(s)¶
Returns the third derivative of the tangent angle of the clothoid at arc length s from the initial point
- SampleXY(npts)¶
A method to return a vector of X coordinates and Y coordinates generated by evaluating the Clothoid at npts equally spaced points along its length.
Roughly shorthand for:
def SampleXY(self,npts): sample_points = [self.length * m/(npts-1) for m in range(0,npts)] X = [self.X(i) for i in sample_points] Y = [self.Y(i) for i in sample_points] return [X,Y]
- Scale(sfactor, center=(0, 0))¶
Returns a copy of the calling clothoid subjected to a scaling transform with a scale of sfactor and a stationary point at center
- Translate(xoff, yoff)¶
Returns a copy of the calling clothoid subjected to a pure translation transform described by a vector (xoff,yoff)
- Rotate(angle, center=(0, 0))¶
Returns a copy of the calling clothoid subjected to a pure rotation transform of angle and a stationary point at center
- Flip(axis='y')¶
Returns a copy of the calling clothoid that has been flipped symmetrically along a specified axis
currently supported options are:
‘y’
‘x’
‘start’
Where ‘start’ represents a line tangent to the clothoid at its starting point.
- Reverse()¶
Returns a copy of the calling clothoid with the direction of the arc length parameter reversed
- Trim(s_begin, s_end)¶
Returns a copy of the subsection of the calling clothoid that lies between s_begin and s_end
- ClosestPoint(X, Y)¶
Returns a tuple containing the cartesian coordinates of the point on the clothoid which is closest to the point defined by the X and Y input arguments.
This method calls the ProjectPointOntoClothoid method and returns only the coordinate return values
- ClosestPointArcLength(X, Y)¶
Returns the arc length along the clothoid associated with the point on the clothoid which is closest to the point defined by the X and Y input arguments.
This method calls the ProjectPointOntoClothoid method and returns only the arc length return value
- Distance(X, Y)¶
Returns the minimum distance between a given point and the clothoid.
This method calls the ProjectPointOntoClothoid method and returns only the distance return value
- IntersectionPoints(other)¶
Returns a list of tuples. Each tuple contains the X and Y cartesian coordinates near which the two clothoids intersect. Approximations are computed using the calling clothoid and will likely differ slightly if computed using the other clothoid.
- IntersectionArcLengths(other)¶
Returns a list of tuples. Each tuple contains a pair of clothoid arc length parameters near which an intersection occurs. The first parameter is the distance along the calling clothoid (self) at which the intersection occurs, and the second parameter is the distance along the argument clothoid (other).
Note that due to the numerical methods and iterative approximation methods involved, the floating point coordinates of the intersection point on the first clothoid will not exactly coincide with the coordinates of the intersection point on the second clothoid. However we expect this error be extremely small.
- SetupProjectionCache(cachesize)¶
By default, each instance of the Clothoid object maintains an lru cache of the results from projecting any point onto the clothoid. This is because the projection operation calculates several potentially useful quantities all at once, such as projection distance and the coordinates of the projected point. Caching the results means that users can call ClosestPoint and Distance separately and sequentially without recomputing the projection. The default cachesize is set to 32 but this method allows configuring the cache with a custom size. Pass cachesize = None to disable caching entirely.
- ProjectPointOntoClothoid(X, Y)¶
Calculates the minimum-distance projection of a given point onto the clothoid.
Returns a tuple containing the closest point coordinates, the arc length along the clothoid where the closest point lies, and the distance between the given point and the projected point on the clothoid.
This method is called by the ClosestPoint, ClosestPointArcLength, and Distance methods. Because the Clothoid object is immutable, we wrap this method in an LRU cache on object construction to save outputs of recently used input points.
This allows a user to call Distance and ClosestPoint separately with the same input point for code readability without recomputing the underlying projection.