[][src]Trait kurbo::ParamCurveArclen

pub trait ParamCurveArclen: ParamCurve {
    fn arclen(&self, accuracy: f64) -> f64;

    fn inv_arclen(&self, arclen: f64, accuracy: f64) -> f64 { ... }
}

A parametrized curve that can have its arc length measured.

Required methods

fn arclen(&self, accuracy: f64) -> f64

The arc length of the curve.

The result is accurate to the given accuracy (subject to roundoff errors for ridiculously low values). Compute time may vary with accuracy, if the curve needs to be subdivided.

Loading content...

Provided methods

fn inv_arclen(&self, arclen: f64, accuracy: f64) -> f64

Solve for the parameter that has the given arclength from the start.

This implementation is bisection, which is very robust but not necessarily the fastest. It does measure increasingly short segments, though, which should be good for subdivision algorithms.

Loading content...

Implementors

impl ParamCurveArclen for PathSeg[src]

impl ParamCurveArclen for ConstPoint[src]

impl ParamCurveArclen for CubicBez[src]

fn arclen(&self, accuracy: f64) -> f64[src]

Arclength of a cubic Bézier segment.

This is an adaptive subdivision approach using Legendre-Gauss quadrature in the base case, and an error estimate to decide when to subdivide.

impl ParamCurveArclen for Line[src]

impl ParamCurveArclen for QuadBez[src]

fn arclen(&self, _accuracy: f64) -> f64[src]

Arclength of a quadratic Bézier segment.

This computation is based on an analytical formula. Since that formula suffers from numerical instability when the curve is very close to a straight line, we detect that case and fall back to Legendre-Gauss quadrature.

Accuracy should be better than 1e-13 over the entire range.

Adapted from http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/ with permission.

Loading content...