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

Math.BernsteinPoly

Description

Algebra on polynomials in the Bernstein form. It is based on the paper /Algebraic manipulation in the Bernstein form made simple via convolutions/ by J. Sanchez-Reyes. It's an efficient implementation using the scaled basis, and using ghc rewrite rules to eliminate intermediate polynomials.

Synopsis

# Documentation

data BernsteinPoly a Source #

Constructors

 BernsteinPoly FieldsbernsteinCoeffs :: Vector a

Instances

 (Unbox a, Show a) => Show (BernsteinPoly a) Source # MethodsshowsPrec :: Int -> BernsteinPoly a -> ShowS #show :: BernsteinPoly a -> String #showList :: [BernsteinPoly a] -> ShowS #

bernsteinSubsegment :: (Unbox a, Ord a, Fractional a) => BernsteinPoly a -> a -> a -> BernsteinPoly a Source #

Return the subsegment between the two parameters.

listToBernstein :: (Unbox a, Num a) => [a] -> BernsteinPoly a Source #

Create a bernstein polynomail from a list of coëfficients.

zeroPoly :: (Num a, Unbox a) => BernsteinPoly a Source #

The constant zero.

(~*) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a infixl 7 Source #

Multiply two bernstein polynomials using convolution. The final degree will be the sum of either degrees. This operation takes O((n+m)^2) with n and m the degree of the beziers. Note that convolution can be done in O(n log n) using the FFT, which may be faster for large polynomials.

(*~) :: (Unbox a, Num a) => a -> BernsteinPoly a -> BernsteinPoly a infixl 7 Source #

Scale a bernstein polynomial by a constant.

(~+) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a infixl 6 Source #

Sum two bernstein polynomials. The final degree will be the maximum of either degrees.

(~-) :: (Unbox a, Fractional a) => BernsteinPoly a -> BernsteinPoly a -> BernsteinPoly a infixl 6 Source #

Subtract two bernstein polynomials. The final degree will be the maximum of either degrees.

bernsteinSplit :: (Unbox a, Num a) => BernsteinPoly a -> a -> (BernsteinPoly a, BernsteinPoly a) Source #

Split a bernstein polynomial

bernsteinEval :: (Unbox a, Fractional a) => BernsteinPoly a -> a -> a Source #

Evaluate the bernstein polynomial using the horner rule adapted for bernstein polynomials.

bernsteinEvalDeriv :: (Unbox t, Fractional t) => BernsteinPoly t -> t -> (t, t) Source #

Evaluate the bernstein polynomial and first derivative

binCoeff :: (Num a, Unbox a) => Int -> Vector a Source #

Give the binomial coefficients of degree n.

convolve :: (Unbox a, Num a) => Vector a -> Vector a -> Vector a Source #

Calculate the convolution of two vectors.

bernsteinEvalDerivs :: (Unbox t, Fractional t) => BernsteinPoly t -> t -> [t] Source #

Evaluate the bernstein polynomial and its derivatives.

bernsteinDeriv :: (Unbox a, Num a) => BernsteinPoly a -> BernsteinPoly a Source #

Find the derivative of a bernstein polynomial.