Copyright | (C) 2015 Dimitri Sabadie |
---|---|

License | BSD3 |

Maintainer | Dimitri Sabadie <dimitri.sabadie@gmail.com> |

Stability | experimental |

Portability | portable |

Safe Haskell | None |

Language | Haskell2010 |

- data Polynomial s a
- hold :: Ord s => Polynomial s a
- linear :: (Additive a, Fractional s, Ord s) => Polynomial s (a s)
- linearBy :: (Additive a, Fractional s, Ord s) => (s -> s) -> Polynomial s (a s)
- cosine :: (Additive a, Floating s, Ord s) => Polynomial s (a s)
- bsearchLower :: (a -> Ordering) -> Vector a -> Maybe Int

# Polynomial

data Polynomial s a Source

A `Polynomial`

is used to interpolate in between a spline’s control points.

# Polynomials for interpolation

hold :: Ord s => Polynomial s a Source

Constant polynomial – a.k.a. *no interpolation*.

Given two control points and a sample value in between, the `hold`

polynomial
won’t perform any interpolation but it just *holds* the value carried by the
lower control point along the whole curve between the two control points.

linear :: (Additive a, Fractional s, Ord s) => Polynomial s (a s) Source

1-degree polynomial – a.k.a. *straight line interpolation*, or /linear
interpolation/.

This polynomial connects control points with straight lines.

Note: implemented with `linearBy id`

.

linearBy :: (Additive a, Fractional s, Ord s) => (s -> s) -> Polynomial s (a s) Source

Parametric linear polynomial.

This form applies a pre-filter on the input before performing a linear interpolation. Instead of:

lerp x a b

We have:

lerp (pref x) a b

This can be used to implement 1-degree splines if `pref = id`

, basic cubic
non-hermitian splines if `pref = (^3)`

, cosine splines if
`pref = x -> (1 - cos (x*pi)) * 0.5`

, and so on and so forth.