% Sheila Shah % MAKE CONSTRUCTION %! % takes in 2 points in vector form and finds the midpoint /findmidpoint { 10 dict begin /B exch def /A exch def [A 0 get B 0 get add 2 div A 1 get B 1 get add 2 div] end} def %takes in stack of 3 2D vectors, 3 points /mktriangle { 16 dict begin /C exch def /B exch def /A exch def A 0 get A 1 get moveto B 0 get B 1 get lineto C 0 get C 1 get lineto closepath end } def % takes in x, y, and size /mkcircle {16 dict begin /size exch def /y exch def /x exch def /N 64 def /a 0 def a cos size mul x add a sin size mul y add moveto N { /a a 360 N div add def a cos size mul x add a sin size mul y add lineto } repeat end } def %takes in a stack of 3 2D vectors, 3 points % and makes an inscribed circle in the triangle outputs centre[x y] /mkinscribedcircle { 20 dict begin /C exch def /B exch def /A exch def /aa [B 0 get C 0 get sub B 1 get C 1 get sub] def /bb [C 0 get A 0 get sub C 1 get A 1 get sub] def /cc [B 0 get A 0 get sub B 1 get A 1 get sub] def /a aa 0 get 2 exp aa 1 get 2 exp add 0.5 exp def /b bb 0 get 2 exp bb 1 get 2 exp add 0.5 exp def /c cc 0 get 2 exp cc 1 get 2 exp add 0.5 exp def /s a b add c add 2 div def /k s a sub s b sub mul s c sub mul s mul 0.5 exp def /r k s div def %finding the centre of the circle /sinA B 1 get A 1 get sub c div def /angle sinA dup 2 exp 1 sub neg sqrt atan def /d 1 angle 2 div sin angle 2 div cos div div r mul def [A 0 get d add A 1 get r add] end} def % takes in 3 vector, points and outputs a vector [xcentre, ycentre,R radius] /mkcircumcircle { 20 dict begin /C exch def /B exch def /A exch def /aa [B 0 get C 0 get sub B 1 get C 1 get sub] def /bb [C 0 get A 0 get sub C 1 get A 1 get sub] def /cc [B 0 get A 0 get sub B 1 get A 1 get sub] def /a aa 0 get 2 exp aa 1 get 2 exp add 0.5 exp def /b bb 0 get 2 exp bb 1 get 2 exp add 0.5 exp def /c cc 0 get 2 exp cc 1 get 2 exp add 0.5 exp def /k 0.5 b mul B 1 get A 1 get sub mul def /R a b mul c mul 4 k mul div def % coordinates of circumcircle /x A 0 get b 2 div add def /y R 2 exp b 2 div 2 exp sub 0.5 exp A 1 get add def [x y R] end} def /Times-Roman findfont 0.1 scalefont setfont /point 0.03 def %--------------------PAGE 1 gsave 100 dup scale 2 5.5 translate 1 72 div setlinewidth /A [0 0] def /B [0.5 1.375] def /C [1 0] def A B C mktriangle stroke 0 0 1 setrgbcolor A 0 get A 1 get point mkcircle fill B 0 get B 1 get point mkcircle fill C 0 get C 1 get point mkcircle fill -0.33 0 moveto ( A(0,0) ) show 0.3 1.43 moveto ( B(0.5, 1.375) ) show 1.01 0 moveto ( C(1, 0) ) show showpage grestore