Bézier Surface Fitting and Evaluation

Version 1.0.3 (5.08 KB) by Moreno, M.
Fast Bézier surface fitting and evaluation via linear and non-linear least squares.
99 Downloads
Updated 14 Jun 2022

View License

Syntax
Fitting
y = bsfit(x,n)
y = bsfit(x,n,u,v)
[y,res,u,v,val] = bsfit(x,n,u,v,varargin)
Evaluation
[x,y,z] = bsval(x,u,v)
Description
Fitting
[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.
Evaluation
[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.

Cite As

Moreno, M. (2024). Bézier Surface Fitting and Evaluation (https://www.mathworks.com/matlabcentral/fileexchange/112470-bezier-surface-fitting-and-evaluation), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.3

Function optimisation, significant speed boost. Change of files and description text.

1.0.2

Correction of the reshaping index in bsurfeval for the case where no knot vectors are parsed as inputs

1.0.1

Typo parsing input arguments in bsurfit. Enhancement of bsurfeval input argument checks.

1.0.0