Copyright | (c) 2013 Daniel Bergey |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | bergey@alum.mit.edu |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Solve equations due to John Hobby, as implemented in Donald Knuth's Metafont, to create (usually) smooth paths from specified points and directions.
Synopsis
- solve :: RealFloat n => MFP n -> MFPath (Dir n) (BasicJoin n) n
- computeControls :: RealFloat n => MetafontSegment (Dir n) (BasicJoin n) n -> MetafontSegment () (ControlJoin n) n
- locatedTrail :: (Floating n, Ord n) => MFPath () (ControlJoin n) n -> Located (Trail V2 n)
- mfPathToSegments :: forall n. Num n => MFPathData P n -> MFP n
Documentation
solve :: RealFloat n => MFP n -> MFPath (Dir n) (BasicJoin n) n Source #
Run all the rules required to fully specify all segment directions, but do not replace the Joins with ControlJoin.
computeControls :: RealFloat n => MetafontSegment (Dir n) (BasicJoin n) n -> MetafontSegment () (ControlJoin n) n Source #
Take a segment whose endpoint directions have been fully
determined, and compute the control points to realize it as a
cubic Bézier segment. If the segment already has control points
specified, the directions are ignored (they are assumed to
match). If the segment tensions are specified as TensionAtLeast,
check whether the minimum tension will lead to an inflection
point. If so, pick the maximum velocity (equivalent to minimum
tension) that avoids the inflection point. Otherwise, calculate
the velocity from the tension using hobbyF
. Then calculate the
control point positions from the direction and the velocity.
Afterwards we can forget the direction information (since the
control points are what we really want, and the directions can be
recovered by subtracting the control points from the endpoints
anyway).
locatedTrail :: (Floating n, Ord n) => MFPath () (ControlJoin n) n -> Located (Trail V2 n) Source #
Convert a MetaFont path to a Diagrams Trail, using a Loop or Line as needed
mfPathToSegments :: forall n. Num n => MFPathData P n -> MFP n Source #
Convert a path in combinator syntax to the internal representation used for solving.