Class Spline
A spline class to provide infinitesimal pose information on a path defined by discrete positions.
Namespace: Holoride.ElasticSDK
Assembly: Holoride.ElasticSDK.Library.Runtime.dll
Syntax
[Serializable]
public class Spline
Constructors
Spline(IReadOnlyList<GeoCoordinate>, int, float, GeoCoordinate?)
Initializes a new instance of the Spline class, prepares distance lookup table and performs filter operations.
Declaration
public Spline(IReadOnlyList<GeoCoordinate> geoCoordinates, int distanceSamplesPerInterval = 10, float controlPointRatio = 0.3, GeoCoordinate? pivot = null)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<GeoCoordinate> | geoCoordinates | A list of geoCoordinates to align a spline to. |
int | distanceSamplesPerInterval | The number of samples per interval to add to the distance lookup-table. The value implies a trade-off between precision and cpu/memory consumption. |
float | controlPointRatio | Controls spline smoothing. 0 = tight, 1 = smooth. |
GeoCoordinate? | pivot | The pivot to use when interpreting the provided coordinates. |
Spline(List<GlobalPosition>, int, float)
Initializes a new instance of the Spline class, prepares distance lookup table and performs filter operations.
Declaration
public Spline(List<GlobalPosition> positions, int distanceSamplesPerInterval = 10, float controlPointRatio = 0.3)
Parameters
Type | Name | Description |
---|---|---|
List<GlobalPosition> | positions | A list of positions to align a spline to. |
int | distanceSamplesPerInterval | The number of samples per interval to add to the distance lookup-table. The value implies a trade-off between precision and cpu/memory consumption. |
float | controlPointRatio | Controls spline smoothing. 0 = tight, 1 = smooth. |
Fields
Pivot
The Pivot this Spline was created with.
Declaration
public GeoCoordinate Pivot
Field Value
Type | Description |
---|---|
GeoCoordinate |
Properties
Length
Gets the length of the spline.
Declaration
public double Length { get; }
Property Value
Type | Description |
---|---|
double |
SupportPointCount
Gets the number of positions to define the spline.
Declaration
public int SupportPointCount { get; }
Property Value
Type | Description |
---|---|
int |
Methods
FindClosestDistance(GlobalPosition, double, RouteSegments)
Finds the spline distance of the closest point to a given search position.
Declaration
public double FindClosestDistance(GlobalPosition searchPosition, double stepDistance, RouteSegments searchRouteSegments = null)
Parameters
Type | Name | Description |
---|---|---|
GlobalPosition | searchPosition | The position to search the closest distance. |
double | stepDistance | The step distance. A smaller distance increases computation effort. |
RouteSegments | searchRouteSegments | The optional interval to search within. |
Returns
Type | Description |
---|---|
double | The distance of the spline point closest to the search position. |
FindClosestPoseOnSpline(GlobalPosition, double, RouteSegments)
Finds the closest position on a spline to a given search position.
Declaration
public GlobalPose FindClosestPoseOnSpline(GlobalPosition searchPosition, double stepDistance, RouteSegments searchRouteSegments = null)
Parameters
Type | Name | Description |
---|---|---|
GlobalPosition | searchPosition | The position to search. |
double | stepDistance | The step distance. A smaller distance increases computation effort. |
RouteSegments | searchRouteSegments | The optional interval to search within. |
Returns
Type | Description |
---|---|
GlobalPose | The closest pose on the spline. |
FindClosestPositionOnSupportLines(GlobalPosition, out double)
Finds the closest position between support points.
Declaration
public GlobalPosition FindClosestPositionOnSupportLines(GlobalPosition searchPosition, out double sqrDistance)
Parameters
Type | Name | Description |
---|---|---|
GlobalPosition | searchPosition | The position to search the closest distance for. |
double | sqrDistance | The minimum squared distance found. |
Returns
Type | Description |
---|---|
GlobalPosition | The closest position. |
FindClosestRatio(GlobalPosition, double, RouteSegments)
Finds the closest spline ratio to a given search position.
Declaration
public double FindClosestRatio(GlobalPosition searchPosition, double stepDistance, RouteSegments searchRouteSegments = null)
Parameters
Type | Name | Description |
---|---|---|
GlobalPosition | searchPosition | The position to search the closest distance. |
double | stepDistance | The step distance. A smaller distance increases computation effort. |
RouteSegments | searchRouteSegments | The optional interval to search within. |
Returns
Type | Description |
---|---|
double | The computed spline ratio. |
ForEachSupportPosition(Action<GlobalPosition, double>)
Calls an action for each support position.
Declaration
public void ForEachSupportPosition(Action<GlobalPosition, double> action)
Parameters
Type | Name | Description |
---|---|---|
Action<GlobalPosition, double> | action | The action to call. Contains the position and the distance on the spline. |
GenerateSimplifiedSplineByRadius(double)
Generates a simplified spline based on this spline.
Declaration
public Spline GenerateSimplifiedSplineByRadius(double supportRadius)
Parameters
Type | Name | Description |
---|---|---|
double | supportRadius | Defines the distance between the generated support positions. |
Returns
Type | Description |
---|---|
Spline | The simplified spline. |
GetCurvatureAtDistance(double, double)
Gets the curvature at a specified distance.
Declaration
public Vector3 GetCurvatureAtDistance(double distance, double curvatureDistanceDelta)
Parameters
Type | Name | Description |
---|---|---|
double | distance | The distance. |
double | curvatureDistanceDelta | The curvature distance delta. |
Returns
Type | Description |
---|---|
Vector3 | The curvature of the spline. |
GetDistanceAtIndex(double)
Looks up the distance at a given index.
Declaration
public double GetDistanceAtIndex(double index)
Parameters
Type | Name | Description |
---|---|---|
double | index | The index where to look at. |
Returns
Type | Description |
---|---|
double | The computed distance on the spline. |
GetDistanceAtRatio(double)
Looks up the distance at a given ratio.
Declaration
public double GetDistanceAtRatio(double ratio)
Parameters
Type | Name | Description |
---|---|---|
double | ratio | The ratio where to look at. |
Returns
Type | Description |
---|---|
double | The computed distance on the spline. |
GetDistanceAtSupportPoint(int)
Looks up the distance at a given support point index.
Declaration
public double GetDistanceAtSupportPoint(int supportPointNumber)
Parameters
Type | Name | Description |
---|---|---|
int | supportPointNumber | The support point number where to look at. |
Returns
Type | Description |
---|---|
double | The computed distance on the spline. |
GetIndexAtDistance(double)
Gets the index at a specific distance.
Declaration
public double GetIndexAtDistance(double distance)
Parameters
Type | Name | Description |
---|---|---|
double | distance | The distance. |
Returns
Type | Description |
---|---|
double | The computed spline index. |
GetIndexAtRatio(double)
Looks up the index at a given ratio.
Declaration
public double GetIndexAtRatio(double ratio)
Parameters
Type | Name | Description |
---|---|---|
double | ratio | The ratio where to look at. |
Returns
Type | Description |
---|---|
double | The computed index on the spline. |
GetRatioAtDistance(double)
Gets the ratio at a specific distance.
Declaration
public double GetRatioAtDistance(double distance)
Parameters
Type | Name | Description |
---|---|---|
double | distance | The distance. |
Returns
Type | Description |
---|---|
double | The computed spline ratio. |
GetRatioAtIndex(double)
Looks up the ratio at a given index.
Declaration
public double GetRatioAtIndex(double index)
Parameters
Type | Name | Description |
---|---|---|
double | index | The index where to look at. |
Returns
Type | Description |
---|---|
double | The computed ratio on the spline. |
GetSupportPosition(int)
Returns a support position at a given index.
Declaration
public GlobalPosition GetSupportPosition(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the support position to return. |
Returns
Type | Description |
---|---|
GlobalPosition | The support position at the given index. |
ProjectRatioFromReferenceSpline(Spline, double, double)
Computes the ratio of the position with the closest distance to the result of sampling a reference spline at a given ratio. This method is referred to as ratio projection.
Declaration
public double ProjectRatioFromReferenceSpline(Spline referenceSpline, double ratio, double errorMargin)
Parameters
Type | Name | Description |
---|---|---|
Spline | referenceSpline | The reference spline. |
double | ratio | The ratio to project. |
double | errorMargin | The error margin. Beyond the margin distance, the result is precisely computed. A smaller margin increases computation effort. |
Returns
Type | Description |
---|---|
double | The projected ratio. |
SampleAtDistance(double, bool)
Samples the spline at a specific distance.
Declaration
public GlobalPose SampleAtDistance(double distance, bool oppositeDirection = false)
Parameters
Type | Name | Description |
---|---|---|
double | distance | The distance in units where to sample the spline. |
bool | oppositeDirection | States whether to return a pose in the opposite direction. |
Returns
Type | Description |
---|---|
GlobalPose | The doublePose (translation and rotation along the tangent) at the defined distance. |
SampleAtDistance(double, out double, bool)
Samples the spline at a specific distance.
Declaration
public GlobalPose SampleAtDistance(double distance, out double controlPointIndex, bool oppositeDirection = false)
Parameters
Type | Name | Description |
---|---|---|
double | distance | The distance in units where to sample the spline. |
double | controlPointIndex | The optional output of the interpolated control point index at the given distance. |
bool | oppositeDirection | States whether to return a pose in the opposite direction. |
Returns
Type | Description |
---|---|
GlobalPose | The doublePose (translation and rotation along the tangent) at the defined distance. |
SampleAtIndex(double, bool)
Samples the hermite spline at a specific index.
Declaration
public GlobalPose SampleAtIndex(double sampleIndex, bool oppositeDirection = false)
Parameters
Type | Name | Description |
---|---|---|
double | sampleIndex | The index between 0.0 and 1.0 where to sample the spline. |
bool | oppositeDirection | States whether to return a pose in the opposite direction. |
Returns
Type | Description |
---|---|
GlobalPose | The doublePose (translation and rotation aligned with the tangent) at the given index. |
SampleAtRatio(double, bool)
Samples the hermite spline at a specific ratio.
Declaration
public GlobalPose SampleAtRatio(double sampleRatio, bool oppositeDirection = false)
Parameters
Type | Name | Description |
---|---|---|
double | sampleRatio | The ratio between 0.0 and 1.0 where to sample the spline. |
bool | oppositeDirection | States whether to return a pose in the opposite direction. |
Returns
Type | Description |
---|---|
GlobalPose | The double precision pose (translation and rotation aligned with the tangent) at the given ratio. |
SamplePositionAtIndex(double)
Samples the hermite spline at a specific index.
Declaration
public GlobalPosition SamplePositionAtIndex(double sampleIndex)
Parameters
Type | Name | Description |
---|---|---|
double | sampleIndex | The index between 0.0 and 1.0 where to sample the spline. |
Returns
Type | Description |
---|---|
GlobalPosition | The position at the given index. |
Scale(double)
Scales the spline by a given factor.
Declaration
public void Scale(double factor)
Parameters
Type | Name | Description |
---|---|---|
double | factor | The factor to scale the spline with. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |