royle0913 发表于 2006-5-11 18:28

MATLAB怎么画Bezier曲线曲面

请教高手,怎么样用MATLAB画Bezier曲线曲面和B样条曲线曲面,急啊

suffer 发表于 2006-5-12 08:41

回复:(royle0913)MATLAB怎么画Bezier曲线曲面

Bezier曲线【zz】

% Faculty of Engineering, University of Fukui. 2004/07/07
% coded by Sokthai Chan (sokthai@wireless.fuis.fukui-u.ac.jp)
% Bezier Curve乮Infinite Sign乯

% clear all the variable from memory
clear all;

% Data Setting
t=[-0.8 -0.6 -1/4 1/2 1 3/2 1 1/2 -1/4 -0.6 -0.8];
p=;

n=11;
a=-1;
b=1;
x=-1:0.01:1;
m=length(x);

% Matrix Setting
Pn=zeros(1,m);
Pv=zeros(1,m);
Tv=zeros(1,m);

Ts=((1:n)-1)*(b-a)/(n-1)+a; % Equally Divided Point

% Calculation Bezier Curve
for j=1:m
for i=1:n
B(i)=(nchoosek(n-1,i-1)*realpow(b-x(j),n-i)*realpow(x(j)-a,i-1))/realpow(b-a,n-1); % Base Function of Bernstein
Pn(j)=Pn(j)+p(i)*B(i); % Scalar Bezier Curve
Tv(j)=Tv(j)+t(i)*B(i); % Equally Divided Point
Pv(j)=Pv(j)+p(i)*B(i); % Vector Bezier Curve
end
end

% Plot Graphic
figure(1)
plot(x,Pn,'*',Ts,p,'-');
legend('Scalar Bezier Curve','Bezier Control Polygon');
xlabel('x'); ylabel('Pn(x)');
title(['Bezier Curve']);

figure(2)
plot(Tv,Pv,'*',t,p,'-');
legend('Vector Bezier Curve','Bezier Control Polygon');
xlabel('x'); ylabel('Pn(x)');
title(['Bezier Curve']);

[ 本帖最后由 suffer 于 2007-6-3 12:06 编辑 ]

raby_yu 发表于 2006-5-12 15:08

suffer老兄,可以指点一下t和p的设置依据吗?再次,查看手头上的文献,好像Berstein基函数并不时程序中那样,且其中的变量x(j)的取值范围也是0~1。
页: [1]
查看完整版本: MATLAB怎么画Bezier曲线曲面