Bezier curve

Creates a Bezier curve from 2D points (up to 1000) and can create an interpolated curve from it.
2,9K descargas
Actualizado 12 sep 2011

Ver licencia

From any points in the plane, the program creates a Bezier curve (with eligible points) and can interpolate the generated points for any x set: the lower the number, the smoother the final curve. The user chooses whether an interpolated curve and a graph with points curves are created.
The interpolation curve can be applied to scatter or noisy xy data, in order to resample and smooth the original data.

function [bezcurve, intcurveyy] = bezier_(points, numofpbc, intcurvexx, fig)

Creates Bezier curve (output 'bezcurve') from 'points' (1st input argument) and the number of points (2nd input argument) and can create from it another interpolated curve (whose x-coordinates are in the input 'intcurvexx' and whose y-coordinates are in the output 'intcurveyy').

INPUTS:
points: matrix ((n+1) x 2) with the original points in xy plane
numofpbc: number of points in the Bezier curve (by default 100)
intcurvexx: vector with x-coordinates of the interpolation curve. If this argument does not exist or is empty, the program generates Bezier curve, but no interpolation curve
fig: any value if you want a figure of points and curve (otherwise, do not enter 4th argument). You can enter here the representing symbol for the points (for instance, 'ks' for black squares).

OUTPUTS:
bezcurve: the Bezier curve, not interpolated, in the format [x y], i.e. a (numofpbc x 2) matrix.
intcurveyy: vector with y-coordinates (by non-parametric interpolation from intcurvexx) of the interpolation curve; it has sense only if intcurvexx elements are monotonically increasing.

Example: x = (1:100)';
y = 0.2*randn(size(x)) - sin(pi*x/100) + 0.5*x/100;
points = [x y];
bezier_(points, 500, [], 1); % Creates only the Bezier curve and represents it together with the original points
Or: bc = bezier_(points); % You want the Bezier curve (with 100 points), but no graph nor interpolated curve
Or: [bc, intcyy] = bezier_(points, 500, (1:0.1:20)', 1); % You want all the Bezier curve, the interpolation of part of it and the graph of all.

Citar como

Jesús Lucio (2024). Bezier curve (https://www.mathworks.com/matlabcentral/fileexchange/32817-bezier-curve), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2010a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Smoothing en Help Center y MATLAB Answers.
Etiquetas Añadir etiquetas
Agradecimientos

Inspiración para: Plot Bezier Curve Composite and Offset

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión
1.4.0.0

Corrected bugs in documentation.
Set the limit of 1000 points maximum.

1.3.0.0

Ordered version: now the Bezier curve is the main target, the interpolation curve is an option.
Added legends to distinguish the curves.

1.1.0.0

A few bugs and better documentation.

1.0.0.0