# 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

- A lightweight struct used to store coordinates on the 2-dimensional Cartesian plane.
- A line segment made up of exactly two
`Coord`

s. - An ordered collection of two or more
`Coord`

s, representing a path between locations. - A continuous piecewise linear function.
- A single point in 2D space.
- Structure returned by
`points_of_inflection_iter()`

- Structure returned by
`segments_iter()`

on a`PiecewiseLinearFunction`

.

## Enums

- Controls how the domain of a function is expanded using
`expand_domain()`

on`PiecewiseLinearFunction`

.

## Traits

- For algorithms which can only use floating point
`Point`

s/`Coord`

s, like area or length calculations

## Functions

- 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`

. - Sums the functions together. Returns
`None`

in case of domain error.