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
Coord
s. - Line
String - An ordered collection of
Coord
s, representing a path between locations. To be valid, aLineString
must be empty, or have two or more coords. - Piecewise
Linear Function - A continuous piecewise linear function.
- Point
- A single point in 2D space.
- Points
OfInflection Iterator - Structure returned by
points_of_inflection_iter()
- Segments
Iterator - Structure returned by
segments_iter()
on aPiecewiseLinearFunction
.
Enums§
- Expand
Domain Strategy - Controls how the domain of a function is expanded using
expand_domain()
onPiecewiseLinearFunction
.
Traits§
- Coord
Float - For algorithms which can only use floating point
Point
s/Coord
s, like area or length calculations
Functions§
- points_
of_ inflection_ iter - Returns an iterator over pairs
(x, values)
, wherex
is the union of all points of inflection ofself
andother
, andvalues
is a vector of the values of all passed functions, in the same order, at the correspondingx
. - sum
- Sums the functions together. Returns
None
in case of domain error.