-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Drawings for printed text documents
--   
--   Drawings for printed text documents
@package typography-geometry
@version 1.0.0.1


-- | This module contains basic tools for geometric types and functions.
module Graphics.Typography.Geometry

-- | The type of the transformation matrices used in all geometrical
--   applications.
data Matrix2 a

-- | The application of <tt>Matrix2 a b c d</tt> to vector <tt>(x,y)</tt>
--   should be <tt>(ax+by,cx+dy)</tt>.
Matrix2 :: a -> a -> a -> a -> Matrix2 a

-- | Inverses an inversible matrix. If it is not inversible, The behaviour
--   is undefined.
inverse :: (Fractional a, Num a) => Matrix2 a -> Matrix2 a

-- | The matrix of a rotation
rotation :: Floating a => a -> Matrix2 a

-- | A class for applying geometric applications to objects
class Geometric g
translate :: Geometric g => Double -> Double -> g -> g
apply :: Geometric g => Matrix2 Double -> g -> g

-- | <tt><a>leftMost</a> a b</tt> is the leftmost point between <tt>a</tt>
--   and <tt>b</tt>.
leftMost :: (Double, Double) -> (Double, Double) -> (Double, Double)

-- | <tt><a>rightMost</a> a b</tt> is the rightmost point between
--   <tt>a</tt> and <tt>b</tt>.
rightMost :: (Double, Double) -> (Double, Double) -> (Double, Double)

-- | <tt><a>topMost</a> a b</tt> is the upper point between <tt>a</tt> and
--   <tt>b</tt>.
topMost :: (Double, Double) -> (Double, Double) -> (Double, Double)

-- | <tt><a>bottomMost</a> a b</tt> is the lower point between <tt>a</tt>
--   and <tt>b</tt>.
bottomMost :: (Double, Double) -> (Double, Double) -> (Double, Double)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Typography.Geometry.Matrix2 a)
instance GHC.Read.Read a => GHC.Read.Read (Graphics.Typography.Geometry.Matrix2 a)
instance GHC.Show.Show a => GHC.Show.Show (Graphics.Typography.Geometry.Matrix2 a)
instance Graphics.Typography.Geometry.Geometric g => Graphics.Typography.Geometry.Geometric [g]
instance GHC.Num.Num a => GHC.Num.Num (Graphics.Typography.Geometry.Matrix2 a)
instance Algebra.Polynomials.Numerical.Intervalize Graphics.Typography.Geometry.Matrix2


-- | This module contains the basic functions for manipulating Bezier
--   curves. It is heavily based on the book by N. M. Patrikalakis and T.
--   Maekawa, Shape Interrogation for Computer Aided Design and
--   Manufacturing.
module Graphics.Typography.Geometry.Bezier

-- | The type for representing all types of curves.
data Curve
Bezier :: Bernsteinp Int Double -> Bernsteinp Int Double -> Double -> Double -> Curve
[cx] :: Curve -> Bernsteinp Int Double
[cy] :: Curve -> Bernsteinp Int Double
[t0] :: Curve -> Double
[t1] :: Curve -> Double
Offset :: Bernsteinp Int Double -> Bernsteinp Int Double -> Double -> Double -> Matrix2 Double -> Curve
[cx] :: Curve -> Bernsteinp Int Double
[cy] :: Curve -> Bernsteinp Int Double
[t0] :: Curve -> Double
[t1] :: Curve -> Double
[matrix] :: Curve -> Matrix2 Double
Circle :: Double -> Double -> Double -> Double -> Matrix2 Double -> Curve
[cx0] :: Curve -> Double
[cy0] :: Curve -> Double
[t0] :: Curve -> Double
[t1] :: Curve -> Double
[matrix] :: Curve -> Matrix2 Double

-- | The basic constructor for lines : a line is a degree 1 Bezier curve
line :: Double -> Double -> Double -> Double -> Curve

-- | A shortcut to define degree 3 Bezier curves from points. If the
--   control points are <tt>a,b,c,d</tt>, the function should be called
--   with <tt><a>bezier3</a> xa ya xb yb xc yc xd yd</tt>.
bezier3 :: Double -> Double -> Double -> Double -> Double -> Double -> Double -> Double -> Curve

-- | Offsets a given Bezier curve with the given pen matrix. The original
--   pen is a circle of radius one, the matrix, if inversible, is applied
--   to it.
offset :: Matrix2 Double -> Curve -> [Curve]

-- | <tt><a>inter</a> c0 c1</tt> is a list of all possible points of
--   intersection between curves <tt>c0</tt> and <tt>c1</tt> : if
--   <tt>(u,v,w,x)</tt> is returned by <a>inter</a>, then curve <tt>c0</tt>
--   may intersect with <tt>c1</tt> between parameter values <tt>u</tt> and
--   <tt>v</tt>, which corresponds to parameter values between <tt>w</tt>
--   and <tt>x</tt> for <tt>c1</tt>. The implementation guarantees that all
--   actual solutions are found, but possibly false solutions may also be
--   returned.
inter :: Curve -> Curve -> [((Double, Double, Double, Double))]

-- | Gives the point corresponding to the given value of the parameter
evalCurve :: Curve -> Interval -> (Interval, Interval)

-- | Pseudo-distance from a point to a curve. Is the result is smaller than
--   1, the point is inside the curve. If it is greater than 1, the point
--   is outside. Else we don't know (as usual with interval arithmetic).
distance :: Interval -> Interval -> Curve -> Interval

-- | The leftmost point on a curve
left :: Curve -> (Double, Double)

-- | The bottommost point on a curve
bottom :: Curve -> (Double, Double)

-- | The rightmost point on a curve
right :: Curve -> (Double, Double)

-- | The topmost point on a curve
top :: Curve -> (Double, Double)
instance GHC.Classes.Eq Graphics.Typography.Geometry.Bezier.Topo
instance GHC.Show.Show Graphics.Typography.Geometry.Bezier.Curve
instance Graphics.Typography.Geometry.Geometric Graphics.Typography.Geometry.Bezier.Curve


-- | This module contains the function to approximate a list of curves with
--   degree 3 Bezier curves, using a least squares method.
module Graphics.Typography.Geometry.Approximation

-- | Approximates a list of <tt>Curves</tt> with a list of degree 3
--   Bernstein curves.
approximate :: [Curve] -> [(Bernsteinp Int Double, Bernsteinp Int Double)]


-- | This module contains the necessary calls to the other modules of
--   Metafont' to compute the outlines of a given number of pen strokes.
--   The normal way of using it is by calling <a>outlines</a>. One other
--   possible way would be :
--   
--   <pre>
--   let curves=cutAll curvesList in
--   remerge $ contour curves $ intersections curves
--   </pre>
module Graphics.Typography.Geometry.Outlines

-- | <tt><a>cutAll</a> curves</tt> is the array of all the curves, cut such
--   that each part does not intersect itself.
cutAll :: [[Curve]] -> Vector (Vector Curve)

-- | Computes the intersections between any pair of curves given as input,
--   in parallel in GHC using <tt>+RTS -N</tt>.
intersections :: Vector (Vector Curve) -> Map (Int, Int, Double) [(Int, Int, Double, Double)]

-- | <a>contour</a> takes the curves and the intersections computed as in
--   <a>intersections</a>, and outputs a list of all simple closed paths
--   defined by the curves in the input.
contour :: Vector (Vector Curve) -> Map (Int, Int, Double) [(Int, Int, Double, Double)] -> [[(Int, Int, Double, Double)]]

-- | <a>remerge</a> takes the curves, the output of <a>contour</a>, and
--   outputs the list of "remerged" curves, i.e. where the parts free of
--   self-intersections are glued back to each other.
remerge :: Vector (Vector Curve) -> [(Int, Int, Double, Double)] -> [Curve]

-- | Takes a list of curves, potentially offset, and outputs the relevants
--   part of the outlines.
outlines :: [[Curve]] -> [[Curve]]
instance GHC.Show.Show Graphics.Typography.Geometry.Outlines.Topology
instance GHC.Classes.Ord Graphics.Typography.Geometry.Outlines.Topology
instance GHC.Classes.Eq Graphics.Typography.Geometry.Outlines.Topology
