Struct BezierCurve2
A cubic Bézier curve defined by four LengthPoint2 control points.
The curve passes through P0 at t = 0 and P3 at
t = 1. P1 and P2 are tangent guides — the curve is
attracted to them but does not (in general) pass through them.
Use Evaluate(double) for an exact position at a given curve parameter, and ToPath(int) to convert to an arc-length parameterised LengthPath2 for distance-based traversal.
public readonly record struct BezierCurve2 : IEquatable<BezierCurve2>
- Implements
- Inherited Members
Constructors
BezierCurve2(LengthPoint2, LengthPoint2, LengthPoint2, LengthPoint2)
A cubic Bézier curve defined by four LengthPoint2 control points.
The curve passes through P0 at t = 0 and P3 at
t = 1. P1 and P2 are tangent guides — the curve is
attracted to them but does not (in general) pass through them.
Use Evaluate(double) for an exact position at a given curve parameter, and ToPath(int) to convert to an arc-length parameterised LengthPath2 for distance-based traversal.
public BezierCurve2(LengthPoint2 P0, LengthPoint2 P1, LengthPoint2 P2, LengthPoint2 P3)
Parameters
P0LengthPoint2Start point (curve passes through this at t = 0).
P1LengthPoint2First control point (tangent guide near start).
P2LengthPoint2Second control point (tangent guide near end).
P3LengthPoint2End point (curve passes through this at t = 1).
Properties
P0
Start point (curve passes through this at t = 0).
public LengthPoint2 P0 { get; init; }
Property Value
P1
First control point (tangent guide near start).
public LengthPoint2 P1 { get; init; }
Property Value
P2
Second control point (tangent guide near end).
public LengthPoint2 P2 { get; init; }
Property Value
P3
End point (curve passes through this at t = 1).
public LengthPoint2 P3 { get; init; }
Property Value
Methods
Evaluate(double)
Returns the world-space position on the curve at parameter t.
t = 0 returns P0; t = 1 returns
P3. Values outside [0, 1] extrapolate beyond the endpoints.
public LengthPoint2 Evaluate(double t)
Parameters
tdoubleCurve parameter in [0, 1].
Returns
- LengthPoint2
The interpolated world-space position.
TangentAt(double)
Returns the forward direction (tangent) of the curve at parameter t.
public Direction2 TangentAt(double t)
Parameters
tdoubleCurve parameter in [0, 1].
Returns
- Direction2
The unit tangent direction at that point on the curve.
ToPath(int)
Returns a LengthPath2 that approximates this curve as a polyline
with resolution + 1 uniformly-spaced waypoints.
public LengthPath2 ToPath(int resolution = 64)
Parameters
resolutionintNumber of segments. Must be ≥ 1. Defaults to 64.
Returns
- LengthPath2
A LengthPath2 approximating this curve.