reset;

set terminal qt size 600,500

po = -40;
gamma = 1.4;
rssi(dist) = po - 10*gamma*log(dist/1);
getRSSI(x,y) = (dx=x-apx, dy=y-apy, dist=sqrt(dx*dx + dy*dy), rssi(dist));
getRSSI2(x,y) = ( getRSSI(x,y) - ((y>w1)?(6):(0)) );

prob(val, mu, sigma) = ( 1/(sigma*sqrt(2*pi)) * exp( -0.5 * ((val-mu)/sigma)**2 ) );

unset xtics;
unset ytics;

s = 0.5;
apx = 15;
apy = 15;

w1 = 17;
wh = 1.2;

ux = 2;
uy = 5;

#set colorbox user origin screen 0.9,0.5

set origin -0.125,-0.125
set size 1.18, 1.18
#unset colorbox;
unset cbtics;


set xrange[0:30];
set yrange[0:30];
set cbrange[-40:-100];

set isosamples 200;
#set view equal xy

set arrow 1 from apx-s,apy-s to apx+s,apy+s front nohead lw 2
set arrow 2 from apx-s,apy+s to apx+s,apy-s front nohead lw 2
set label 1 "AP" at apx+1,apy-0.5 front font ",20"
#set object 1 circle at graph apx,apy radius graph 2 lc rgb "#000000" lw 1 front

#set arrow 3 from ux-s,uy-s to ux+s,uy+s front nohead lw 2
#set arrow 4 from ux-s,uy+s to ux+s,uy-s front nohead lw 2

#set arrow 5 from apx,apy to ux,uy front nohead lw 1 dashtype 3

set view map;

set terminal pngcairo size 512,512



# plot 1
set label 2 "strong" font ",20" right at screen 0.973, 0.95
set label 3 "weak" font ",20" right at screen 0.973, 0.03
set output "wifi1.png"
splot getRSSI(x,y) with pm3d notitle;

# plot 2
set output "wifi2.png"
#set arrow 81 from 15,w2 to 30,w2 front nohead lw 4
#set arrow 82 from 0,w1 to 30,w1 front nohead lw 10 lc rgb "#ffffff"
set object 82 rectangle center apx,w1 size 30,wh front fillstyle solid fc rgb "#ffffff"
set object 83 rectangle center apx,w1 size 30,wh front fillstyle pattern 4 fc rgb "#000000"

splot getRSSI2(x,y) with pm3d notitle;

unset cbrange;
set palette rgb 33,13,10;
#unset colorbox;

# plot 3
set label 2 "likely" font ",20" right at screen 0.973, 0.95
set label 3 "unlikely" font ",20" right at screen 0.973, 0.03
set output "wifi3.png"
unset arrow 82;
unset arrow 81;
unset object 82;
unset object 83;
splot prob(-70, getRSSI(x,y), 4) with pm3d notitle;

# plot 4
set output "wifi4.png"
#set arrow 81 from 15,w2 to 30,w2 front nohead lw 4
#set arrow 82 from 0,w1 to 30,w1 front nohead lw 4
set object 82 rectangle center apx,w1 size 30,wh front fillstyle solid fc rgb "#ffffff"
set object 83 rectangle center apx,w1 size 30,wh front fillstyle pattern 4 fc rgb "#000000"
splot prob(-70, getRSSI2(x,y), 4) with pm3d notitle;
