diagrams-lib-1.1.0.3: Embedded domain-specific language for declarative graphics

Copyright(c) 2011 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.CubicSpline

Contents

Description

A cubic spline is a smooth, connected sequence of cubic curves passing through a given sequence of points. This module provides the cubicSpline method, which can be used to create closed or open cubic splines from a list of points. For access to the internals of the spline generation algorithm (including in particular a solver for cyclic tridiagonal systems of linear equations), see Diagrams.CubicSpline.Internal.

Synopsis

Constructing paths from cubic splines

cubicSpline :: (TrailLike t, Fractional (V t)) => Bool -> [Point (V t)] -> t Source

Construct a spline path-like thing of cubic segments from a list of vertices, with the first vertex as the starting point. The first argument specifies whether the path should be closed.

pts = map p2 [(0,0), (2,3), (5,-2), (-4,1), (0,3)]
dot = circle 0.2 # fc blue # lw 0
mkPath closed = position (zip pts (repeat dot))
             <> cubicSpline closed pts # lw 0.05
cubicSplineEx = (mkPath False ||| strutX 2 ||| mkPath True)
              # centerXY # pad 1.1

For more information, see http://mathworld.wolfram.com/CubicSpline.html.