Class SplineHelpers
A collection of utilities relating to Bezier splines
Inherited Members
Namespace: Cinemachine.Utility
Assembly: Cinemachine.dll
Syntax
public static class SplineHelpers
Methods
Bezier1(float, float, float, float, float)
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 |
---|---|---|
float | t | How far along the spline (0...1) |
float | p0 | First point |
float | p1 | First tangent |
float | p2 | Second point |
float | p3 | Second tangent |
Returns
Type | Description |
---|---|
float | The spline value at t |
Bezier3(float, 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 |
---|---|---|
float | 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(float, float, float, float, float)
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 |
---|---|---|
float | t | How far along the spline (0...1) |
float | p0 | First point |
float | p1 | First tangent |
float | p2 | Second point |
float | p3 | Second tangent |
Returns
Type | Description |
---|---|
float | The spline tangent at t |
BezierTangent3(float, 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 |
---|---|---|
float | 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 |
BezierTangentWeights3(Vector3, Vector3, Vector3, Vector3, out Vector3, out Vector3, out Vector3)
Compute the weights for the tangent of a 4-point 3-dimensional bezier spline
Declaration
public static void BezierTangentWeights3(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, out Vector3 w0, out Vector3 w1, out Vector3 w2)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | p0 | First point |
Vector3 | p1 | First tangent |
Vector3 | p2 | Second point |
Vector3 | p3 | Second tangent |
Vector3 | w0 | First output weight |
Vector3 | w1 | Second output weight |
Vector3 | w2 | Third output weight |
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)