matlab实现三次贝塞尔曲线

更新时间:2023-10-08 11:26:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

根据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)

本文来源:https://www.bwwdw.com/article/unyf.html

Top