-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bezier_extract.m
50 lines (44 loc) · 938 Bytes
/
Bezier_extract.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function [C_e,nb]=Bezier_extract(xi)
%%Made by Jason Li
clear C Ce alphas
%xi=[0,0,1/3,2/3,1,1];
m=length(xi);
[x,y]=mode(xi);
p=y-1;
a=p+1;
b=a+1;
nb=1;
C(:,:,1)=eye(a,a);
xi(m+1)=0;
while b<m;
C(:,:,nb+1)=eye(y,y);
i=b;
while and(b<m,xi(b+1)==xi(b));
b=b+1;
end
mult=b-i+1;
if mult<p;
numer=xi(b)-xi(a);
for j=p:-1:mult+1
alphas(j-mult)=numer/(xi(a+j)-xi(a));
end
r=p-mult;
for j=1:r;
save=r-j+1;
s=mult+j;
for k=p+1:-1:s+1;
alph=alphas(k-s);
C(:,k,nb)=alph*C(:,k,nb)+(1.0-alph)*C(:,k-1,nb);
end
if b<m;
C(save:j+save,save,nb+1)=C(p-j+1:p+1,p+1,nb);
end
end
nb=nb+1;
if b<m;
a=b;
b=b+1;
end
end
end
C_e=C(:,:,1:nb);