smoothie-0.1.2: Smooth curves via several splines and polynomials.

Copyright(C) 2015 Dimitri Sabadie
LicenseBSD3
MaintainerDimitri Sabadie <dimitri.sabadie@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Spline.Polynomial

Contents

Description

 

Synopsis

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.

cosine :: (Additive a, Floating s, Ord s) => Polynomial s (a s) Source

Cosine polynomial.

Helpers

bsearchLower :: (a -> Ordering) -> Vector a -> Maybe Int Source

Helper binary search that search the ceiling index for the value to be searched according to the predicate.