clc;clear;close
m=3;
P=[0 0 1 2;0 1 2.5 3;1 0 2 5];
jj=1;
for u=0:0.01:1
b=BezierP(P,m,u);
bx(jj)=b(1,1);
by(jj)=b(2,1);
bz(jj)=b(3,1);
jj=jj+1;
end
plot3(bx,by,bz,'r');
hold on;
plot3(P(1,:),P(2,:),P(3,:));
xlabel('X轴');
ylabel('Y轴');
zlabel('Z轴');
function [ B ] = BezierP( P,m,u )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
B=P;
if m==0
B=P;
else
for k=1:m
for j=1:m-k+1
B(:,j)=(1-u)*B(:,j)+u*B(:,j+1);
end
end
end
end