Module flo_curves::bezier

source ·
Expand description

Routines for describing, querying and manipulating Bezier curves

let curve           = Curve::from_points(Coord2(1.0, 2.0), (Coord2(2.0, 0.0), Coord2(3.0, 5.0)), Coord2(4.0, 2.0));

let mid_point       = curve.point_at_pos(0.5);
let all_points      = walk_curve_evenly(&curve, 1.0, 0.01).map(|section| section.point_at_pos(0.5)).collect::<Vec<_>>();
let fitted_curve    = fit_curve::<Curve<Coord2>>(&all_points, 0.1);
let intersections   = curve_intersects_ray(&curve, &(Coord2(1.0, 1.0), Coord2(2.0, 2.0)));
let offset_curve    = offset(&curve, 2.0, 2.0);

Anything that implements the BezierCurve trait can be manipulated by the functions in this crate. The Curve type is provided as a basic implementation for defining bezier curves, but the trait can be defined on any type that represents a bezier curve.

The BezierCurveFactory trait extends the BezierCurve trait for use with functions that can build/return new curves.

For routines that deal with paths made up of bezier curves, see the path namespace.

Re-exports

  • pub use super::geo::*;

Modules

  • Manipulates multiple Bezier curves joined into a path

Structs

  • Represents a Bezier curve
  • Represents a subsection of a bezier curve
  • Iterator implementation that performs an even walk along a curve
  • A structure that can be used to compute the tangent of a bezier curve

Enums

  • Possible types of a two-dimensional cubic bezier curve
  • Describes the features of a two-dimensional cubic bezier curve

Traits

  • Trait implemented by things representing a cubic bezier curve
  • Functions supported on 2D bezier curves
  • Trait implemented by bezier curves that can create new versions of themselves
  • Trait implemented by bezier curves where we can compute the normal
  • Changes a point and its tangent into a normal

Functions

  • The cubic bezier weighted basis function
  • Computes the bezier coefficients (A, B, C, D) for a bezier curve
  • Finds the upper and lower points in a cubic curve’s bounding box
  • Determines the characteristics of a particular bezier curve: whether or not it is an arch, or changes directions (has inflection points), or self-intersects (has a loop)
  • Discovers the ‘character’ of a particular bezier curve, returning a value indicating what kinds of features it has (for example, whether it has a loop or a cusp)
  • Returns the length of the chord of a bezier curve
  • Returns the length of the control polygon for a bezier curve
  • Determines the points at which two curves intersect using the Bezier clipping algorihtm
  • Find the t values where a curve intersects a line
  • Find the t values where a curve intersects a ray
  • Estimates the length of a bezier curve within a particular error tolerance
  • de Casteljau’s algorithm for lines
  • de Casteljau’s algorithm for quadratic bezier curves
  • de Casteljau’s algorithm for cubic bezier curves
  • Returns the 3rd derivative of a cubic bezier curve (2nd of a quadratic)
  • Returns the 1st derivative of a quadratic bezier curve (or the 2nd derivative of a cubic curve)
  • Returns the 1st derivative of a cubic bezier curve
  • Distorts a curve using an arbitrary function
  • Distorts a path using an arbitrary function
  • Determines the characteristics of a paritcular bezier curve: whether or not it is an arch, or changes directions (has inflection points), or self-intersects (has a loop)
  • Discovers what kind of features a curve has and where they are located
  • Finds the t values of the extremities of a curve (these are the points at which the x or y value is at a minimum or maximum)
  • If a cubic curve contains a loop, finds the t values where the curve self-intersects
  • Creates a bezier curve that fits a set of points with a particular error
  • Fits a bezier curve to a subset of points
  • Moves the point at ‘t’ on the curve by the offset vector
  • Finds the ‘t’ value of the closest point on a curve to the supplied point
  • Optimises an estimate of a nearest point on a bezier curve using the newton-raphson method
  • Optimises an estimate of a nearest point on a bezier curve using the newton-raphson method
  • Computes a series of curves that approximate an offset curve from the specified origin curve.
  • Produces an offset curve by performing a least-mean-square curve fit against the output of a function
  • Computes a series of curves that approximate an offset curve from the specified origin curve.
  • If curve2 overlaps curve1, returns two sets of t values (those for curve1 and those for curve2)
  • Performs a subdivision search on a curve for a point matching a function
  • Solves for t in a single dimension for a bezier curve (finds the point(s) where the basis function evaluates to p)
  • Searches along the x or y axis for a point within accuracy units of the curve, returning the t value of that point
  • Subdivides a cubic bezier curve at a particular point, returning the weights of the two component curves
  • Walks a bezier curve by moving forward a set amount at each point. Each point may be up to max_error away from distance.
  • Walks a bezier curve by dividing it into a number of sections