%% syntaxe : t array1 array2 interpolparamfunct --> ( x(t), y(t) )
%% interpole a partir des tableaux array1 (parametre) et array2
%% (les points). dim array2 = 2 * dim array1, et array1 trie par ordre
%% croissant
/interpolparamfunct {
10 dict begin
/table_xy exch def
/table_t exch def
/t exch def
/n table_t length 1 sub def
%% (interpolparamfunct) ==
%% (t) == t ==
%% (t0) == table_t 0 get ==
%% (tn) == table_t n get ==
t table_t 0 get le {
%% t =< t0 ==> on renvoie (x0, y0)
table_xy 0 get
table_xy 1 get
} {
t table_t n get ge {
%% t >= tn ==> on renvoie (xn, yn)
table_xy 2 n mul get
table_xy 2 n mul 1 add get
} {
%% t0 < t < tn
/i 0 def
/ti 0 def
{
/i i 1 add store
/ti table_t i get store
t ti le {
%% ti-1 < t =< ti
/xi table_xy 2 i mul get def
/yi table_xy 2 i mul 1 add get def
/xi-1 table_xy 2 i 1 sub mul get def
/yi-1 table_xy 2 i 1 sub mul 1 add get def
/ti-1 table_t i 1 sub get def
xi xi-1 sub ti ti-1 sub div t ti-1 sub mul xi-1 add
yi yi-1 sub ti ti-1 sub div t ti-1 sub mul yi-1 add
%% (sortie) ==
%% (i) == i ==
%% (xi-1 -> ) == xi-1 ==
%% (xi -> ) == xi ==
%% (x -> ) == 1 index ==
%% (y -> ) == 0 index ==
exit
} if
} loop
} ifelse
} ifelse
end
} def
%% 23-06-06 %% %% syntaxe : t array1 array2 interpolparamfunct --> ( x(t), y(t) )
%% 23-06-06 %% %% interpole a partir des tableaux array1 (parametre) et array2
%% 23-06-06 %% %% (les points). dim array2 = 2 * dim array1, et array1 trie par ordre
%% 23-06-06 %% %% croissant
%% 23-06-06 %% /interpolparamfunct {
%% 23-06-06 %% 10 dict begin
%% 23-06-06 %% /table_xy exch def
%% 23-06-06 %% /table_t exch def
%% 23-06-06 %% /t exch def
%% 23-06-06 %% /n table_t length 1 sub def
%% 23-06-06 %%
%% 23-06-06 %% %% (interpolparamfunct) ==
%% 23-06-06 %% %% (t) == t ==
%% 23-06-06 %% %% (t0) == table_t 0 get ==
%% 23-06-06 %% %% (tn) == table_t n get ==
%% 23-06-06 %%
%% 23-06-06 %% t table_t 0 get le {
%% 23-06-06 %% %% t =< t0 ==> on renvoie (x0, y0)
%% 23-06-06 %% table_xy 0 get
%% 23-06-06 %% table_xy 1 get
%% 23-06-06 %% } {
%% 23-06-06 %% t table_t n get ge {
%% 23-06-06 %% %% t >= tn ==> on renvoie (xn, yn)
%% 23-06-06 %% table_xy 2 n mul get
%% 23-06-06 %% table_xy 2 n mul 1 add get
%% 23-06-06 %% } {
%% 23-06-06 %% %% t0 < t < tn
%% 23-06-06 %% /i 0 def
%% 23-06-06 %% /ti 0 def
%% 23-06-06 %% {
%% 23-06-06 %% /i i 1 add store
%% 23-06-06 %% /ti table_t i get store
%% 23-06-06 %% t ti le {
%% 23-06-06 %% %% ti-1 < t =< ti
%% 23-06-06 %% /xi table_xy 2 i mul get def
%% 23-06-06 %% /yi table_xy 2 i mul 1 add get def
%% 23-06-06 %% /xi-1 table_xy 2 i 1 sub mul get def
%% 23-06-06 %% /yi-1 table_xy 2 i 1 sub mul 1 add get def
%% 23-06-06 %% /ti-1 table_t i 1 sub get def
%% 23-06-06 %% xi xi-1 sub ti ti-1 sub div t ti-1 sub mul xi-1 add
%% 23-06-06 %% yi yi-1 sub ti ti-1 sub div t ti-1 sub mul yi-1 add
%% 23-06-06 %%
%% 23-06-06 %% %% (sortie) ==
%% 23-06-06 %% %% (i) == i ==
%% 23-06-06 %% %% (xi-1 -> ) == xi-1 ==
%% 23-06-06 %% %% (xi -> ) == xi ==
%% 23-06-06 %% %% (x -> ) == 1 index ==
%% 23-06-06 %% %% (y -> ) == 0 index ==
%% 23-06-06 %%
%% 23-06-06 %% exit
%% 23-06-06 %% } if
%% 23-06-06 %% } loop
%% 23-06-06 %% } ifelse
%% 23-06-06 %% } ifelse
%% 23-06-06 %% end
%% 23-06-06 %% } def
|