cubicbezier-0.4.0.1: Efficient manipulating of 2D cubic bezier curves.

Safe HaskellNone
LanguageHaskell98

Geom2D.CubicBezier.Approximate

Synopsis

Documentation

interpolate :: Num a => a -> a -> a -> a Source

approximatePath Source

Arguments

:: (Unbox a, Ord a, Floating a) 
=> (a -> (Point a, Point a))

The function to approximate and it's derivative

-> Int

The number of discrete samples taken to approximate each subcurve. More samples are more precise but take more time to calculate. For good precision 16 is a good candidate.

-> a

The tolerance

-> a

The lower parameter of the function

-> a

The upper parameter of the function

-> Bool

Calculate the result faster, but with more subcurves. Runs typically 10 times faster, but generates 50% more subcurves. Useful for interactive use.

-> [CubicBezier a] 

Approximate a function with piecewise cubic bezier splines using a least-squares fit, within the given tolerance. Each subcurve is approximated by using a finite number of samples. It is recommended to avoid changes in direction by subdividing the original function at points of inflection.

approximateQuadPath Source

Arguments

:: (Show a, Unbox a, Ord a, Floating a) 
=> (a -> (Point a, Point a))

The function to approximate and it's derivative

-> a

The tolerance

-> a

The lower parameter of the function

-> a

The upper parameter of the function

-> Bool

Calculate the result faster, but with more subcurves.

-> [QuadBezier a] 

Approximate a function with piecewise quadratic bezier splines using a least-squares fit, within the given tolerance. It is recommended to avoid changes in direction by subdividing the original function at points of inflection.

quadDist :: (Unbox a, Floating a) => (a -> (Point a, Point a)) -> QuadBezier a -> a -> a -> a -> a Source

phi :: Floating a => a Source

goldSearch :: (Ord a, Floating a) => (a -> a) -> a Source

goldSearch' :: (Ord a, Floating a) => (a -> a) -> a -> a -> a -> a -> a -> a -> a -> a -> Int -> a Source

maxDist :: (Unbox a, Ord a, Floating a) => (a -> (Point a, Point a)) -> QuadBezier a -> a -> a -> a Source

approxquad :: (Ord a, Floating a) => Point a -> Point a -> Point a -> Point a -> QuadBezier a Source

approx1quad :: (Ord a, Floating a) => (a -> (Point a, Point a)) -> a -> a -> QuadBezier a Source

splitQuad :: (Show a, Unbox a, Ord a, Floating a) => a -> a -> (a -> (Point a, Point a)) -> a -> a -> Int -> (a, a, QuadBezier a, a, QuadBezier a) Source

approximateQuad' :: (Show a, Unbox a, Ord a, Floating a) => (a -> (Point a, Point a)) -> a -> a -> a -> Bool -> [QuadBezier a] Source

approximatePath' :: (Unbox a, Ord a, Floating a) => (a -> (Point a, Point a)) -> Int -> a -> a -> a -> Bool -> [CubicBezier a] Source

approximatePathMax Source

Arguments

:: (Unbox a, Floating a, Ord a) 
=> Int

The maximum number of subcurves

-> (a -> (Point a, Point a))

The function to approximate and it's derivative

-> Int

The number of discrete samples taken to approximate each subcurve. More samples are more precise but take more time to calculate. For good precision 16 is a good candidate.

-> a

The tolerance

-> a

The lower parameter of the function

-> a

The upper parameter of the function

-> Bool

Calculate the result faster, but with more subcurves. Runs typically 10 times faster, but generates 50% more subcurves. Useful for interactive use.

-> [CubicBezier a] 

Like approximatePath, but limit the number of subcurves.

data FunctionSegment a Source

Constructors

FunctionSegment 

Fields

fsTmin :: !a
 
_fsTmax :: !a
 
fsCurve :: CubicBezier a
 

approxMax :: (Unbox a, Ord a, Floating a) => (a -> (Point a, Point a)) -> a -> Int -> Vector a -> Bool -> Map a (FunctionSegment a) -> [CubicBezier a] Source

splitCubic :: (Unbox a, Ord a, Floating a) => a -> a -> Int -> (a -> (Point a, Point a)) -> a -> a -> Int -> (a, a, CubicBezier a, a, CubicBezier a) Source

approx1cubic :: (Unbox a, Ord a, Floating a) => Int -> (a -> (Point a, Point a)) -> a -> a -> Int -> (CubicBezier a, a) Source

approximateCubic Source

Arguments

:: (Unbox a, Ord a, Floating a) 
=> CubicBezier a

Curve

-> Vector (Point a)

Points

-> Maybe (Vector a)

Params. Approximate if Nothing

-> Int

Maximum iterations

-> (CubicBezier a, a)

result curve and maximum error

approximateCubic b pts maxiter finds the least squares fit of a bezier curve to the points pts. The resulting bezier has the same first and last control point as the curve b, and have tangents colinear with b.

leastSquares :: (Unbox a, Fractional a, Eq a) => Vector a -> Vector a -> Vector a -> Maybe (a, a) Source

approximateCubic' :: (Unbox a, Ord a, Floating a) => CubicBezier a -> Vector (Point a) -> Vector a -> Int -> a -> Vector (Point a) -> Vector (Point a) -> Maybe (CubicBezier a, Vector a, Vector a, a, Vector (Point a)) Source