-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | B-Splines, other splines, and NURBS. -- -- This is a fairly simple implementation of a general-purpose spline -- library, just to get the code out there. Its interface is still mildly -- unstable and may change (hopefully not drastically) as new needs or -- better style ideas come up. Patches, suggestions and/or feature -- requests are welcome. @package splines @version 0.3 module Math.Spline.Knots -- | Knot vectors - multisets of points in a 1-dimensional space. data Knots a -- | An empty knot vector empty :: Knots a isEmpty :: Knots a -> Bool -- | Create a knot vector consisting of one knot. knot :: Ord a => a -> Knots a -- | Create a knot vector consisting of one knot with the specified -- multiplicity. multipleKnot :: Ord a => a -> Int -> Knots a -- | Create a knot vector consisting of all the knots in a list. mkKnots :: Ord a => [a] -> Knots a -- | Create a knot vector consisting of all the knots and corresponding -- multiplicities in a list. fromList :: Ord k => [(k, Int)] -> Knots k -- | Returns the number of knots (not necessarily distinct) in a knot -- vector. numKnots :: Knots t -> Int lookupKnot :: Int -> Knots a -> Maybe a -- | Returns a list of all distinct knots in ascending order along with -- their multiplicities. toList :: Knots k -> [(k, Int)] -- | Returns the number of distinct knots in a knot vector. numDistinctKnots :: Knots t -> Int lookupDistinctKnot :: Int -> Knots a -> Maybe a -- | Returns a list of all knots (not necessarily distinct) of a knot -- vector in ascending order knots :: Knots t -> [t] -- | Returns a vector of all knots (not necessarily distinct) of a knot -- vector in ascending order knotsVector :: Knots t -> Vector t -- | Returns a list of all distinct knots of a knot vector in ascending -- order distinctKnots :: Knots t -> [t] -- | Returns a vector of all distinct knots of a knot vector in ascending -- order distinctKnotsVector :: Knots t -> Vector t toMap :: Knots k -> Map k Int fromMap :: Map k Int -> Knots k toVector :: Knots k -> Vector (k, Int) fromVector :: Ord k => Vector (k, Int) -> Knots k -- | splitLookup n kts: Split a knot vector kts into 3 -- parts (pre, mbKt, post) such that: -- --
-- evalSpline b1 x == evalSpline b (x * t) -- evalSpline b2 (x-t) == evalSpline b (x * (1-t)) --splitBezierCurve :: VectorSpace v => BezierCurve v -> Scalar v -> (BezierCurve v, BezierCurve v) evalSpline :: Spline s v => s v -> Scalar v -> v instance Eq t => Eq (BezierCurve t) instance Ord t => Ord (BezierCurve t) instance Spline BezierCurve v => ControlPoints BezierCurve v instance (VectorSpace v, Fractional (Scalar v), Ord (Scalar v)) => Spline BezierCurve v instance Show v => Show (BezierCurve v) module Math.Spline.MSpline -- | M-Splines are B-splines normalized so that the integral of each basis -- function over the spline domain is 1. data MSpline v -- | mSpline kts cps creates a M-spline with the given knot vector -- and control points. The degree is automatically inferred as the -- difference between the number of spans in the knot vector -- (numKnots kts - 1) and the number of control points -- (length cps). mSpline :: Knots (Scalar a) -> Vector a -> MSpline a toMSpline :: Spline s v => s v -> MSpline v evalSpline :: Spline s v => s v -> Scalar v -> v instance (Ord (Scalar v), Ord v) => Ord (MSpline v) instance (Eq (Scalar v), Eq v) => Eq (MSpline v) instance Spline MSpline v => ControlPoints MSpline v instance (VectorSpace v, Fractional (Scalar v), Ord (Scalar v)) => Spline MSpline v instance (Show (Scalar v), Show v) => Show (MSpline v) module Math.Spline.ISpline -- | The I-Spline basis functions are the integrals of the M-splines, or -- alternatively the integrals of the B-splines normalized to the range -- [0,1]. Every I-spline basis function increases monotonically from 0 to -- 1, thus it is useful as a basis for monotone functions. An I-Spline -- curve is monotone if and only if every non-zero control point has the -- same sign. data ISpline v -- | iSpline kts cps creates an I-spline with the given knot -- vector and control points. The degree is automatically inferred as the -- difference between the number of spans in the knot vector -- (numKnots kts - 1) and the number of control points -- (length cps). iSpline :: Knots (Scalar a) -> Vector a -> ISpline a toISpline :: (Spline s v, Eq v) => s v -> ISpline v evalSpline :: Spline s v => s v -> Scalar v -> v instance (Ord (Scalar v), Ord v) => Ord (ISpline v) instance (Eq (Scalar v), Eq v) => Eq (ISpline v) instance Spline ISpline v => ControlPoints ISpline v instance (VectorSpace v, Fractional (Scalar v), Ord (Scalar v)) => Spline ISpline v instance (Show (Scalar v), Show v) => Show (ISpline v) module Math.NURBS data NURBS v nurbs :: (VectorSpace v, (Scalar v) ~ w, VectorSpace w, (Scalar w) ~ w) => Knots (Scalar v) -> Vector (w, v) -> NURBS v toNURBS :: (Spline s v, (Scalar v) ~ (Scalar (Scalar v))) => s v -> NURBS v -- | Constructs the homogeneous-coordinates B-spline that corresponds to -- this NURBS curve -- -- Constructs the NURBS curve corresponding to a homogeneous-coordinates -- B-spline evalNURBS :: (VectorSpace v, (Scalar v) ~ w, VectorSpace w, (Scalar w) ~ w, Fractional w, Ord w) => NURBS v -> w -> v -- | Returns the domain of a NURBS - that is, the range of parameter values -- over which a spline with this degree and knot vector has a full basis -- set. nurbsDomain :: (Scalar v) ~ (Scalar (Scalar v)) => NURBS v -> Maybe (Scalar v, Scalar v) nurbsDegree :: NURBS v -> Int nurbsKnotVector :: (Scalar v) ~ (Scalar (Scalar v)) => NURBS v -> Knots (Scalar v) nurbsControlPoints :: NURBS v -> Vector (Scalar v, v) splitNURBS :: (VectorSpace v, (Scalar v) ~ w, VectorSpace w, (Scalar w) ~ w, Ord w, Fractional w) => NURBS v -> Scalar v -> Maybe (NURBS v, NURBS v) instance (Ord v, Ord (Scalar v), Ord (Scalar (Scalar v))) => Ord (NURBS v) instance (Eq v, Eq (Scalar v), Eq (Scalar (Scalar v))) => Eq (NURBS v) instance (Show v, Show (Scalar v), Show (Scalar (Scalar v))) => Show (NURBS v) module Math.Spline -- | A spline is a piecewise polynomial vector-valued function. The -- necessary and sufficient instance definition is toBSpline. class (VectorSpace v, Fractional (Scalar v), Ord (Scalar v)) => Spline s v splineDomain :: Spline s v => s v -> Maybe (Scalar v, Scalar v) evalSpline :: Spline s v => s v -> Scalar v -> v splineDegree :: Spline s v => s v -> Int knotVector :: Spline s v => s v -> Knots (Scalar v) toBSpline :: Spline s v => s v -> BSpline v class Spline s v => ControlPoints s v controlPoints :: ControlPoints s v => s v -> Vector v -- | Knot vectors - multisets of points in a 1-dimensional space. data Knots a -- | Create a knot vector consisting of all the knots in a list. mkKnots :: Ord a => [a] -> Knots a -- | Returns a list of all knots (not necessarily distinct) of a knot -- vector in ascending order knots :: Knots t -> [t] -- | A BezierCurve curve on 0 <= x <= 1. data BezierCurve t -- | Construct a Bezier curve from a list of control points. The degree of -- the curve is one less than the number of control points. bezierCurve :: Vector t -> BezierCurve t data BSpline t -- | bSpline kts cps creates a B-spline with the given knot vector -- and control points. The degree is automatically inferred as the -- difference between the number of spans in the knot vector -- (numKnots kts - 1) and the number of control points -- (length cps). bSpline :: Knots (Scalar a) -> Vector a -> BSpline a -- | M-Splines are B-splines normalized so that the integral of each basis -- function over the spline domain is 1. data MSpline v -- | mSpline kts cps creates a M-spline with the given knot vector -- and control points. The degree is automatically inferred as the -- difference between the number of spans in the knot vector -- (numKnots kts - 1) and the number of control points -- (length cps). mSpline :: Knots (Scalar a) -> Vector a -> MSpline a toMSpline :: Spline s v => s v -> MSpline v -- | The I-Spline basis functions are the integrals of the M-splines, or -- alternatively the integrals of the B-splines normalized to the range -- [0,1]. Every I-spline basis function increases monotonically from 0 to -- 1, thus it is useful as a basis for monotone functions. An I-Spline -- curve is monotone if and only if every non-zero control point has the -- same sign. data ISpline v -- | iSpline kts cps creates an I-spline with the given knot -- vector and control points. The degree is automatically inferred as the -- difference between the number of spans in the knot vector -- (numKnots kts - 1) and the number of control points -- (length cps). iSpline :: Knots (Scalar a) -> Vector a -> ISpline a toISpline :: (Spline s v, Eq v) => s v -> ISpline v