static Vector3 CatmullRomSpline( Vector3& p0, Vector3& p1, Vector3& p2, Vector3& p3, float t )

book_4_sparkGenerated
code_blocksInput

Description

The CatmullRomSpline method calculates a point on a Catmull-Rom spline, which is a type of interpolating spline. This method is useful for creating smooth curves through a set of points in 3D space. The method takes four control points and a parameter t that determines the position on the spline.

Usage

To use the CatmullRomSpline method, provide four control points p0, p1, p2, and p3 as Vector3 references, and a float t which should be between 0 and 1. The method will return a Vector3 representing the interpolated point on 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 t = 0.5f;

Vector3 pointOnSpline = Vector3.CatmullRomSpline(ref p0, ref p1, ref p2, ref p3, t);

// pointOnSpline now holds the interpolated point on the spline at t = 0.5