smoothie-0.4.2.11: Smooth curves via several interpolation modes
Copyright(C) 2015 Dimitri Sabadie
LicenseBSD3
MaintainerDimitri Sabadie <dimitri.sabadie@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Spline.Curve

Description

This module defines Splines and related functions. Because a Spline requires Keys, the Data.Spline.Key module is also exported.

Synopsis

Splines

data Spline a s Source #

A Spline a s is a collection of Keys with associated interpolation modes.

Given two Keys which indices are i and i+1, the interpolation mode on the resulting curve is performed using the interpolation mode of the key i. Thus, the interpolation mode of the latest key might be ignored. There’s an exception, though, when using the Bezier interpolation mode. Feel free to dig in the Key documentation.

Instances

Instances details
Functor a => Functor (Spline a) Source # 
Instance details

Defined in Data.Spline.Curve

Methods

fmap :: (a0 -> b) -> Spline a a0 -> Spline a b #

(<$) :: a0 -> Spline a b -> Spline a a0 #

Eq (a s) => Eq (Spline a s) Source # 
Instance details

Defined in Data.Spline.Curve

Methods

(==) :: Spline a s -> Spline a s -> Bool #

(/=) :: Spline a s -> Spline a s -> Bool #

Show (a s) => Show (Spline a s) Source # 
Instance details

Defined in Data.Spline.Curve

Methods

showsPrec :: Int -> Spline a s -> ShowS #

show :: Spline a s -> String #

showList :: [Spline a s] -> ShowS #

Generic (Spline a s) Source # 
Instance details

Defined in Data.Spline.Curve

Associated Types

type Rep (Spline a s) :: Type -> Type #

Methods

from :: Spline a s -> Rep (Spline a s) x #

to :: Rep (Spline a s) x -> Spline a s #

(FromJSON (a s), Ord s) => FromJSON ((a s -> s) -> Spline a s) Source # 
Instance details

Defined in Data.Spline.Curve

Methods

parseJSON :: Value -> Parser ((a s -> s) -> Spline a s)

parseJSONList :: Value -> Parser [(a s -> s) -> Spline a s]

ToJSON (a s) => ToJSON (Spline a s) Source # 
Instance details

Defined in Data.Spline.Curve

Methods

toJSON :: Spline a s -> Value

toEncoding :: Spline a s -> Encoding

toJSONList :: [Spline a s] -> Value

toEncodingList :: [Spline a s] -> Encoding

type Rep (Spline a s) Source # 
Instance details

Defined in Data.Spline.Curve

type Rep (Spline a s) = D1 ('MetaData "Spline" "Data.Spline.Curve" "smoothie-0.4.2.11-inplace" 'True) (C1 ('MetaCons "Spline" 'PrefixI 'True) (S1 ('MetaSel ('Just "splineKeys") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Vector (Key (a s))))))

splineKeys :: Spline a s -> Vector (Key (a s)) Source #

Extract the Keys.

Building splines

spline :: Ord s => (a s -> s) -> [Key (a s)] -> Spline a s Source #

Build a Spline a s.

a s is the type held by Keys. For instance, V2 Float.

The first argument of the function, which has type a s -> s, is a function used to extract the sampling value of each Keys. In most cases, that value represents the time or the frame of a simulation. That value is used to perform sampling comparison.

Sampling splines

sample :: (Additive a, Floating s, Ord s) => (a s -> s) -> Spline a s -> s -> Maybe (a s) Source #

Sample a Spline at a given s sampling value. If no sample exists, yields Nothing.

The first parameter is a sampler function used to extract a comparison value. For most curves, the reflected value should be the time or the frame.

Re-exported