Method GetDistanceToInterpolation
GetDistanceToInterpolation(BezierCurve, float)
Gets the normalized interpolation, (t), that corresponds to a distance on a BezierCurve.
Declaration
public static float GetDistanceToInterpolation(BezierCurve curve, float distance)
Parameters
Type | Name | Description |
---|---|---|
BezierCurve | curve | The BezierCurve to calculate the distance to interpolation ratio for. |
float | distance | The curve-relative distance to convert to an interpolation ratio (also referred to as 't'). |
Returns
Type | Description |
---|---|
float | Returns the normalized interpolation ratio associated to distance on the designated curve. |
Remarks
It is inefficient to call this method frequently. For better performance create a DistanceToInterpolation cache with CalculateCurveLengths(BezierCurve, DistanceToInterpolation[]) and use the overload of this method which accepts a lookup table.
GetDistanceToInterpolation<T>(T, float)
Return the normalized interpolation (t) corresponding to a distance on a BezierCurve. This method accepts a look-up table (referred to in code with acronym "LUT") that may be constructed using CalculateCurveLengths(BezierCurve, DistanceToInterpolation[]). The built-in Spline class implementations (Spline and NativeSpline) cache these look-up tables internally.
Declaration
public static float GetDistanceToInterpolation<T>(T lut, float distance) where T : IReadOnlyList<DistanceToInterpolation>
Parameters
Type | Name | Description |
---|---|---|
T | lut | A look-up table of distance to 't' values. See CalculateCurveLengths(BezierCurve, DistanceToInterpolation[]) for creating this collection. |
float | distance | The curve-relative distance to convert to an interpolation ratio (also referred to as 't'). |
Returns
Type | Description |
---|---|
float | The normalized interpolation ratio associated to distance on the designated curve. |
Type Parameters
Name | Description |
---|---|
T | The collection type. |