永发信息网

哪位高手能帮我画图(计算机辅助几何设计),程序已给出!

答案:2  悬赏:70  手机版
解决时间 2021-04-12 08:02

function bytqx
u=[3 3 3 3 4 5 6 7 8 9 9 9 9];%等距节点
n=100;m=length(u);k=4;%阶数=次数+1
[bx by]=ginput(m-k);
[yT,duanshu]=bsplinej(u,k,n);
D=[bx by]'*yT;
plot(bx,by,'-ob','LineWidth',2);
hold on;
axis equal;
axis tight;
for i=1:duanshu
plot(D(1,1+n*(i-1):n*i),D(2,1+n*(i-1):n*i),'r','LineWidth',2);
end
hold off;
function [y,duanshu]=bsplinej(u,k,n)
%u为节点;k为阶数或次数+1;%n为小段曲线取点数
m=length(u);
N=zeros(k,n*(m-1),m-1);
D=zeros(2,n*(m-1-2*(k-1)));
tu=zeros(1,n*(m-1));
qjied=zeros(1,m-2*k+2);
sjied=zeros(1,m-2*k+2);
for i=k:1:m-k+1
qjied(i-k+1)=max(find(u(k:m-k+1)==u(i)));
end
ci=1;jishuq=1;
while ci<=m-2*k+2 & jishuq<=m-2*k+2
jishuq=max(find(qjied==qjied(jishuq)));
sjied(ci)=qjied(jishuq);
ci=ci+1;jishuq=jishuq+1;
end
duanshu=length(find(sjied~=0))-1;
sjied=k-1+sjied;
for i=1:1:m-1;
tu((i-1)*n+1:i*n)=linspace(u(i),u(i+1),n);
end
for i=1:1:m-1
N(1,(i-1)*n+1:i*n,i)=1;
end
for j=2:1:k
for i=1:1:m-j
t=tu((i-1)*n+1:(i-1+j)*n);
delt1=u(i+j-1)-u(i);
delt2=u(i+j)-u(i+1);
feizi1=(t-u(i)).*N(j-1,(i-1)*n+1:(i-1+j)*n,i);
feizi2=(u(i+j)-t).*N(j-1,(i-1)*n+1:(i-1+j)*n,i+1);
if delt1==0 & delt2==0
N(j,(i-1)*n+1:(i-1+j)*n,i)=0;
end
if delt1==0 & delt2~=0
N(j,(i-1)*n+1:(i-1+j)*n,i)=feizi2/delt2;
end
if delt2==0 & delt1~=0
N(j,(i-1)*n+1:(i-1+j)*n,i)=feizi1/delt1;
end
if delt1~=0 & delt2~=0
N(j,(i-1)*n+1:(i-1+j)*n,i)=feizi1/delt1+feizi2/delt2;
end
end
end
y=zeros(m-k,n*duanshu);
for i=1:1:m-k
for j=1:1:duanshu
y(i,(j-1)*n+1:j*n)=N(k,n*(sjied(j)-1)+1:n*(sjied(j)),i);
end
end

这个程序改一些点(只改点和阶数即可),画出一朵花的图形,把蓝线隐去,只留红线

function bsplinequm33
clear;
v=[0 0 0 0 1 2 2 2 2];
u=[0 0 0 0 1 2 2 2 2];
ku=3;kv=3;
Mu=30;Mv=30;
x=[1 2 3 4 5];y=[3 1 3 5 3];
n=length(x);
m=length(y);
[x y]=meshgrid(x,y);
z=[1 2 3 2 1;
1 2 3 2 1;
2 3 3 3 2;
1 2 3 2 1;
1 2 3 2 1 ];
Tu=bsplinej(u,ku+1,Mu);
Tv=bsplinej(v,kv+1,Mv);
xst=zeros(Mu,Mv);yst=zeros(Mu,Mv);zst=zeros(Mu,Mv);
xst=Tu'*x*Tv;
yst=Tu'*y*Tv;
zst=Tu'*z*Tv;
axis equal;
axis([0 6 0 6 1 3]);
for i=1:m
plot3(x(i,:),y(i,:),z(i,:),'-or','LineWidth',2);
hold on;
end
for i=1:n
plot3(x(:,i),y(:,i),z(:,i),'-ob','LineWidth',2);
end
grid on
mesh(xst,yst,zst);
axis([0 6 0 6 1 4]);
xlabel('X-axis');ylabel('Y-axis');zlabel('Z-axis');
hold off;
view([-30 30]);
function [y,duanshu]=bsplinej(u,k,n)
%u为节点;k为阶数或次数+1;%n为小段曲线取点数
m=length(u);
N=zeros(k,n*(m-1),m-1);
D=zeros(2,n*(m-1-2*(k-1)));
tu=zeros(1,n*(m-1));
qjied=zeros(1,m-2*k+2);
sjied=zeros(1,m-2*k+2);
for i=k:1:m-k+1
qjied(i-k+1)=max(find(u(k:m-k+1)==u(i)));
end
ci=1;jishuq=1;
while ci<=m-2*k+2 & jishuq<=m-2*k+2
jishuq=max(find(qjied==qjied(jishuq)));
sjied(ci)=qjied(jishuq);
ci=ci+1;jishuq=jishuq+1;
end
duanshu=length(find(sjied~=0))-1;
sjied=k-1+sjied;
for i=1:1:m-1;
tu((i-1)*n+1:i*n)=linspace(u(i),u(i+1),n);
end
for i=1:1:m-1
N(1,(i-1)*n+1:i*n,i)=1;
end
for j=2:1:k
for i=1:1:m-j
t=tu((i-1)*n+1:(i-1+j)*n);
delt1=u(i+j-1)-u(i);
delt2=u(i+j)-u(i+1);
feizi1=(t-u(i)).*N(j-1,(i-1)*n+1:(i-1+j)*n,i);
feizi2=(u(i+j)-t).*N(j-1,(i-1)*n+1:(i-1+j)*n,i+1);
if delt1==0 & delt2==0
N(j,(i-1)*n+1:(i-1+j)*n,i)=0;
end
if delt1==0 & delt2~=0
N(j,(i-1)*n+1:(i-1+j)*n,i)=feizi2/delt2;
end
if delt2==0 & delt1~=0
N(j,(i-1)*n+1:(i-1+j)*n,i)=feizi1/delt1;
end
if delt1~=0 & delt2~=0
N(j,(i-1)*n+1:(i-1+j)*n,i)=feizi1/delt1+feizi2/delt2;
end
end
end
y=zeros(m-k,n*duanshu);
for i=1:1:m-k
for j=1:1:duanshu
y(i,(j-1)*n+1:j*n)=N(k,n*(sjied(j)-1)+1:n*(sjied(j)),i);
end
end
这个程序也是只增加修改一些点,画出一个比较复杂且美观的图案

急用,谢谢

最佳答案

每行加一个数字 保持等距 阶数加1

全部回答

你应该在编程区域提问,那里才比较多编程高手

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
篮球裁判员的手势有那些
厕所用英语怎么写,厕所英文怎么讲
非凡之恋在哪里啊,我有事要去这个地方
如何使电脑连接电视有声音
The manager along with his workers day an
Win7 32位操作系统启动慢的原因有哪些
杯子很脏要怎么洗干净啊?
舌头被咬破了
电脑所谓的二进制和C语言是什么关系
为什么49级了没给我觉醒者的骄傲那个称号
求一首歌。一首英文的。一个女的唱的音调很悲
2012考研数学一国家线预测是多少?
智途儿童玩具城地址在哪,我要去那里办事
准确称取6g铝土矿(含Al2O3、Fe2O3、SiO2)样
楚乔传 风云令主和往生营什么关系
推荐资讯
qq抢车位开通时间段
黄石市邮政速递物流分公司西塞山揽投站在哪
倔强的萝卜给我观看地址
Where is New York ? It’s inA. the Un
There is an old tiger in the forest. He do
穿越火线这个周末有什么活动吗?
好衣柜的句子,形容衣柜的句子
3d版铁臂阿童木什么时候能看?
跪求大神来两篇英文小说的读后感!!
2006年安徽省省城合肥阔步前进,实现GDP1073.
东北原味老式烤肉地址在哪,我要去那里办事
女孩子最好几岁学排球
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?