您好,欢迎来到纷纭教育。
搜索
您的当前位置:首页matlab实现三次贝塞尔曲线

matlab实现三次贝塞尔曲线

来源:纷纭教育
根据bezier定义

% Bezier Square Curve Ploter

% This file will create a Bezier square curve and dispay the plot.

% The parameter is the Vertex matrix.

function [X] = bezier2(Vertex)

BCon=[1 -2 1;-2 2 0;1 0 0]; % constant Matrix

for i = 1:1:50

par = (i - 1)/49;

XY(i,:) = [par^2 par 1]*BCon*Vertex; % create data

end

% display the vertices and the curve using Matlabs built-in graphic functions

clf % this will clear the figure

plot(Vertex(:,1),Vertex(:,2),'ro',XY(:,1),XY(:,2),'b-')

% create a plot of both the Vertices and curve, the vertices will be red “o”

% while the curve is blue line

line(Vertex(:,1),Vertex(:,2),'color','g') % add the control polygon.

xlabel(' x ')

ylabel ('y ')

title('Square Bezier Curve')

legend('控制顶点','Bezier曲线','控制多边形') % you can move the legend on the plot

然后,在命令行定义Bez2Vertex=[ 0 0 ; 0.3 0.7 ; 1.0 0.2],即定义 , , ,再在命令行输入bezier2(Bez2Vertex)

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- fenyunshixun.cn 版权所有 湘ICP备2023022495号-9

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务