Table of Contents

Struct CubicSpline

Namespace
Xui.Core.Curves2D
Assembly
Core.dll

Represents a 4-point spline segment using Catmull–Rom interpolation. The curve interpolates smoothly between P1 and P2.

public readonly struct CubicSpline : ICurve
Implements
Inherited Members

Remarks

Catmull–Rom splines are useful for generating smooth curves through a sequence of points with minimal configuration. This implementation produces a C¹-continuous cubic curve, influenced by neighboring control points P0 and P3. The segment can also be converted into a CubicBezier for drawing or compatibility.

Constructors

CubicSpline(Point, Point, Point, Point)

Initializes a new Catmull–Rom spline segment from four control points.

public CubicSpline(Point p0, Point p1, Point p2, Point p3)

Parameters

p0 Point
p1 Point
p2 Point
p3 Point

Fields

P0

The control point before the start of the curve.

public readonly Point P0

Field Value

Point

P1

The starting point of the interpolated segment.

public readonly Point P1

Field Value

Point

P2

The ending point of the interpolated segment.

public readonly Point P2

Field Value

Point

P3

The control point after the end of the curve.

public readonly Point P3

Field Value

Point

Properties

this[NFloat]

Indexer-style access to evaluate the curve at a given parameter.

public Point this[NFloat t] { get; }

Parameters

t NFloat

Property Value

Point

Methods

Length()

Approximates the arc length of the curve using uniform sampling with 16 segments.

public NFloat Length()

Returns

NFloat

Length(NFloat)

Approximates the arc length using recursive adaptive subdivision.

public NFloat Length(NFloat precision)

Parameters

precision NFloat

The tolerance used to decide subdivision depth.

Returns

NFloat

Lerp(NFloat)

Evaluates the point on the spline at the given parameter t using the Catmull–Rom formula.

public Point Lerp(NFloat t)

Parameters

t NFloat

A normalized parameter in the range [0, 1].

Returns

Point

Tangent(NFloat)

Computes the tangent vector at parameter t by differentiating the spline.

public Vector Tangent(NFloat t)

Parameters

t NFloat

A normalized parameter in the range [0, 1].

Returns

Vector

Operators

implicit operator CubicBezier(CubicSpline)

Converts this Catmull–Rom spline segment to an equivalent CubicBezier. The resulting curve interpolates between P1 and P2.

public static implicit operator CubicBezier(CubicSpline s)

Parameters

s CubicSpline

Returns

CubicBezier