Class SplineMath
Assorted utility functions for math equations commonly used when working with Splines.
Inherited Members
Namespace: UnityEngine.Splines
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 |
---|---|
Single | Returns the distance of the closest line from a point to a line segment. |
PointLineNearestPoint(float3, float3, float3, out Single)
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. |
Single | lineParam | The parameter for the projection of a point onto the line segment. This is a value between 0 and 1 that represents the ratio along the line segment at which the nearest point is found. |
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 |
---|---|
(T1, T2)<float3, float3> | Returns the nearest points between a ray and line segment. |
RayLineNearestPoint(float3, float3, float3, float3, out Single, out Single)
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. |
Single | rayParam | The parameter of the projection of the nearest point on the line segment to the ray. This is a value between 0 and 1 that represents the ratio along the ray starting from origin at which the nearest point is found. |
Single | lineParam | The parameter for the projection of the nearest point on a ray onto the line segment. This is a value between 0 and 1 that represents the ratio along the line segment at which the nearest point is found. |
Returns
Type | Description |
---|---|
(T1, T2)<float3, float3> | 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 |
---|---|
Single | The parameter of a ray line projection. |