如何用matlab绘制贝塞尔曲线10阶贝塞尔曲线(平面曲线),控制点分别为(0,1.2),(0.04,0.6),(0.15,0.51),(0.32,0.88),(0.31,0.09),(0.52,0),(0.62,0.8),(0.89,0.87),(0.92,0.6),(0.92,0.3),(0.75,0).
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 12:34:03
如何用matlab绘制贝塞尔曲线10阶贝塞尔曲线(平面曲线),控制点分别为(0,1.2),(0.04,0.6),(0.15,0.51),(0.32,0.88),(0.31,0.09),(0.52,0),(0.62,0.8),(0.89,0.87),(0.92,0.6),(0.92,0.3),(0.75,0).
如何用matlab绘制贝塞尔曲线
10阶贝塞尔曲线(平面曲线)
,控制点分别为
(0,1.2),(0.04,0.6),(0.15,0.51),(0.32,0.88),
(0.31,0.09),(0.52,0),(0.62,0.8),(0.89,0.87),(0.92,0.6),(0.92,0.3),
(0.75,0).
如何用matlab绘制贝塞尔曲线10阶贝塞尔曲线(平面曲线),控制点分别为(0,1.2),(0.04,0.6),(0.15,0.51),(0.32,0.88),(0.31,0.09),(0.52,0),(0.62,0.8),(0.89,0.87),(0.92,0.6),(0.92,0.3),(0.75,0).
以下是运行结果:
程序代码:
function bezier(x,y)
x=[0,0.04,0.15,0.32,0.31,0.52,0.62,0.89,0.92,0.75];
y=[1.2,0.6,0.51,0.88,0.09,0,0.8,0.87,0.6,0.3,0];
n=length(x);
t=linspace(0,1);
xx=0;yy=0;
for k=0:n-1
tmp=nchoosek(n-1,k)*t.^k.*(1-t).^(n-1-k);
xx=xx+tmp*x(k+1);
yy=yy+tmp*y(k+1);
end
if nargout==2
X=xx;Y=yy;
end
h=plot(xx,yy);
if nargout==1
X=h;