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.Key

Description

 
Synopsis

Key type

data Key a Source #

A Key is a point on the spline with extra information added. It can be, for instance, left and right handles for a Bezier curve, or whatever the interpolation might need.

Hold v is used to express no interpolation and holds its latest value until the next key.

Linear v represents a linear interpolation until the next key.

Cosine v represents a cosine interpolation until the next key.

CubicHermite v represents a cubic hermitian interpolation until the next key.

Bezier l v r represents a cubic Bezier interpolation, where l refers to the input – left – tangent of the key and r is the output – right – tangent of the key.

Constructors

Hold a 
Linear a 
Cosine a 
CubicHermite a 
Bezier a a a 

Instances

Instances details
Functor Key Source # 
Instance details

Defined in Data.Spline.Key

Methods

fmap :: (a -> b) -> Key a -> Key b #

(<$) :: a -> Key b -> Key a #

Eq a => Eq (Key a) Source # 
Instance details

Defined in Data.Spline.Key

Methods

(==) :: Key a -> Key a -> Bool #

(/=) :: Key a -> Key a -> Bool #

Show a => Show (Key a) Source # 
Instance details

Defined in Data.Spline.Key

Methods

showsPrec :: Int -> Key a -> ShowS #

show :: Key a -> String #

showList :: [Key a] -> ShowS #

FromJSON a => FromJSON (Key a) Source # 
Instance details

Defined in Data.Spline.Key

Methods

parseJSON :: Value -> Parser (Key a)

parseJSONList :: Value -> Parser [Key a]

ToJSON a => ToJSON (Key a) Source # 
Instance details

Defined in Data.Spline.Key

Methods

toJSON :: Key a -> Value

toEncoding :: Key a -> Encoding

toJSONList :: [Key a] -> Value

toEncodingList :: [Key a] -> Encoding

keyValue :: Key a -> a Source #

Extract the value out of a Key.

Interpolation

interpolateKeys :: (Additive a, Floating s) => s -> Key (a s) -> Key (a s) -> a s Source #

interpolateKeys t start end interpolates between start and end using s as a normalized sampling value.

Satisfies the following laws:

  interpolateKeys 0 start _ = start
  interpolateKeys 1 _ end   = end

normalizeSampling :: Fractional s => (a s -> s) -> s -> Key (a s) -> Key (a s) -> s Source #

Normalize a sampling value by clamping and scaling it between two Keys.

The following laws should be satisfied in order to get a coherent output:

  sampler :: a s -> s

  sampler (keyValue k1) s= sampler (keyValue k0)
  0 <= normalizeSampling sampler s k0 k1 <= 1