Safe Haskell | None |
---|---|
Language | Haskell98 |
Geom2D.CubicBezier.Basic
- data CubicBezier a = CubicBezier {}
- data QuadBezier a = QuadBezier {}
- data AnyBezier a = AnyBezier (Vector (a, a))
- class GenericBezier b where
- data PathJoin a
- data ClosedPath a = ClosedPath [(Point a, PathJoin a)]
- data OpenPath a = OpenPath [(Point a, PathJoin a)] (Point a)
- class AffineTransform a b | a -> b where
- anyToCubic :: Unbox a => AnyBezier a -> Maybe (CubicBezier a)
- anyToQuad :: Unbox a => AnyBezier a -> Maybe (QuadBezier a)
- openPathCurves :: Fractional a => OpenPath a -> [CubicBezier a]
- closedPathCurves :: Fractional a => ClosedPath a -> [CubicBezier a]
- curvesToOpen :: [CubicBezier a] -> OpenPath a
- curvesToClosed :: [CubicBezier a] -> ClosedPath a
- consOpenPath :: Point a -> PathJoin a -> OpenPath a -> OpenPath a
- consClosedPath :: Point a -> PathJoin a -> ClosedPath a -> ClosedPath a
- openClosedPath :: ClosedPath a -> OpenPath a
- closeOpenPath :: OpenPath a -> ClosedPath a
- bezierParam :: (Ord a, Num a) => a -> Bool
- bezierParamTolerance :: GenericBezier b => b Double -> Double -> Double
- reorient :: (GenericBezier b, Unbox a) => b a -> b a
- bezierToBernstein :: (GenericBezier b, Unbox a) => b a -> (BernsteinPoly a, BernsteinPoly a)
- evalBezierDerivs :: (GenericBezier b, Unbox a, Fractional a) => b a -> a -> [Point a]
- evalBezier :: (GenericBezier b, Unbox a, Fractional a) => b a -> a -> Point a
- evalBezierDeriv :: (Unbox a, Fractional a) => GenericBezier b => b a -> a -> (Point a, Point a)
- findBezierTangent :: DPoint -> CubicBezier Double -> [Double]
- quadToCubic :: Fractional a => QuadBezier a -> CubicBezier a
- bezierHoriz :: CubicBezier Double -> [Double]
- bezierVert :: CubicBezier Double -> [Double]
- findBezierInflection :: CubicBezier Double -> [Double]
- findBezierCusp :: CubicBezier Double -> [Double]
- bezierArc :: Double -> Double -> CubicBezier Double
- arcLength :: CubicBezier Double -> Double -> Double -> Double
- arcLengthParam :: CubicBezier Double -> Double -> Double -> Double
- splitBezier :: (Unbox a, Fractional a) => GenericBezier b => b a -> a -> (b a, b a)
- bezierSubsegment :: (Ord a, Unbox a, Fractional a) => GenericBezier b => b a -> a -> a -> b a
- splitBezierN :: (Ord a, Unbox a, Fractional a) => GenericBezier b => b a -> [a] -> [b a]
- colinear :: CubicBezier Double -> Double -> Bool
- closest :: CubicBezier Double -> DPoint -> Double -> Double
- findX :: CubicBezier Double -> Double -> Double -> Double
Documentation
data CubicBezier a #
A cubic bezier curve.
Constructors
CubicBezier | |
Instances
Functor CubicBezier # | |
Foldable CubicBezier # | |
Traversable CubicBezier # | |
GenericBezier CubicBezier # | |
Eq a => Eq (CubicBezier a) # | |
Show a => Show (CubicBezier a) # | |
Num a => AffineTransform (CubicBezier a) a # | |
data QuadBezier a #
A quadratic bezier curve.
Instances
Functor QuadBezier # | |
Foldable QuadBezier # | |
Traversable QuadBezier # | |
GenericBezier QuadBezier # | |
Eq a => Eq (QuadBezier a) # | |
Show a => Show (QuadBezier a) # | |
Num a => AffineTransform (QuadBezier a) a # | |
A bezier curve of any degree.
Instances
class GenericBezier b where #
Minimal complete definition
Methods
degree :: Unbox a => b a -> Int #
toVector :: Unbox a => b a -> Vector (a, a) #
unsafeFromVector :: Unbox a => Vector (a, a) -> b a #
Instances
data ClosedPath a #
Constructors
ClosedPath [(Point a, PathJoin a)] |
Instances
Functor ClosedPath # | |
Foldable ClosedPath # | |
Traversable ClosedPath # | |
Show a => Show (ClosedPath a) # | |
Num a => AffineTransform (ClosedPath a) a # | |
class AffineTransform a b | a -> b where #
Minimal complete definition
Instances
Num a => AffineTransform (Polygon a) a # | |
Num a => AffineTransform (Transform a) a # | |
Num a => AffineTransform (Point a) a # | |
Num a => AffineTransform (ClosedPath a) a # | |
Num a => AffineTransform (OpenPath a) a # | |
Num a => AffineTransform (PathJoin a) a # | |
Num a => AffineTransform (QuadBezier a) a # | |
Num a => AffineTransform (CubicBezier a) a # | |
(Floating a, Eq a) => AffineTransform (Pen a) a # | |
anyToCubic :: Unbox a => AnyBezier a -> Maybe (CubicBezier a) #
safely convert from AnyBezier
to CubicBezier
anyToQuad :: Unbox a => AnyBezier a -> Maybe (QuadBezier a) #
safely convert from AnyBezier
to QuadBezier
openPathCurves :: Fractional a => OpenPath a -> [CubicBezier a] #
Return the open path as a list of curves.
closedPathCurves :: Fractional a => ClosedPath a -> [CubicBezier a] #
Return the closed path as a list of curves
curvesToOpen :: [CubicBezier a] -> OpenPath a #
Make an open path from a list of curves. The last control point of each curve except the last is ignored.
curvesToClosed :: [CubicBezier a] -> ClosedPath a #
Make an open path from a list of curves. The last control point of each curve is ignored.
consClosedPath :: Point a -> PathJoin a -> ClosedPath a -> ClosedPath a #
construct a closed path
openClosedPath :: ClosedPath a -> OpenPath a #
open a closed path
closeOpenPath :: OpenPath a -> ClosedPath a #
close an open path, discarding the last point
bezierParam :: (Ord a, Num a) => a -> Bool #
Return True if the param lies on the curve, iff it's in the interval [0, 1]
.
bezierParamTolerance :: GenericBezier b => b Double -> Double -> Double #
Convert a tolerance from the codomain to the domain of the bezier curve, by dividing by the maximum velocity on the curve. The estimate is conservative, but holds for any value on the curve.
reorient :: (GenericBezier b, Unbox a) => b a -> b a #
Reorient to the curve B(1-t).
bezierToBernstein :: (GenericBezier b, Unbox a) => b a -> (BernsteinPoly a, BernsteinPoly a) #
Give the bernstein polynomial for each coordinate.
evalBezierDerivs :: (GenericBezier b, Unbox a, Fractional a) => b a -> a -> [Point a] #
Evaluate the bezier and all its derivatives using the modified horner algorithm.
evalBezier :: (GenericBezier b, Unbox a, Fractional a) => b a -> a -> Point a #
Calculate a value on the bezier curve.
evalBezierDeriv :: (Unbox a, Fractional a) => GenericBezier b => b a -> a -> (Point a, Point a) #
Calculate a value and the first derivative on the curve.
findBezierTangent :: DPoint -> CubicBezier Double -> [Double] #
findBezierTangent p b
finds the parameters where
the tangent of the bezier curve b
has the same direction as vector p.
quadToCubic :: Fractional a => QuadBezier a -> CubicBezier a #
Convert a quadratic bezier to a cubic bezier.
bezierHoriz :: CubicBezier Double -> [Double] #
Find the parameter where the bezier curve is horizontal.
bezierVert :: CubicBezier Double -> [Double] #
Find the parameter where the bezier curve is vertical.
findBezierInflection :: CubicBezier Double -> [Double] #
Find inflection points on the curve. Use the formula B_x''(t) * B_y'(t) - B_y''(t) * B_x'(t) = 0 with B_x'(t) the x value of the first derivative at t, B_y''(t) the y value of the second derivative at t
findBezierCusp :: CubicBezier Double -> [Double] #
Find the cusps of a bezier.
bezierArc :: Double -> Double -> CubicBezier Double #
bezierArc startAngle endAngle
approximates an arc on the unit circle with
a single cubic béziér curve. Maximum deviation is <0.03% for arcs
90° degrees or less.
arcLength :: CubicBezier Double -> Double -> Double -> Double #
@arcLength c t tol finds the arclength of the bezier c at t, within given tolerance tol.
arcLengthParam :: CubicBezier Double -> Double -> Double -> Double #
arcLengthParam c len tol finds the parameter where the curve c has the arclength len, within tolerance tol.
splitBezier :: (Unbox a, Fractional a) => GenericBezier b => b a -> a -> (b a, b a) #
Split a bezier curve into two curves.
bezierSubsegment :: (Ord a, Unbox a, Fractional a) => GenericBezier b => b a -> a -> a -> b a #
Return the subsegment between the two parameters.
splitBezierN :: (Ord a, Unbox a, Fractional a) => GenericBezier b => b a -> [a] -> [b a] #
Split a bezier curve into a list of beziers The parameters should be in ascending order or the result is unpredictable.
colinear :: CubicBezier Double -> Double -> Bool #
Return False if some points fall outside a line with a thickness of the given tolerance.