y = bsfit(x,n)
y = bsfit(x,n,u,v)
[y,res,u,v,val] = bsfit(x,n,u,v,varargin)
[x,y,z] = bsval(x,u,v)
[y,res,u,v,val] = bsfit(x,n,u,v,varargin) Returns the control points 'y' of the best-fitting Bézier surface of order 'n' by 'n' to a data set 'x' of scattered points. A vector of 'u' and 'v' knots can be parsed as an input, as well as the following pairs of parameter-vales:
'nlls' Specifies a non-linear least squares calculation
'tol' Specifies a fit tolerance for the non-linear iterations
'iter' Specifies a maximum number of non-linear iterations
'bico' Specifies the binomial coefficients of order 'n+1'
'coef' Specifies a relaxation factor for the knot correction
'plot' Generates a figure with the residual convergence
The average residual 'res', knot vectors 'u' and 'v' and the surface evaluation 'val' in the previous knots can be queried as output. The unstructured point cloud 'x' must be a three-dimensional column matrix.
The research paper of reference for this function is:
Lifton, J., Liu, T. and McBride, J., 'Non-Linear Least Squares Fitting of Bézier Surfaces to Unstructured Point Clouds'. AIMS Mathematics, 6(4), 3142-3159.
The help of the research paper author Joseph Lifton has ben of paramount importance.
[x,y,z] = bsval(x,u,v) Evaluates the Bézier surface of order n+1, n+1 that results from the [n*n, 3] control point matrix 'x' with knots 'u' and 'v'. If the knot vectors are not parsed, a grid of 100 by 100 knots is used.
The function returns the scattered surface points if only one output is specified, and the gridded surface points otherwise. The nomenclature of this function is as per bsfit and the aforementioned research paper.