Crate piecewise_linear

Source
Expand description

This crate provides utilities to manipulate continuous piecewise linear functions.

They are internally represented as a list of (x, y) pairs, each representing a point of inflection (or equivalently a limit between two linear pieces). The represented function is assumed to be linear between each of these points.

§Domains

The domain of a function is the range over which it is defined, that is, the range between the smallest x coordinate and the greatest one in the function’s definition points.

Most methods will refuse to operate on two (or more) functions that do not have the same domain. You can use expand_domain() and shrink_domain() to adapt domains.

Domains over all real numbers should be possible by using ±inf x values, but this has not been extensively tested.

§Numeric types

This crate should support functions using any CoordFloat (more or less a rust-num Num), however it has not been tested with types other than f32 and f64.

Structs§

Coord
A lightweight struct used to store coordinates on the 2-dimensional Cartesian plane.
Line
A line segment made up of exactly two Coords.
LineString
An ordered collection of Coords, representing a path between locations. To be valid, a LineString must be empty, or have two or more coords.
PiecewiseLinearFunction
A continuous piecewise linear function.
Point
A single point in 2D space.
PointsOfInflectionIterator
Structure returned by points_of_inflection_iter()
SegmentsIterator
Structure returned by segments_iter() on a PiecewiseLinearFunction.

Enums§

ExpandDomainStrategy
Controls how the domain of a function is expanded using expand_domain() on PiecewiseLinearFunction.

Traits§

CoordFloat
For algorithms which can only use floating point Points/Coords, like area or length calculations

Functions§

points_of_inflection_iter
Returns an iterator over pairs (x, values), where x is the union of all points of inflection of self and other, and values is a vector of the values of all passed functions, in the same order, at the corresponding x.
sum
Sums the functions together. Returns None in case of domain error.