 CurveFitting - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Statistics and Data Analysis : Interpolation and Curve Fitting : CurveFitting Package : CurveFitting/BSplineCurve

CurveFitting

 BSplineCurve
 compute a B-spline curve

 Calling Sequence BSplineCurve(xydata, v, opts) BSplineCurve(xdata, ydata, v, opts)

Parameters

 xydata - list, Array, DataFrame, or Matrix of the form [[x1,y1], [x2,y2], ... , [xn,yn]]; data points xdata - list, Array, DataSeries, or Vector of the form [x1, x2, ..., xn]; independent values ydata - list, Array, DataSeries, or Vector or the form [y1, y2, ..., yn]; dependent values v - name opts - (optional) one or more equations of the form order=k or knots=knotlist

Description

 • The BSplineCurve routine computes a B-spline curve based on the control points $\left\{\left(\mathrm{x1},\mathrm{y1}\right),\left(\mathrm{x2},\mathrm{y2}\right),...,\left(\mathrm{xn},\mathrm{yn}\right)\right\}$.  The resulting curve is in parametric form $\left[\mathrm{xf}\left(v\right),\mathrm{yf}\left(v\right),v=a..b\right]$, where $\mathrm{xf}\left(v\right)$ and $\mathrm{yf}\left(v\right)$ are piecewise functions of v, and $a..b$ is the range over which the B-spline curve is defined.
 • The BSplineCurve routine can be called in two ways.
 The first form accepts a list, Array, or Matrix, $[[\mathrm{x1},\mathrm{y1}],[\mathrm{x2},\mathrm{y2}],...,[\mathrm{xn},\mathrm{yn}]]$, of data points.
 The second form accepts the input data as two lists, two Arrays, or two Vectors. In this form, the first set of data contains the independent values, $[\mathrm{x1},\mathrm{x2},...,\mathrm{xn}]$, and the second set of data contains the dependent values, $[\mathrm{y1},\mathrm{y2},...,\mathrm{yn}]$.  Each element must be of type algebraic.
 • A cubic (order 4) B-spline curve is produced, unless the order=k (where $0 ) option is provided. An order k B-spline curve has polynomial pieces of degree less than k.
 • A uniform knot list is used by the procedure, but a different knot list can be specified using the knots=knotlist option.  The list knotlist must contain exactly $n+k$ values.  These values must be in nondecreasing order; otherwise, unexpected results may be produced.  If the knots=knotlist option is the only option provided, then an order 4 B-spline is assumed.  Knots can have a multiplicity up to $k-1$.  If the multiplicity of a knot is m, then the continuity at that knot is $C\left(k-m-1\right)$.
 • The B-spline curve is defined only on the range $v={\mathrm{knotlist}}_{k}\mathrm{...}{\mathrm{knotlist}}_{n+1}$.  For any value of v in this range, all k blending functions are present in the B-spline curve.  These blending functions are computed by the CurveFitting[BSpline] procedure.
 • This function is part of the CurveFitting package, and so it can be used in the form BSplineCurve(..) only after executing the command with(CurveFitting).  However, it can always be accessed through the long form of the command by using CurveFitting[BSplineCurve](..).

Examples

The following example produces a cubic (order 4) B-spline curve using a uniform knot list.

 > $\mathrm{with}\left(\mathrm{CurveFitting}\right):$
 > $\mathrm{xydata}≔\left[\left[0,0\right],\left[1,1\right],\left[4,9\right],\left[6,10\right],\left[8,5\right],\left[8,3\right]\right]$
 ${\mathrm{xydata}}{≔}\left[\left[{0}{,}{0}\right]{,}\left[{1}{,}{1}\right]{,}\left[{4}{,}{9}\right]{,}\left[{6}{,}{10}\right]{,}\left[{8}{,}{5}\right]{,}\left[{8}{,}{3}\right]\right]$ (1)
 > $\mathrm{c1}≔\mathrm{BSplineCurve}\left(\mathrm{xydata},v\right)$
 ${\mathrm{c1}}{≔}\left[\left\{\begin{array}{cc}{0}& {v}{<}{1}\\ \frac{{\left({v}{-}{1}\right)}^{{3}}}{{6}}& {v}{<}{2}\\ {-}\frac{{5}}{{6}}{+}\frac{{v}}{{2}}{+}\frac{{\left({v}{-}{2}\right)}^{{2}}}{{2}}{+}\frac{{\left({v}{-}{2}\right)}^{{3}}}{{6}}& {v}{<}{3}\\ {-}\frac{{14}}{{3}}{+}{\left({v}{-}{3}\right)}^{{2}}{-}\frac{{\left({v}{-}{3}\right)}^{{3}}}{{2}}{+}{2}{}{v}& {v}{<}{4}\\ {-}\frac{{37}}{{6}}{+}\frac{{5}{}{v}}{{2}}{-}\frac{{\left({v}{-}{4}\right)}^{{2}}}{{2}}{+}\frac{{\left({v}{-}{4}\right)}^{{3}}}{{6}}& {v}{<}{5}\\ {-}{4}{+}{2}{}{v}{-}\frac{{\left({v}{-}{5}\right)}^{{3}}}{{3}}& {v}{<}{6}\\ \frac{{5}}{{3}}{+}{v}{-}{\left({v}{-}{6}\right)}^{{2}}{-}{\left({v}{-}{6}\right)}^{{3}}& {v}{<}{7}\\ \frac{{104}}{{3}}{-}{4}{}{v}{-}{4}{}{\left({v}{-}{7}\right)}^{{2}}{+}\frac{{8}{}{\left({v}{-}{7}\right)}^{{3}}}{{3}}& {v}{<}{8}\\ \frac{{100}}{{3}}{-}{4}{}{v}{+}{4}{}{\left({v}{-}{8}\right)}^{{2}}{-}\frac{{4}{}{\left({v}{-}{8}\right)}^{{3}}}{{3}}& {v}{<}{9}\\ {0}& {9}{\le }{v}\end{array}\right\{,}\left\{\begin{array}{cc}{0}& {v}{<}{1}\\ \frac{{\left({v}{-}{1}\right)}^{{3}}}{{6}}& {v}{<}{2}\\ {-}\frac{{5}}{{6}}{+}\frac{{v}}{{2}}{+}\frac{{\left({v}{-}{2}\right)}^{{2}}}{{2}}{+}{\left({v}{-}{2}\right)}^{{3}}& {v}{<}{3}\\ {-}\frac{{34}}{{3}}{+}\frac{{7}{}{\left({v}{-}{3}\right)}^{{2}}}{{2}}{-}\frac{{7}{}{\left({v}{-}{3}\right)}^{{3}}}{{3}}{+}\frac{{9}{}{v}}{{2}}& {v}{<}{4}\\ {-}\frac{{61}}{{6}}{+}\frac{{9}{}{v}}{{2}}{-}\frac{{7}{}{\left({v}{-}{4}\right)}^{{2}}}{{2}}{+}\frac{{\left({v}{-}{4}\right)}^{{3}}}{{6}}& {v}{<}{5}\\ {19}{-}{2}{}{v}{-}{3}{}{\left({v}{-}{5}\right)}^{{2}}{+}\frac{{3}{}{\left({v}{-}{5}\right)}^{{3}}}{{2}}& {v}{<}{6}\\ \frac{{53}}{{2}}{-}\frac{{7}{}{v}}{{2}}{+}\frac{{3}{}{\left({v}{-}{6}\right)}^{{2}}}{{2}}{-}\frac{{2}{}{\left({v}{-}{6}\right)}^{{3}}}{{3}}& {v}{<}{7}\\ \frac{{61}}{{3}}{-}\frac{{5}{}{v}}{{2}}{-}\frac{{\left({v}{-}{7}\right)}^{{2}}}{{2}}{+}\frac{{2}{}{\left({v}{-}{7}\right)}^{{3}}}{{3}}& {v}{<}{8}\\ \frac{{25}}{{2}}{-}\frac{{3}{}{v}}{{2}}{+}\frac{{3}{}{\left({v}{-}{8}\right)}^{{2}}}{{2}}{-}\frac{{\left({v}{-}{8}\right)}^{{3}}}{{2}}& {v}{<}{9}\\ {0}& {9}{\le }{v}\end{array}\right\{,}{v}{=}{3}{..}{6}\right]$ (2)

Use the plot command to see the resulting curve on the defined range, along with the boundary defined by the input points.

 > $\mathrm{plot}\left(\left\{\mathrm{c1},\mathrm{xydata}\right\}\right)$ The next example produces a quadratic (order 3) B-spline from the same input points, but with multiply-defined knot values.

 > $\mathrm{c2}≔\mathrm{BSplineCurve}\left(\mathrm{xydata},v,\mathrm{order}=3,\mathrm{knots}=\left[0,0,1,2,3,3,4,5,6\right]\right)$
 ${\mathrm{c2}}{≔}\left[\left\{\begin{array}{cc}{0}& {v}{<}{0}\\ \frac{{{v}}^{{2}}}{{2}}& {v}{<}{1}\\ {-}\frac{{1}}{{2}}{+}{v}{+}{\left({v}{-}{1}\right)}^{{2}}& {v}{<}{2}\\ {-}\frac{{7}}{{2}}{+}{3}{}{v}{+}\frac{{\left({v}{-}{2}\right)}^{{2}}}{{2}}& {v}{<}{3}\\ {-}{6}{+}{4}{}{v}{-}{2}{}{\left({v}{-}{3}\right)}^{{2}}& {v}{<}{4}\\ {8}{-}{4}{}{\left({v}{-}{4}\right)}^{{2}}& {v}{<}{5}\\ {44}{-}{8}{}{v}{+}{4}{}{\left({v}{-}{5}\right)}^{{2}}& {v}{<}{6}\\ {0}& {6}{\le }{v}\end{array}\right\{,}\left\{\begin{array}{cc}{0}& {v}{<}{0}\\ \frac{{{v}}^{{2}}}{{2}}& {v}{<}{1}\\ {-}\frac{{1}}{{2}}{+}{v}{+}\frac{{7}{}{\left({v}{-}{1}\right)}^{{2}}}{{2}}& {v}{<}{2}\\ {-}{11}{+}{8}{}{v}{-}{3}{}{\left({v}{-}{2}\right)}^{{2}}& {v}{<}{3}\\ {40}{-}{10}{}{v}{+}{4}{}{\left({v}{-}{3}\right)}^{{2}}& {v}{<}{4}\\ {12}{-}{2}{}{v}{-}\frac{{\left({v}{-}{4}\right)}^{{2}}}{{2}}& {v}{<}{5}\\ \frac{{33}}{{2}}{-}{3}{}{v}{+}\frac{{3}{}{\left({v}{-}{5}\right)}^{{2}}}{{2}}& {v}{<}{6}\\ {0}& {6}{\le }{v}\end{array}\right\{,}{v}{=}{1}{..}{4}\right]$ (3)
 > $\mathrm{plot}\left(\left\{\mathrm{c2},\mathrm{xydata}\right\}\right)$ See Also