Source PostScript (interdroitecercle.pps)

Retour Texte non formaté
%% intersection de la droite y = ax+b avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 %% { -- b - y 2 2 3 %% { | x = - -----, y = (b + a x0 + a y0 + (2 a b y0 - 2 a b x0 + %% { -- a %% %% 3 2 2 2 2 4 2 2 2 4 2 2 %% 2 a x0 y0 - a b + a r + a r - a y0 - a x0 )^(1/2)) / (a + 1) %% %% %% -- %% |, %% -- %% -- b - y 2 2 3 %% | x = - -----, y = (b + a x0 + a y0 - (2 a b y0 - 2 a b x0 + %% -- a %% %% 3 2 2 2 2 4 2 2 2 4 2 2 %% 2 a x0 y0 - a b + a r + a r - a y0 - a x0 )^(1/2)) / (a + 1) %% %% -- } %% | } %% -- } %% intersection de la droite x = a avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 %% 2 2 2 1/2 %% {[x = a, y = y0 + (2 a x0 - a + r - x0 ) ], %% %% 2 2 2 1/2 %% [x = a, y = y0 - (2 a x0 - a + r - x0 ) ]} %% intersection de la droite y = b avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 %% 2 2 2 1/2 %% {[y = b, x = x0 + (2 b y0 - b + r - y0 ) ], %% %% 2 2 2 1/2 %% [y = b, x = x0 - (2 b y0 - b + r - y0 ) ]} %% syntaxe : D I r interdroitecercle /interdroitecercle { 16 dict begin /r exch def /y0 exch def /x0 exch def /yB exch def /xB exch def /yA exch def /xA exch def xA yA xB yB verticale? %% la droite est verticale { /xpt1 xA def /xpt2 xA def /quantite 2 xA mul x0 mul xA dup mul sub r dup mul add x0 dup mul sub sqrt def /ypt1 y0 quantite add def /ypt2 y0 quantite sub def } %% la droite n'est pas verticale { /a xA yA xB yB coeffdir def /b xA yA xB yB ordorig def 0 a eq %% la droite est horizontale { /quantite 2 b mul y0 mul b dup mul sub r dup mul add y0 dup mul sub sqrt def /xpt1 x0 quantite add def /xpt2 x0 quantite sub def /ypt1 b def /ypt2 b def } %% la droite n'est pas horizontale { /quantite1 b a x0 mul add a dup mul y0 mul add def /quantite2 2 a dup mul mul b mul y0 mul 2 a 3 exp mul b mul x0 mul sub 2 a 3 exp mul x0 mul y0 mul add a dup mul b dup mul mul sub a dup mul r dup mul mul add a 4 exp r dup mul mul add a dup mul y0 dup mul mul sub a 4 exp x0 dup mul mul sub sqrt def /quantite3 a dup mul 1 add def /ypt1 quantite1 quantite2 add quantite3 div def /xpt1 ypt1 b sub a div def /ypt2 quantite1 quantite2 sub quantite3 div def /xpt2 ypt2 b sub a div def } ifelse } ifelse xpt1 ypt1 xpt2 ypt2 ordonnepoints end } def