问题
What's the Matlab way to draw a Bezier curve ? Do you have to prgoram it yourself ?
I am not looking for a user made routine, but am asking if Matlab offers a standard way to draw them.
回答1:
After looking and searching through the documentation, my answer is No: you'd have to go with one of the 3rd party implementations.
Likeliest candidate would be the interp
family functions, and they implement no Bezier interpolation.
回答2:
With the Curve Fitting Toolbox, Matlab supports B-splines, which are a generalization of Bézier curves. A rational B-spline with no internal knots is a Bézier spline.
For example
p = spmak([0 0 0 1 1 1],[1 0;0 1]);
fnplt(p)
would plot a Bézier curve with control points at (0,0),(1,0),(1,1),(0,1).
回答3:
You can try this, http://www.cnblogs.com/begtostudy/articles/1787709.html
回答4:
The following code based on this link.
function B = bazier( t, P )
%Bazier curve
% Parameters
% ----------
% - t: double
% Time between 0 and 1
% - C: 2-by-n double matrix
% Control points
%
% Returns
% -------
% - B: 2-by-1 vector
% Output point
B = [0, 0]';
n = size(P, 2);
for i = 1:n
B = B + b(t, i - 1, n - 1) * P(:, i);
end
end
function value = b(t, i, n)
value = nchoosek(n, i) * t^i * (1 - t)^(n - i);
end
来源:https://stackoverflow.com/questions/2301743/how-can-you-draw-a-bezier-curve-in-matlab