| Copyright | (C) 2015 Dimitri Sabadie | 
|---|---|
| License | BSD3 | 
| Maintainer | Dimitri Sabadie <dimitri.sabadie@gmail.com> | 
| Stability | experimental | 
| Portability | portable | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Data.Spline.Key
Contents
Description
Synopsis
- data Key a
- = Hold a
 - | Linear a
 - | Cosine a
 - | CubicHermite a
 - | Bezier a a a
 
 - keyValue :: Key a -> a
 - interpolateKeys :: (Additive a, Floating s) => s -> Key (a s) -> Key (a s) -> a s
 - normalizeSampling :: Fractional s => (a s -> s) -> s -> Key (a s) -> Key (a s) -> s
 
Key type
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.
H is used to express no interpolation and holds its latest value
 until the next key.old v
 represents a linear interpolation until the next key.Linear v
 represents a cosine interpolation until the next key.Cosine v
 represents a cubic hermitian interpolation until the next
 key.CubicHermite v
 represents a cubic Bezier l v rBezier 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
| Functor Key Source # | |
| Eq a => Eq (Key a) Source # | |
| Show a => Show (Key a) Source # | |
| FromJSON a => FromJSON (Key a) Source # | |
Defined in Data.Spline.Key  | |
| ToJSON a => ToJSON (Key a) Source # | |
Defined in Data.Spline.Key Methods toEncoding :: Key a -> Encoding toJSONList :: [Key a] -> Value toEncodingList :: [Key a] -> Encoding  | |
Interpolation
interpolateKeys :: (Additive a, Floating s) => s -> Key (a s) -> Key (a s) -> a s Source #
 interpolates between interpolateKeys t start endstart and end using
 s as a normalized sampling value.
Satisfies the following laws:
interpolateKeys0 start _ = startinterpolateKeys1 _ 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 (keyValuek1) s= sampler (keyValuek0) 0 <=normalizeSamplingsampler s k0 k1 <= 1