%!PS-Adobe-2.0

/Times-Bold findfont 16 scalefont setfont
/n 6 def 
/a 360 n div def % a = 60
/b a 2 div def % b = 30
/r 100 def

/tanb b sin b cos div def
/x r 1 tanb sub div def
/y x tanb mul def
/s 2 sqrt y mul def
/t y b sin div def

/pict {
% make square gray
newpath
  r 0 moveto
  x y lineto
  x y add 0 lineto
  x y neg lineto
  closepath
0.9 setgray fill
0 setgray

% axes
0.7 setlinewidth
-20 0 moveto
r 4 mul 30 add 0 lineto stroke
0 r neg moveto
0 r 2 mul lineto stroke

% key stuff
3 setlinewidth
0 0 moveto
x 0 lineto stroke
0 0 moveto
x y lineto stroke
r 0 moveto
x y lineto stroke
x 0 moveto
x y lineto stroke

% rest
0.7 setlinewidth
x y add 0 moveto
x y lineto stroke
0 0 moveto
x y neg lineto stroke
r 0 moveto
x y neg lineto stroke
x 0 moveto
x y neg lineto stroke
x y neg moveto
x y add 0 lineto stroke

% labels
x y add 20 add 10 moveto (x-axis) show
10 y moveto (y-axis) show
x y 10 add moveto ((x, y)) show
r 15 add -15 moveto ((r, 0)) show
x 10 add y 2 div moveto (y) show
x 5 add -15 moveto ((x, 0)) show
x y add 5 add -15 moveto ((x+y, 0)) show
x y 2 div add -15 moveto (y) show
33 5 moveto (b) show
r 20 add 5 moveto (45) show
r 2 div 10 add -15 moveto (r) show
r y 2 div add 13 add y 2 div moveto (s) show
r 13 sub y 2 div moveto (t) show
x y neg 20 sub moveto ((x, -y)) show
r y 2 div add 5 add -15 moveto (y) show

% formulas
20 y neg 20 sub moveto (n = 6) show
20 y neg 40 sub moveto (a = 360/n = 60) show
20 y neg 60 sub moveto (a = 360/n = 60) show
20 y neg 80 sub moveto (b = a/2 = 30) show
320 y neg 20 sub moveto (x = r/(1 - tan(b))) show
320 y neg 40 sub moveto (y = x tan(b)) show
320 y neg 60 sub moveto (x = y + r) show
320 y neg 80 sub moveto (s = y sqrt(2)) show
320 y neg 100 sub moveto (t = y/sin(b)) show

% dots
/dodot { 6 0 360 arc fill} def
1 setgray
x x add x dodot % crazy! first dot leaves stray mark
0 setgray
0 0 dodot
x 0 dodot
r 0 dodot
x y dodot

/Courier-Bold findfont 14 scalefont setfont
20 400 moveto (/n 6 def) show
20 383 moveto (/a 360 n div def % a = 60) show
20 366 moveto (/b a 2 div def % b = 30) show
20 349 moveto (/r 100 def) show

20 315 moveto (/tanb b sin b cos div def) show
20 298 moveto (/x r 1 tanb sub div def) show
20 281 moveto (/y x tanb mul def) show
20 264 moveto (/s 2 sqrt y mul def) show
20 247 moveto (/t y b sin div def) show

/rightmargin 280 def
rightmargin 400 moveto (/square {) show
rightmargin 383 moveto (  newpath) show
rightmargin 366 moveto (  r 0 moveto) show
rightmargin 349 moveto (  x y lineto) show
rightmargin 332 moveto (  x y add 0 lineto) show
rightmargin 315 moveto (  x y neg lineto) show
rightmargin 298 moveto (  closepath) show
rightmargin 281 moveto (} def) show
rightmargin 264 moveto (100 200 translate) show
rightmargin 247 moveto (square) show

/Times-Bold findfont 20 scalefont setfont
150 440 moveto (Square in Postsript) show
} def % pict

100 300 translate
pict

showpage