static Vector3 TcbSpline( Vector3& p0, Vector3& p1, Vector3& p2, Vector3& p3, float tension, float continuity, float bias, float u )

book_4_sparkGenerated
code_blocksInput

Description

The Vector3.TcbSpline method calculates a point on a Tension-Continuity-Bias (TCB) spline, which is a type of Hermite spline. This method is useful for creating smooth curves that pass through a series of points, with control over the tension, continuity, and bias of the curve.

Usage

To use the Vector3.TcbSpline method, provide four control points p0, p1, p2, and p3, along with the tension, continuity, and bias parameters. The parameter u specifies the position along the spline, where 0 represents the start and 1 represents the end of the segment between p1 and p2.

Parameters:

  • p0: The first control point (Vector3).
  • p1: The second control point (Vector3).
  • p2: The third control point (Vector3).
  • p3: The fourth control point (Vector3).
  • tension: A float value that controls the tension of the spline. A value of 0 results in a Catmull-Rom spline.
  • continuity: A float value that controls the continuity of the spline.
  • bias: A float value that controls the bias of the spline.
  • u: A float value between 0 and 1 that specifies the position along the spline.

Example

Vector3 p0 = new Vector3(0, 0, 0);
Vector3 p1 = new Vector3(1, 2, 0);
Vector3 p2 = new Vector3(3, 3, 0);
Vector3 p3 = new Vector3(4, 0, 0);

float tension = 0.5f;
float continuity = 0.0f;
float bias = 0.0f;
float u = 0.5f;

Vector3 pointOnSpline = Vector3.TcbSpline(ref p0, ref p1, ref p2, ref p3, tension, continuity, bias, u);

// pointOnSpline now contains the interpolated point on the TCB spline.