% name of textfile: Pxx Circle through three points (DL/Synergetics Feb 02 v1.0) % .... % ========= % This file requires the previous download of gonzo.psl % available from https://www.tinaja.com/pssamp1.shtml % Make sure the following line agrees with your own gonzo.psl location (C:/Users/don/Desktop/gonzo/gonzo.psl) run % use internal gonzo % ========== gonzo begin gutility begin printerror nuisance begin % Draws a circle through three points and finds the tangent angle of them mid point. % Fundamental trig math, plus potentially useful for curvetracing. 100 100 10 setgrid 20 20 showgrid % given points a, b, and c. Find equation of normal bisector of ab and bc. % solve simultaneously for center. /points [3 7 6 9 12 2] def /grabpoints { points aload pop /y3 exch store /x3 exch store /y2 exch store /x2 exch store /y1 exch store /x1 exch store} def /plotpoints {x1 y1 mt dot x2 y2 mt dot x3 y3 mt dot} def /drawcircle { y2 y1 sub x2 x1 sub atan 90 sub tan /mm exch store x2 x1 sub 2 div x1 add /px1 exch store y2 y1 sub 2 div y1 add /py1 exch store /bb py1 px1 mm mul sub store y3 y2 sub x3 x2 sub atan 90 sub tan /nn exch store x3 x2 sub 2 div x2 add /px2 exch store y3 y2 sub 2 div y2 add /py2 exch store /cc py2 px2 nn mul sub store /xcen cc bb sub mm nn sub dup 0 eq {pop 0.000001} if div store /ycen xcen mm mul bb add store /rad x1 xcen sub dup mul y1 ycen sub dup mul add sqrt store 0.75 settint 0.31 setgray px1 py1 mt dot x1 y1 mt x2 y2 lineto line1 stroke x2 y2 mt x3 y3 lineto line1 stroke xcen ycen mt dot beige 0.4 setgray px2 py2 mt dot 0 settint 0.3 setgray line1 xcen ycen rad 0 360 arc stroke 0.67 settint 0.31 setgray xcen ycen mt px1 py1 lineto stroke xcen ycen mt px2 py2 lineto stroke y2 ycen sub x2 xcen sub atan 90 sub /ttang exch store (tangent at second point is ) ttang 10 string cvs mergestr ( degrees.) mergestr print } def /points [7 11 10 13 16 6] def grabpoints plotpoints drawcircle showpage % eof