smoothie 0.2 → 0.2.1
raw patch · 2 files changed
+8/−2 lines, 2 files
Files
- smoothie.cabal +1/−1
- src/Data/Spline.hs +7/−1
smoothie.cabal view
@@ -1,5 +1,5 @@ name: smoothie -version: 0.2 +version: 0.2.1 synopsis: Smooth curves via several splines and polynomials. description: This package exports several splines and curves you can use to interpolate points in between.
src/Data/Spline.hs view
@@ -19,6 +19,7 @@ -- * Spline Spline , spline+ , unspline -- * Sampling values from splines , sample ) where@@ -27,7 +28,8 @@ import Data.Ord ( comparing ) import Data.Spline.CP import Data.Spline.Polynomial ( Polynomial(..), bsearchLower )-import Data.Vector ( Vector, (!?), fromList )+import Data.Vector ( Vector, (!?), fromList, toList )+import qualified Data.Vector as V ( zip ) -- |A @Spline@ is a collection of control points with associated polynomials. -- Given two control points which indices are /i/ and /i+1/, interpolation on@@ -44,6 +46,10 @@ spline = uncurry spline_ . unzip . dupLast . sortBy (comparing fst) where spline_ cps polys = Spline (fromList cps) (fromList polys)++-- |Deconstruct a 'Spline s a' to yield '[(CP s a,Polynomial s a)]'.+unspline :: Spline s a -> [(CP s a,Polynomial s a)]+unspline (Spline cps polys) = toList $ V.zip cps polys -- |Sample a point on a spline. sample :: (Ord s) => Spline s a -> s -> Maybe a