Class SplineMath
Assorted utility functions for math equations commonly used when working with Splines.
Inherited Members
Namespace: UnityEngine.Splines
Assembly: Unity.Splines.dll
Syntax
public static class SplineMath
Methods
DistancePointLine(float3, float3, float3)
Gets the distance from a point to a line segment.
Declaration
public static float DistancePointLine(float3 p, float3 a, float3 b)
Parameters
Type | Name | Description |
---|---|---|
float3 | p | The point to compare against. |
float3 | a | The start point of the line segment. |
float3 | b | The end point of the line segment. |
Returns
Type | Description |
---|---|
float | Returns the distance of the closest line from a point to a line segment. |
PointLineNearestPoint(float3, float3, float3, out float)
Returns the nearest point on a finite line segment to a point.
Declaration
public static float3 PointLineNearestPoint(float3 p, float3 a, float3 b, out float lineParam)
Parameters
Type | Name | Description |
---|---|---|
float3 | p | The point to compare to. |
float3 | a | The line start point. |
float3 | b | The line end point. |
float | lineParam | The signed distance between point 'a' and the projection of point 'p' on the line segment. |
Returns
Type | Description |
---|---|
float3 | The nearest point on a line segment to another point. |
RayLineDistance(float3, float3, float3, float3)
Returns the shortest distance between a ray and line segment as a direction and magnitude.
Declaration
public static float3 RayLineDistance(float3 ro, float3 rd, float3 a, float3 b)
Parameters
Type | Name | Description |
---|---|---|
float3 | ro | The ray origin point. |
float3 | rd | The ray direction (normalized vector). |
float3 | a | The line start point. |
float3 | b | The line end point. |
Returns
Type | Description |
---|---|
float3 | Returns the shortest distance between a ray and line segment as a direction and magnitude. |
RayLineNearestPoint(float3, float3, float3, float3)
Returns the nearest points between a ray and line segment.
Declaration
public static (float3 rayPoint, float3 linePoint) RayLineNearestPoint(float3 ro, float3 rd, float3 a, float3 b)
Parameters
Type | Name | Description |
---|---|---|
float3 | ro | The ray origin point. |
float3 | rd | The ray direction (normalized vector). |
float3 | a | The line start point. |
float3 | b | The line end point. |
Returns
Type | Description |
---|---|
(float3 rayPoint, float3 linePoint) | Returns the nearest points between a ray and line segment. |
RayLineNearestPoint(float3, float3, float3, float3, out float, out float)
Returns the nearest points on a ray and a line segment to one another.
Declaration
public static (float3 rayPoint, float3 linePoint) RayLineNearestPoint(float3 ro, float3 rd, float3 a, float3 b, out float rayParam, out float lineParam)
Parameters
Type | Name | Description |
---|---|---|
float3 | ro | The ray origin point. |
float3 | rd | The ray direction (normalized vector). |
float3 | a | The line start point. |
float3 | b | The line end point. |
float | rayParam | The signed distance between point 'ro' and the projection of the line segment along the ray. |
float | lineParam | The signed distance between point 'a' and the projection of point 'p' on the line segment. |
Returns
Type | Description |
---|---|
(float3 rayPoint, float3 linePoint) | Returns the nearest points on a ray and a line segment to one another. |
RayLineParameter(float3, float3, float3, float3)
Returns the parameterization of a ray line projection. The parameter will be negative if the nearest point between the ray/line is negative to 'lineOrigin', and greater than 1 if nearest intersection is past the end off the line segment (lineOrigin + lineDir).
Declaration
public static float RayLineParameter(float3 ro, float3 rd, float3 lineOrigin, float3 lineDir)
Parameters
Type | Name | Description |
---|---|---|
float3 | ro | The ray origin point. |
float3 | rd | The ray direction (normalized vector). |
float3 | lineOrigin | Line segment first point. |
float3 | lineDir | Line segment direction (with magnitude). |
Returns
Type | Description |
---|---|
float | The parameter of a ray line projection. |