Class SplineHelpers
A collection of utilities relating to Bezier splines
Namespace: Cinemachine.Utility
Syntax
public static class SplineHelpers
Methods
Bezier1(Single, Single, Single, Single, Single)
Compute the value of a 4-point 1-dimensional bezier spline
Declaration
public static float Bezier1(float t, float p0, float p1, float p2, float p3)
Parameters
Type | Name | Description |
---|---|---|
Single | t | How far along the spline (0...1) |
Single | p0 | First point |
Single | p1 | First tangent |
Single | p2 | Second point |
Single | p3 | Second tangent |
Returns
Type | Description |
---|---|
Single | The spline value at t |
Bezier3(Single, Vector3, Vector3, Vector3, Vector3)
Compute the value of a 4-point 3-dimensional bezier spline
Declaration
public static Vector3 Bezier3(float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
Parameters
Type | Name | Description |
---|---|---|
Single | t | How far along the spline (0...1) |
Vector3 | p0 | First point |
Vector3 | p1 | First tangent |
Vector3 | p2 | Second point |
Vector3 | p3 | Second tangent |
Returns
Type | Description |
---|---|
Vector3 | The spline value at t |
BezierTangent1(Single, Single, Single, Single, Single)
Compute the tangent of a 4-point 1-dimensional bezier spline
Declaration
public static float BezierTangent1(float t, float p0, float p1, float p2, float p3)
Parameters
Type | Name | Description |
---|---|---|
Single | t | How far along the spline (0...1) |
Single | p0 | First point |
Single | p1 | First tangent |
Single | p2 | Second point |
Single | p3 | Second tangent |
Returns
Type | Description |
---|---|
Single | The spline tangent at t |
BezierTangent3(Single, Vector3, Vector3, Vector3, Vector3)
Compute the tangent of a 4-point 3-dimensional bezier spline
Declaration
public static Vector3 BezierTangent3(float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
Parameters
Type | Name | Description |
---|---|---|
Single | t | How far along the spline (0...1) |
Vector3 | p0 | First point |
Vector3 | p1 | First tangent |
Vector3 | p2 | Second point |
Vector3 | p3 | Second tangent |
Returns
Type | Description |
---|---|
Vector3 | The spline tangent at t |
ComputeSmoothControlPoints(ref Vector4[], ref Vector4[], ref Vector4[])
Use the Thomas algorithm to compute smooth tangent values for a spline.
Resultant tangents guarantee second-order smoothness of the curve.
Declaration
public static void ComputeSmoothControlPoints(ref Vector4[] knot, ref Vector4[] ctrl1, ref Vector4[] ctrl2)
Parameters
Type | Name | Description |
---|---|---|
Vector4[] | knot | The knots defining the curve |
Vector4[] | ctrl1 | Output buffer for the first control points (1 per knot) |
Vector4[] | ctrl2 | Output buffer for the second control points (1 per knot) |
ComputeSmoothControlPointsLooped(ref Vector4[], ref Vector4[], ref Vector4[])
Use the Thomas algorithm to compute smooth tangent values for a spline.
This method will assume that the spline is looped (i.e. that the last knot is followed by the first).
Resultant tangents guarantee second-order smoothness of the curve.
Declaration
public static void ComputeSmoothControlPointsLooped(ref Vector4[] knot, ref Vector4[] ctrl1, ref Vector4[] ctrl2)
Parameters
Type | Name | Description |
---|---|---|
Vector4[] | knot | The knots defining the curve |
Vector4[] | ctrl1 | Output buffer for the first control points (1 per knot) |
Vector4[] | ctrl2 | Output buffer for the second control points (1 per knot) |