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. 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 as Vector3
references and a float value t
that represents the interpolation factor. The value of t
should be between 0 and 1, where 0 corresponds to the start of the spline segment and 1 corresponds to the end.
Example
Vector3 p0 = new Vector3(0, 0, 0);
Vector3 p1 = new Vector3(1, 1, 0);
Vector3 p2 = new Vector3(2, 0, 0);
Vector3 p3 = new Vector3(3, -1, 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