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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// 08.05.28
// 08.05.29
// 09.06.13
// 10.04.24
// 10.04.25
// 11.01.07 ( major changed )
function OutL=Splinedata(varargin)
global SplinePt;
Nargs=length(varargin);
Eps=10^(-3);
PL=varargin(1);
if type(PL)==10 // 100425
Fname=PL;
PL=Readtextdata(Fname);
else
if size(PL,1)==1
PL=matrix(PL,2,length(PL)/2);
PL=PL';
end;
end;
if size(PL,2)==3
Flg3=1;
else
Flg3=0;
end;
PLL=Dividegraphics(PL);
N=50;
C=[];
for I=2:Nargs
Tmp=varargin(I);
if type(Tmp)~=10 continue; end
if mtlb_findstr(Tmp,'=')~=[]
execstr(Tmp);
else
Tmp1=Strop(1,Tmp);
if Tmp1=='C' | Tmp1=='c'
C=1:length(PLL);
end;
end;
end;
Cflg=zeros(1,length(PLL));
for J=1:length(C)
K=C(J);
Cflg(K)=1;
end;
if length(N)>1
if type(Nj)==1
Nj=N;
else
Nj=[];
for J=1:length(N)
Nj(J)=N(J);
end;
end;
else
Tmp1=[];
for J=1:length(PLL)
Tmp1(J)=size(PLL(J),1);
end;
MxP=max(Tmp1);
Nj=[];
for J=1:length(PLL)
Tmp=size(PLL(J),1);
Tmp1=round(N/MxP*(Tmp-1));
Nj(J)=Tmp1;
end;
end;
OutL=list();
for J=1:length(PLL) //
PL=PLL(J);
if Cflg(J)==1
if norm(PL(1,:)-PL(size(PL,1),:))>Eps
PL=[PL;PL(1,:)];
Nj(J)=round(N/MxP*size(PL,1));
else
PL(size(PL,1),:)=PL(1,:);
end
end;
SplinePt=PL;
Tn=1:size(PL,1);
Xn=PL(:,1)';
Yn=PL(:,2)';
if Flg3==1 Zn=PL(:,3)';end;
if Cflg(J)==0
Dxn=splin(Tn,Xn);
Dyn=splin(Tn,Yn);
if Flg3==1 Dzn=splin(Tn,Zn); end;
else
Dxn=splin(Tn,Xn,'periodic');
Dyn=splin(Tn,Yn,'periodic');
if Flg3==1 Dzn=splin(Tn,Zn,'periodic'); end;
end
T=linspace(1,size(PL,1),Nj(J));
X=interp(T,Tn,Xn,Dxn);
Y=interp(T,Tn,Yn,Dyn);
if Flg3==1 Z=interp(T,Tn,Zn,Dzn); end;
if Flg3==1
Out=[X',Y',Z'];
else
Out=[X',Y'];
end;
OutL($+1)=Out;
end;
if length(OutL)==1
OutL=OutL(1);
end;
endfunction;
|