-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Smooth curves via several interpolation modes
--   
--   This package exports several splines you can use to interpolate points
--   in between. It includes instances for <a>aeson</a> so that you can
--   quickly store the splines and restore them.
@package smoothie
@version 0.4.2.9


module Data.Spline.Key

-- | A <a>Key</a> is a point on the spline with extra information added. It
--   can be, for instance, left and right handles for a <a>Bezier</a>
--   curve, or whatever the interpolation might need.
--   
--   <tt>H<tt>old</tt> v</tt> is used to express no interpolation and holds
--   its latest value until the next key.
--   
--   <tt><a>Linear</a> v</tt> represents a linear interpolation until the
--   next key.
--   
--   <tt><a>Cosine</a> v</tt> represents a cosine interpolation until the
--   next key.
--   
--   <tt><a>CubicHermite</a> v</tt> represents a cubic hermitian
--   interpolation until the next key.
--   
--   <tt><a>Bezier</a> l v r</tt> represents a cubic <a>Bezier</a>
--   interpolation, where <tt>l</tt> refers to the input – left – tangent
--   of the key and <tt>r</tt> is the output – right – tangent of the key.
data Key a
Hold :: a -> Key a
Linear :: a -> Key a
Cosine :: a -> Key a
CubicHermite :: a -> Key a
Bezier :: a -> a -> a -> Key a

-- | Extract the value out of a <a>Key</a>.
keyValue :: Key a -> a

-- | <tt><a>interpolateKeys</a> t start end</tt> interpolates between
--   <tt>start</tt> and <tt>end</tt> using <tt>s</tt> as a normalized
--   sampling value.
--   
--   Satisfies the following laws:
--   
--   <pre>
--   <a>interpolateKeys</a> 0 start _ = start
--   <a>interpolateKeys</a> 1 _ end   = end
--   </pre>
interpolateKeys :: (Additive a, Floating s) => s -> Key (a s) -> Key (a s) -> a s

-- | Normalize a sampling value by clamping and scaling it between two
--   <a>Key</a>s.
--   
--   The following laws should be satisfied in order to get a coherent
--   output:
--   
--   <pre>
--   sampler :: a s -&gt; s
--   
--   sampler (<a>keyValue</a> k1) <a>s</a>= sampler (<a>keyValue</a> k0)
--   0 &lt;= <a>normalizeSampling</a> sampler s k0 k1 &lt;= 1
--   </pre>
normalizeSampling :: (Fractional s) => (a s -> s) -> s -> Key (a s) -> Key (a s) -> s
instance GHC.Show.Show a => GHC.Show.Show (Data.Spline.Key.Key a)
instance GHC.Base.Functor Data.Spline.Key.Key
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Spline.Key.Key a)
instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Data.Spline.Key.Key a)
instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Data.Spline.Key.Key a)


-- | This module defines <a>Spline</a>s and related functions. Because a
--   <a>Spline</a> requires <a>Key</a>s, the <a>Data.Spline.Key</a> module
--   is also exported.
module Data.Spline.Curve

-- | A <tt><a>Spline</a> a s</tt> is a collection of <a>Key</a>s with
--   associated interpolation modes.
--   
--   Given two <a>Key</a>s which indices are <i>i</i> and <i>i+1</i>, the
--   interpolation mode on the resulting curve is performed using the
--   interpolation mode of the key <i>i</i>. Thus, the interpolation mode
--   of the latest key might be ignored. There’s an exception, though, when
--   using the <a>Bezier</a> interpolation mode. Feel free to dig in the
--   <a>Key</a> documentation.
data Spline a s

-- | Extract the <a>Key</a>s.
splineKeys :: Spline a s -> Vector (Key (a s))

-- | Build a <tt><a>Spline</a> a s</tt>.
--   
--   <tt>a s</tt> is the type held by <a>Key</a>s. For instance,
--   <tt><tt>V2</tt> Float</tt>.
--   
--   The first argument of the function, which has type <tt>a s -&gt;
--   s</tt>, is a function used to extract the sampling value of each
--   <a>Key</a>s. In most cases, that value represents the time or the
--   frame of a simulation. That value is used to perform sampling
--   comparison.
spline :: (Ord s) => (a s -> s) -> [Key (a s)] -> Spline a s

-- | Sample a <a>Spline</a> at a given <tt>s</tt> sampling value. If no
--   sample exists, yields <a>Nothing</a>.
--   
--   The first parameter is a <i>sampler</i> function used to extract a
--   comparison value. For most curves, the reflected value should be the
--   time or the frame.
sample :: (Additive a, Floating s, Ord s) => (a s -> s) -> Spline a s -> s -> Maybe (a s)
instance GHC.Show.Show (a s) => GHC.Show.Show (Data.Spline.Curve.Spline a s)
instance GHC.Base.Functor a => GHC.Base.Functor (Data.Spline.Curve.Spline a)
instance GHC.Generics.Generic (Data.Spline.Curve.Spline a s)
instance GHC.Classes.Eq (a s) => GHC.Classes.Eq (Data.Spline.Curve.Spline a s)
instance (Data.Aeson.Types.FromJSON.FromJSON (a s), GHC.Classes.Ord s) => Data.Aeson.Types.FromJSON.FromJSON ((a s -> s) -> Data.Spline.Curve.Spline a s)
instance Data.Aeson.Types.ToJSON.ToJSON (a s) => Data.Aeson.Types.ToJSON.ToJSON (Data.Spline.Curve.Spline a s)


-- | This package works around two primary types:
--   
--   <ul>
--   <li><a>Key</a></li>
--   <li><a>Spline</a></li>
--   </ul>
--   
--   A <tt><a>Spline</a> a s</tt> represents a curve in which <tt>a</tt> is
--   very likely to be <tt>Additive</tt> (see <a>linear</a>) and <tt>s</tt>
--   is the sampling type.
--   
--   A <a>Key</a> is used to hold data in a <a>Spline</a>. It adds
--   interpolation mode to data for <b>each</b> <a>Key</a> used to build
--   the <a>Spline</a>.
--   
--   Through the library, you’ll see types like:
--   
--   <pre>
--   (<tt>Additive</tt> a) =&gt; a s
--   </pre>
--   
--   That is due to the fact some functions work on <tt>a</tt> as a
--   polymorphic first-class value. That enables more flexibility in the
--   implementation and the interface. Thus, in most cases, you can use any
--   type of your choice as long as it’s an additive one.
module Data.Spline
