logo
pub struct QuadraticBezierSegment<S> {
    pub from: Point<S>,
    pub ctrl: Point<S>,
    pub to: Point<S>,
}
Expand description

A 2d curve segment defined by three points: the beginning of the segment, a control point and the end of the segment.

The curve is defined by equation: ∀ t ∈ [0..1], P(t) = (1 - t)² * from + 2 * (1 - t) * t * ctrl + 2 * t² * to

Fields

from: Point<S>ctrl: Point<S>to: Point<S>

Implementations

Sample the curve at t (expecting t between 0 and 1).

Sample the x coordinate of the curve at t (expecting t between 0 and 1).

Sample the y coordinate of the curve at t (expecting t between 0 and 1).

Sample the curve’s derivative at t (expecting t between 0 and 1).

Sample the x coordinate of the curve’s derivative at t (expecting t between 0 and 1).

Sample the y coordinate of the curve’s derivative at t (expecting t between 0 and 1).

Swap the beginning and the end of the segment.

Find the advancement of the y-most position in the curve.

This returns the advancement along the curve, not the actual y position.

Find the advancement of the y-least position in the curve.

This returns the advancement along the curve, not the actual y position.

Return the y inflection point or None if this curve is y-monotonic.

Find the advancement of the x-most position in the curve.

This returns the advancement along the curve, not the actual x position.

Find the advancement of the x-least position in the curve.

This returns the advancement along the curve, not the actual x position.

Return the x inflection point or None if this curve is x-monotonic.

Return the sub-curve inside a given range of t.

This is equivalent splitting at the range’s end points.

Split this curve into two sub-curves.

Return the curve before the split point.

Return the curve after the split point.

Elevate this curve to a third order bézier.

Computes a “fat line” of this segment.

A fat line is two conservative lines between which the segment is fully contained.

Applies the transform to this curve and returns the results.

Find the interval of the beginning of the curve that can be approximated with a line segment.

Compute a flattened approximation of the curve, invoking a callback at each step.

The callback takes the point on the curve at each step.

This implements the algorithm described by Raph Levien at https://raphlinus.github.io/graphics/curves/2019/12/23/flatten-quadbez.html

Compute a flattened approximation of the curve, invoking a callback at each step.

The callback takes the curve parameter at each step.

This implements the algorithm described by Raph Levien at https://raphlinus.github.io/graphics/curves/2019/12/23/flatten-quadbez.html

Compute a flattened approximation of the curve, invoking a callback at each step.

The callback takes the point and corresponding curve parameter at each step.

This implements the algorithm described by Raph Levien at https://raphlinus.github.io/graphics/curves/2019/12/23/flatten-quadbez.html

Returns the flattened representation of the curve as an iterator, starting after the current point.

Returns the flattened representation of the curve as an iterator, starting after the current point.

Invokes a callback between each monotonic part of the segment.

Invokes a callback for each monotonic part of the segment..

Compute the length of the segment using a flattened approximation.

Returns a triangle containing this curve segment.

Returns a conservative rectangle that contains the curve.

Returns a conservative rectangle that contains the curve.

Returns a conservative range of x that contains this curve.

Returns a conservative range of y that contains this curve.

Returns the smallest rectangle the curve is contained in

Returns the smallest rectangle the curve is contained in

Returns the smallest range of x that contains this curve.

Returns the smallest range of y that contains this curve.

Cast this curve into a monotonic curve without checking that the monotonicity assumption is correct.

Returns whether this segment is monotonic on the x axis.

Returns whether this segment is monotonic on the y axis.

Returns whether this segment is fully monotonic.

Computes the intersections (if any) between this segment a line.

The result is provided in the form of the t parameters of each point along curve. To get the intersection points, sample the curve at the corresponding values.

Computes the intersection points (if any) between this segment a line.

Computes the intersections (if any) between this segment a line segment.

The result is provided in the form of the t parameters of each point along curve and segment. To get the intersection points, sample the segments at the corresponding values.

Computes the intersection points (if any) between this segment a line segment.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Start of the curve.

End of the curve.

Sample the curve at t (expecting t between 0 and 1).

Sample x at t (expecting t between 0 and 1).

Sample y at t (expecting t between 0 and 1).

Sample the derivative at t (expecting t between 0 and 1).

Sample x derivative at t (expecting t between 0 and 1).

Sample y derivative at t (expecting t between 0 and 1).

Split this curve into two sub-curves.

Return the curve before the split point.

Return the curve after the split point.

Return the curve inside a given range of t. Read more

Swap the direction of the segment.

Compute the length of the segment using a flattened approximation.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.