> bern:=proc(j,n,t)
binomial(n,j)*t^j*(1-t)^(n-j);
end:
 

>
 

> bezier1:=proc(p1,p2,p3)
local m1,m,m2,P,S,B,k,t;
P:=plot([p1,p2,p3],color=green);
B:=NULL;
for k from 0 to 1 by 0.01 do
  m1:=(1-k)*p1+k*p2;
  m2:=(1-k)*p2+k*p3;
  m:=(1-k)*m1+k*m2;
  B:=B,m;
od;
B:=plot([B],color=blue);
S:=seq(plots[display](B,P,plot([(1-t*0.01)*p1+t*0.01*p2,(1-t*0.01)*p2+t*0.01*p3],color=red)),t=0..100);
plots[display](S,insequence=true,axes=none,scaling=constrained);
end:
 

> bezier1([0,0],[3,2],[5,-2]);
 

Plot_2d
 

> bezier3:=proc(p)
local Vi,Vf,B,k,j,M;
Vi:=plot([p[1],p[2]],color=green);
Vf:=plot([p[3],p[4]],color=green);
B:=p[1];
for k from 0.01 to 0.99 by 0.01 do
 M:=sum(bern(j,3,k)*p[j+1],j=0..3);
 B:=B,M;
od;
B:=plot([B,p[4]],color=blue);
plots[display](B,Vi,Vf,axes=none);
end:
 

> bezier3([[0,0],[-1,1],[-1,0],[0,-3]]);
 

Plot_2d
 

> Bezier:=proc(P)
local n,L,k,N,B;
n:=nops(P);
L:=NULL;
for k from 1 to n do
 if irem(k,2)=0 and k>=4 and k<n then
      L:=L,(P[k],P[k],2*P[k]-P[k-1]);
    else L:=L,P[k];
 fi;
od;
L:=[L];
N:=nops(L);
B:=NULL;
for k from 1 to N-3 by 4 do
 B:=B,bezier3([L[k],L[k+1],L[k+2],L[k+3]]);
od;
plots[display]([B]);
end:
 

> Bezier([[0,2],[0,3],[0,6],[-2,6],[-4,2],[-4,0],[0,-8],[0,-8],[4,0],[4,2],[2,6],[0,6],[0,3],[0,2]]);
 

Plot_2d
 

> bspline:=proc(p)
local Vi,Vf,B,t,j,M;
Vi:=plot([p[1],p[2]],color=green);
Vf:=plot([p[3],p[4]],color=green);
B:=NULL;
for t from 0 to 1 by 0.01 do
 M:=((1-t)^3*p[1]+(3*t^3-6*t^2+4)*p[2]+(-3*t^3+3*t^2+3*t+1)*p[3]+t^3*p[4])/6;
 B:=B,M;
od;
B:=plot([B],color=blue);
plots[display](B,Vi,Vf,axes=none);
end:
 

> plots[display](bspline([[0,0],[-1,1],[-1,0],[0,-3]]),bspline([[-1,1],[-1,0],[0,-3],[0,3]]));
 

Plot_2d
 

> bspline([[0,-3],[1,-1],[1,0],[0,3]]);
 

Plot_2d
 

> Bspline:=proc(P)
local n,L,k,N,B;
n:=nops(P);
L:=NULL;
for k from 1 to n-3 do
   L:=L,(P[k],P[k+1],P[k+2],P[k+3]);
od;
L:=[L];
N:=nops(L);
B:=NULL;
for k from 1 to N-3 by 4 do
 B:=B,bspline([L[k],L[k+1],L[k+2],L[k+3]]);
od;
plots[display]([B]);
end:
 

> Bspline([[0,2],[0,3],[0,6],[-2,6],[-4,2],[-4,0],[0,-8],[0,-8],[4,0],[4,2],[2,6],[0,6],[0,3],[0,2]]);
 

Plot_2d
 

>
 

>