资源描述:
《b样条和贝塞尔曲线曲面的拼接》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验二曲线曲面的拼接贝塞尔曲线的拼接P=[-123.544.567;7566.5739;2644.55119];plot3(P(1,1:4),P(2,1:4),P(3,1:4),'o')holdonplot3(P(1,4:7),P(2,4:7),P(3,4:7),'+');holdonB=[-13-31;3-630;-3300;1000];fort=0:0.05:1T=[t^3t^2t1];P1=T*B*P(1,1:4)';P2=T*B*P(2,1:4)';P3=T*B*P(3,1:4)';plot3(P1,P2,P3,'r.')holdonQ1=T*B*P(1,4:7)';Q2=T*B
2、*P(2,4:7)';Q3=T*B*P(3,4:7)';plot3(Q1,Q2,Q3,'b*')endtitle('贝塞尔曲线的拼接');xlabel('x');ylabel('y');zlabel('z');B样条曲线的拼接P=[12345;1.5766.57;31.53.55.54.5];plot3(P(1,1:4),P(2,1:4),P(3,1:4),'o')holdonplot3(P(1,2:5),P(2,2:5),P(3,2:5),'+')holdonB=[-13-31;3-630;-3030;1410];fort=0:0.05:1T=[t^3t^2t1];P1=1/6*T*B
3、*P(1,1:4)';P2=1/6*T*B*P(2,1:4)';P3=1/6*T*B*P(3,1:4)';plot3(P1,P2,P3,'r.')holdonQ1=1/6*T*B*P(1,2:5)';Q2=1/6*T*B*P(2,2:5)';Q3=1/6*T*B*P(3,2:5)';plot3(Q1,Q2,Q3,'b*');endtitle('B样条曲线的拼接');xlabel('x');ylabel('y');zlabel('z');双三次贝塞尔曲面的拼接[X1,Y1]=meshgrid(0:1/3:1,1:1/3:2);[X2,Y2]=meshgrid(1:1/3:2,0:1/3:1
4、);Z1=sin(X1+Y1).^3;B(:,:,1)=X1;B(:,:,2)=Y1;B(:,:,3)=Z1;[X,Y]=meshgrid(0:1/3:1);Z=sin(X+Y).^3;C(:,:,1)=X;C(:,:,2)=Y;C(:,:,3)=Z;M=[-13-31;3-630;-3300;1000];fori=1:3Q(:,:,i)=M*B(:,:,i)*M';P(:,:,i)=M*C(:,:,i)*M';foru=0:1:10forw=0:1:10u3=(u/10)^3;u2=(u/10)^2;u1=(u/10);w3=(w/10)^3;w2=(w/10)^2;w1=(w/10)
5、;S1(u+1,w+1,i)=[u3,u2,u11]*Q(:,:,i)*[w3,w2,w1,1]';S2(u+1,w+1,i)=[u3,u2,u11]*P(:,:,i)*[w3,w2,w1,1]';endendendplot3(B(:,:,1),B(:,:,2),B(:,:,3),'o');holdonplot3(C(:,:,1),C(:,:,2),C(:,:,3),'.');holdonplot3(X1,Y1,Z1)holdonplot3(Y2,X2,Z1)holdonplot3(X,Y,Z)holdonplot3(Y,X,Z)surf(S1(:,:,1),S1(:,:,2),S1(:
6、,:,3))surf(S2(:,:,1),S2(:,:,2),S2(:,:,3))title('双三次贝塞尔曲面的拼接');xlabel('x');ylabel('y');zlabel('z');双三次B样条曲面的拼接[X1,Y1]=meshgrid(0:1/3:1,1/3:1/3:4/3);[X2,Y2]=meshgrid(1/3:1/3:4/3,0:1/3:1);Z1=sin(X1+Y1);B(:,:,1)=X1;B(:,:,2)=Y1;B(:,:,3)=Z1;[X,Y]=meshgrid(0:1/3:1);Z=sin(X+Y);C(:,:,1)=X;C(:,:,2)=Y;C(:,:
7、,3)=Z;M=[-13-31;3-630;-3030;1410]/6;fori=1:3Q(:,:,i)=M*B(:,:,i)*M';P(:,:,i)=M*C(:,:,i)*M';foru=0:1:10forw=0:1:10u3=(u/10)^3;u2=(u/10)^2;u1=(u/10);w3=(w/10)^3;w2=(w/10)^2;w1=(w/10);S1(u+1,w+1,i)=[u3,u2,u11]*Q(:,:,i)*[w3