Copyright | (c) 2015 diagrams-lib team (see LICENSE) |
---|---|

License | BSD-style (see LICENSE) |

Maintainer | diagrams-discuss@googlegroups.com |

Safe Haskell | None |

Language | Haskell2010 |

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

See

- Thomas W. Sederberg,
*An Introduction to B-Spline Curves*, http://web.archive.org/web/20120227050519/http://tom.cs.byu.edu/~455/bs.pdf - Lyle Ramshaw,
*Blossoming: A Connect-the-Dots Approach to Splines*, http://www.hpl.hp.com/techreports/Compaq-DEC/SRC-RR-19.pdf

- type BSpline v n = [Point v n]
- bsplineToBeziers :: (Additive v, Fractional n, Num n, Ord n) => BSpline v n -> [FixedSegment v n]
- bspline :: (TrailLike t, V t ~ v, N t ~ n) => BSpline v n -> t

# Documentation

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