%% auteur :
600 setwidth
400 setheight
-7 8 setxrange
-5 5 setyrange
/x_min -7 def
/x_max 7 def
/y_min -7 def
/y_max 7 def
/curvelinewidth 0 def
%% la source d'eclairage
/xp 3 def
/yp 3 def
/zp 7 def
/kp 8 def
/nx 150 def
/ny 150 def
%% f (x, y) = sin (x^2 + y^2)
/f {
%% 2 copy
%% 0 eq
%% {
%% 0 eq
%% {1}
%% {dup mul exch dup mul add dup Sin exch div}
%% ifelse
%% }
%% {
%% pop
%% dup mul exch dup mul add dup Sin exch div
%% }
%% ifelse
dup mul exch dup mul add dup Sin exch .001 max div
} def
/f {
0 0 distance sqrt
} def
/f {Sin exch Sin add} def
/vect_I {-.7 -.5} def
/vect_J {1 0} def
/vect_K {0 1} def
%% syntaxe : x y z XYZtoXY --> X Y
/XYZtoXY {
3 dict begin
/z exch def
/y exch def
/x exch def
vect_I x mulv
vect_J y mulv addv
vect_K z mulv addv
end
} def
%% syntaxe : x y (f) diffx
/diffx {
3 dict begin
/la_fonction exch cvx def
/y exch def
/x exch def
x .01 add y la_fonction
x .01 sub y la_fonction sub
.02 div
end
} def
%% syntaxe : x y (f) diffy
/diffy {
3 dict begin
/la_fonction exch cvx def
/y exch def
/x exch def
x y .01 add la_fonction
x y .01 sub la_fonction sub
.02 div
end
} def
%% syntaxe : x y z (f) facteur
/facteur {
4 dict begin
/fonction exch cvx def
/z exch def
/y exch def
/x exch def
/dfx x y (fonction) diffx def
/dfy x y (fonction) diffy def
/ca
zp z sub
yp y sub dfy mul sub
xp x sub dfx mul sub
def
/cb
dfx dup mul
dfy dup mul add
1 add
sqrt
def
/cc
z zp sub dup mul
y yp sub dup mul add
x xp sub dup mul add
sqrt
def
kp ca mul
cc dup dup mul mul cb mul div
end
} def
/dx
x_max x_min sub nx div
def
/dy
y_max y_min sub ny div
def
/fillstyle {
%% [ 1 .65 0 ] %% orange
%% % [ 1 0 0 0 ] %% cyan
%% {kp coeff_couleur abs mul mul} apply
%% aload pop
%% % setcmykcolor
%% setrgbcolor
%% % setgray
fill
} def
/i 0 def
nx 1 sub {
/xt x_min i dx mul add def
/xt+1 xt dx add def
/j 0 def
ny 1 sub {
/yt y_min j dy mul add def
/yt+1 yt dy add def
/coeff_couleur xt yt 2 copy f (f) facteur def
xt yt 2 copy f XYZtoXY /A0 defpoint
xt yt+1 2 copy f XYZtoXY /A1 defpoint
xt+1 yt+1 2 copy f XYZtoXY /A2 defpoint
xt+1 yt 2 copy f XYZtoXY /A3 defpoint
gsave
% [ 1 .65 0 ] %% orange
[ 1 0 1 1 ] %% cyan
{kp coeff_couleur abs mul mul} apply
aload pop
setcmykcolor
% setrgbcolor
[A0 A1 A2 A3] polygone*
grestore
/j j 1 add store
} repeat
/i i 1 add store
} repeat
|