%% la projection 3D --> 2D
/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 : nx ny (f) src_pt [color] kp x_min x_max y_min y_max surfz
/surfz {
24 dict begin
/y_max exch def
/y_min exch def
/x_max exch def
/x_min exch def
/kp exch def
/la_couleur exch def
/zp exch def
/yp exch def
/xp exch def
/fs exch def
/fx fs cvx def
/ny exch def
/nx exch 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
/fillstyle {
la_couleur
{kp coeff_couleur abs mul mul} apply
setcolor
fill
} def
/dx
x_max x_min sub nx div
def
/dy
y_max y_min sub ny div
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 fx fs facteur def
xt yt 2 copy fx XYZtoXY /A0 defpoint
xt yt+1 2 copy fx XYZtoXY /A1 defpoint
xt+1 yt+1 2 copy fx XYZtoXY /A2 defpoint
xt+1 yt 2 copy fx XYZtoXY /A3 defpoint
gsave
la_couleur
{kp coeff_couleur abs mul mul} apply
setcolor
[A0 A1 A2 A3 A0] polygone*
grestore
/j j 1 add store
} repeat
/i i 1 add store
} repeat
end
} def
|