BezierF

References
public readonly struct BezierF
Represents a single unweighted, four point bezier span.

Constructors

BezierF

#
public BezierF(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Create a new bezier segment from four control point coordinates.
x0 (float)X of first control point.
y0 (float)Y of first control point.
x1 (float)X of second control point.
y1 (float)Y of second control point.
x2 (float)X of third control point.
y2 (float)Y of third control point.
x3 (float)X of fourth control point.
y3 (float)Y of fourth control point.

BezierF

#
public BezierF(PointF p0, PointF p1, PointF p2, PointF p3)
Create a new segment from the four control points.
p0 (PointF)First point.
p1 (PointF)Second point.
p2 (PointF)Third point.
p3 (PointF)Fourth point.

BezierF

#
public BezierF(PointF p0, PointF p1, PointF p2)
Create a new segment which exactly matches a degree=2, 3-point bezier curve.
p0 (PointF)First point.
p1 (PointF)Second point.
p2 (PointF)Third point.

Properties

Bounds

#
public RectangleF Bounds { get; }
Gets the boundingbox of this segment.

Classification

#
public BezierShapeClassification Classification { get; }
Gets the classification of the bezier type based on its canonical form.

IsClosed

#
public bool IsClosed { get; }
Gets whether this curve is closed.

IsEmpty

#
public bool IsEmpty { get; }
Geta whether this bezier segment is empty.

IsValid

#
public bool IsValid { get; }
Gets whether all the coordinates are valid numbers.

Length

#
public float Length { get; }
Gets the length of this segment. The length is computed to a tolerance of 1e-4, so if you need a more accurate length, you need to scale the curve up first, then divide the resulting length by your scaling factor.

P0

#
public PointF P0 { get; }
Gets the first control point of the bezier. This is synonymous with the start of the segment.

P1

#
public PointF P1 { get; }
Gets the second control point of the bezier.

P2

#
public PointF P2 { get; }
Gets the third control-point of the bezier.

P3

#
public PointF P3 { get; }
Gets the fourth (and final) control-point of the bezier. This is synonymous with the end of the segment.

T0

#
public SizeF T0 { get; }
Gets the normalised tangent at the start of the segment.

T3

#
public SizeF T3 { get; }
Gets the normalised tangent at the end of the segment.

Methods

AlignedForm

#
[EditorBrowsable(EditorBrowsableState.Never)] public BezierF AlignedForm()
Compute the axis aligned bezier segment. This involves moving P0 to (0,0) and rotating the entire segment until the y-coordinate of P3 equals zero.
Axis aligned bezier.

CanonicalForm

#
[EditorBrowsable(EditorBrowsableState.Never)] public BezierF CanonicalForm()
Compute the canonical bezier form. The canonical form consists of a linear transformation such that P0 ends up at (0,0), P1 ends up at (0,1) and P2 ends up at (1,1). The exact location of P3 can then be used to infer certain properties of the original bezier segment, such as intersections, cusps and inflection count.
Canonical form.

Distance

#
public float Distance(PointF point)
Gets the distance from this bezier to a point.
point (PointF)Point.
Distance.

DistanceFromStart

#
public float DistanceFromStart(float distance)
Find the parameter on the curve with a certain Euclidean distance from the start.
distance (float)

Extremes

#
public void Extremes(out float[] x, out float[] y)
Solve all parameters along the segment where the x and y coordinates are local extremes.
x (out float[])Array of parameters for x-extremes.
y (out float[])Array of parameters for y-extremes.

Inflections

#
public float[] Inflections()
Compute the inflection parameters for this curve.
An array of either zero, one or two inflection parameters.

ParameterAtLength

#
public float ParameterAtLength(float length)
Gets the bezier parameter at the arc-length. This is approximate.
length (float)

PointAt

#
public PointF PointAt(float t)
Evaluate the point at a given parameter.
t (float)Parameter.
Point at parameter.

Project

#
public float Project(PointF point)
Find the parameter on the finite segment closest to the given point.
point (PointF)Search locus.
Parameter on bezier domain.

Reverse

#
public BezierF Reverse()
Create a reversed bezier segment.

Split

#
public void Split(float t, out BezierF left, out BezierF right)
Split this curve into two subcurves.
t (float)Splitting parameter, must be in the [0,1] range.
left (out BezierF)Part of bezier on the subdomain [0, t].
right (out BezierF)Part of bezier o the subdomain [t, 1].

TangentAt

#
public SizeF TangentAt(float t)
Evaluate the (non-unitised) tangent at a given parameter.
t (float)Parameter.
Tangent at parameter.

ToPolyline

#
public PointF[] ToPolyline(float maxError)
Convert this bezier to an array of points. Regardless of maxError, there will always be points at extremes and inflection points.
maxError (float)Maximum deviation between polyline segments and bezier spline.
Point array.

Translate

#
public BezierF Translate(float dx, float dy)
Move this bezier.
dx (float)Horizontal displacement.
dy (float)Vertical displacement.
Moved bezier.

Trim

#
public BezierF Trim(float t0, float t1)
Trim part of this bezier.
t0 (float)First trimming parameter.
t1 (float)Second trimming parameter.
Bezier segment in between trimming parameters.