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.

The method returns a Vector3 representing the calculated point on the spline.

Example

// Example usage of Vector3.TcbSpline
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; // Midpoint of the segment

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

// pointOnSpline now contains the coordinates of the point on the spline at u = 0.5