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

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

Diagrams.CubicSpline.Boehm

Description

Boehm's algorithm for converting a cubic B-spline into a sequence of cubic Bezier curves.

See

Synopsis

Documentation

type BSpline v n = [Point v n] Source #

bsplineToBeziers :: (Additive v, Fractional n, Num n, Ord n) => BSpline v n -> [FixedSegment v n] Source #

Convert a uniform cubic B-spline to a sequence of cubic beziers. (Uniform refers to the fact that the knots are assumed to be evenly spaced, with no duplicates.) The knots at the end are replicated so the cubic spline begins and ends at the first and last control points, tangent to the line from the end control point to the next.

bspline :: (TrailLike t, V t ~ v, N t ~ n) => BSpline v n -> t Source #

Generate a uniform cubic B-spline from the given control points. The spline starts and ends at the first and last control points, and is tangent to the line to the second(-to-last) control point. It does not necessarily pass through any of the other control points.

pts = map p2 [(0,0), (2,3), (5,-2), (-4,1), (0,3)]
spot = circle 0.2 # fc blue # lw none
bsplineEx = mconcat
  [ position (zip pts (repeat spot))
  , bspline pts
  ]
  # frame 0.5