WYKŁAD 14
INTERPOLACJA FUNKCJI DWÓCH ZMIENNYCH
....................................................
N:=50;
h:=2*Pi/N;
for i:=0 to N do begin
x:=-Pi+i*h;
for j:=0 to N do begin
y:=-Pi+j*h;
fun[i,j]:=Sin(x-1.5*y)*Sqrt(Abs(x*y)/3);
end;
end;
N1:=N-1;
{.......................................}
ZX:=GetMaxX div 2; ZY:=GetMaxY;
a:=ZY-50; b:=ZY/2;
xw[1]:=ZX-a/2; xw[2]:=ZX+a/2;
xw[3]:=xw[2]; xw[4]:=xw[1];
yw[1]:=b+a/2; yw[2]:=yw[1];
yw[3]:=b-a/2; yw[4]:=yw[3];
h:=a/N; M:=Round(h);
SetBkColor(White); SetColor(Blue);
min:=fun[0,0]; max:=fun[0,0];
for i:=0 to N do
for j:=0 to N do begin
pp:=fun[i,j];
if pp<min then min:=pp;
if pp>max then max:=pp;
end;
del:=(max-min)/25;
for j:=0 to N1 do begin
yp:=yw[1]-j*h;
for i:=0 to N1 do begin
xp:=xw[1]+i*h;
for jj:=0 to M do begin
s:=jj/h;
s1:=1-s;
for ii:=0 to M do begin
r:=ii/h;
r1:=1-r;
pp:=s1*(r1*fun[i,j]+r*fun[i+1,j])+
s*(r1*fun[i,j+1]+r*fun[i+1,j+1]);
K:=Trunc((pp-min)/del);
if Odd(K) then
PutPixel(Round(xp+ii),Round(ypjj),
LightGray)
else
PutPixel(Round(xp+ii),Round(yp-jj),White);
end;
end;
end;
end;
..................................................................
,
5
.
1
,
5
.
1
5
.
1
,
5
.
1
,
2
)
,
(
)
(
2
2
2
D
y
x
e
y
x
f
,
]
,
[
]
,
[
,
2
sin
)
,
(
2
2
D
y
x
y
x
f
KONIEC