请教在matlab中怎么画双三次均匀B样条啊?
楼主 · 1 楼
我刚学B样条不久,不知道哪位能提示我该怎样去做,函数我找了几个,但具体不知道是怎么实现的,下面是一个完整的代码
a=load('test1.txt');
[m,n]=size(a);
a1=a(:,1);
a2=a(:,2);
a3=a(:,3);
u=augknt(1:24,1);
uu=(1:240)/10;
v=augknt(1:28,1);
vv=(1:280)/10;
X=reshape(a1,20,24);
Y=reshape(a2,20,24);
Z=reshape(a3,20,24);
c1=spmak( {u,v}, X );
c2=spmak( {u,v}, Y );
c3=spmak( {u,v}, Z);
cc1=fnval(c1,{uu,vv});
cc2=fnval(c2,{uu,vv});
cc3=fnval(c3,{uu,vv});
fig = figure;
set(fig, 'Color', 'white',...
'AlphaMap',...
[ zeros(1,40), ...
linspace(0,.5,15), linspace(.5,1,8), ...
ones(1,30)]);
axes('CameraPosition', [-193.4013 -265.1546 220.4819],...
'CameraTarget',[26 26 10], ...
'CameraUpVector',[0 0 1], ...
'CameraViewAngle',9.5, ...
'DataAspectRatio', [1 1 .9],...
'Position',[0 0 1 1], ...
'Visible','off', ...
'XLim',[1 51], ...
'YLim',[1 51], ...
'ZLim',[-13 40]);
surf(cc1,cc2,cc3, ...
'FaceColor','white', ...
'FaceLighting','none', ...
'Clipping','off',...
'EdgeColor',[.8 .8 .8]);
%surfl(cc1,cc2,cc3)
%mesh(cc1,cc2,cc3)
shading flat
colormap(copper)
%colormap hot
%plot3(cc1,cc2,cc3)
grid on
light('position',[100 100 50],'position',[-13,30,11]);
hold on
mesh(X,Y,Z)
%alpha(1)
不过我不知道是怎么来实现的,有谁能帮我解释一下么?不胜感谢!
a=load('test1.txt');
[m,n]=size(a);
a1=a(:,1);
a2=a(:,2);
a3=a(:,3);
u=augknt(1:24,1);
uu=(1:240)/10;
v=augknt(1:28,1);
vv=(1:280)/10;
X=reshape(a1,20,24);
Y=reshape(a2,20,24);
Z=reshape(a3,20,24);
c1=spmak( {u,v}, X );
c2=spmak( {u,v}, Y );
c3=spmak( {u,v}, Z);
cc1=fnval(c1,{uu,vv});
cc2=fnval(c2,{uu,vv});
cc3=fnval(c3,{uu,vv});
fig = figure;
set(fig, 'Color', 'white',...
'AlphaMap',...
[ zeros(1,40), ...
linspace(0,.5,15), linspace(.5,1,8), ...
ones(1,30)]);
axes('CameraPosition', [-193.4013 -265.1546 220.4819],...
'CameraTarget',[26 26 10], ...
'CameraUpVector',[0 0 1], ...
'CameraViewAngle',9.5, ...
'DataAspectRatio', [1 1 .9],...
'Position',[0 0 1 1], ...
'Visible','off', ...
'XLim',[1 51], ...
'YLim',[1 51], ...
'ZLim',[-13 40]);
surf(cc1,cc2,cc3, ...
'FaceColor','white', ...
'FaceLighting','none', ...
'Clipping','off',...
'EdgeColor',[.8 .8 .8]);
%surfl(cc1,cc2,cc3)
%mesh(cc1,cc2,cc3)
shading flat
colormap(copper)
%colormap hot
%plot3(cc1,cc2,cc3)
grid on
light('position',[100 100 50],'position',[-13,30,11]);
hold on
mesh(X,Y,Z)
%alpha(1)
不过我不知道是怎么来实现的,有谁能帮我解释一下么?不胜感谢!