Changeset 77

Show
Ignore:
Timestamp:
06/29/08 18:35:27 (6 months ago)
Author:
jpv
Message:

Ajout cercles+droites dans psProjection.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pst-solides3d.tex

    r75 r77  
    293293surface,calottespherecreuse,polygoneregulier,fusion,new,chemin,courbeR2,courbe,% 
    294294surfaceparametree,texte,trigospherique,vecteur,line,objfile,datfile,surface*,% 
    295 plan,offfile,geode,load,plantype,point,pie,droite,polygone
     295plan,offfile,geode,load,plantype,point,pie,droite,polygone,cercle,angledroit
    296296%% Reservation de macros correspondants aux objects 
    297297\pst@solides@reservednames{object} 
     
    10251025    end 
    10261026  }%<- fin du code ps 
    1027   \psk@fillstyle 
     1027%  \psk@fillstyle 
    10281028  \pst@stroke 
    10291029  \ifPst@solidmemory\else\end@ClosedObj\fi 
  • trunk/solides.pro

    r76 r77  
    11%! 
    22% PostScript prologue for pst-solides3d.tex. 
    3 % Version 3.43, 2008/06/28 
     3% Version 3.45, 2008/06/29 
    44% 
    55%% COPYRIGHT 2008 by Jean-Paul Vignault 
     
    407407 
    408408%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     409%%%%            methodes numeriques                     %%%% 
     410%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     411 
     412%%%%% ### solve2nddegre ### 
     413%% syntaxe : a b c solve2nddegre --> x1 x2 
     414/solve2nddegre { 
     4155 dict begin 
     416   /@c exch def 
     417   /@b exch def 
     418   /@a exch def 
     419   /delt@ @b dup mul 4 @a mul @c mul sub def 
     420   @b neg delt@ sqrt sub 2 @a mul div 
     421   @b neg delt@ sqrt add 2 @a mul div 
     422end 
     423} def 
     424 
     425%%%%% ### fin insertion ### 
     426 
     427%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    409428%%%%                  la 2D                             %%%% 
    410429%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     
    652671} def 
    653672 
     673%%%%% ### ordonnepoints ### 
     674%% syntaxe : xA yA xB yB ordonnepoints --> idem si yB>yA ou si yB=yA 
     675%% avec xB>xA, sinon xB yB xA yA 
     676/ordonnepoints { 
     677   4 copy 
     678   exch pop             %% ... xA, yA, yB 
     679   lt                   %% yA < yB ? 
     680      {pop}                     %% oui, c'est fini 
     681      {                         %% non : yA >= yB 
     682         pop 4 copy   
     683         exch pop               %% ... xA, yA, yB 
     684         eq                     %% yA = yB ? 
     685            { 
     686               3 copy                   %% oui, yA = yB 
     687               pop pop                  %% ... xA, xB 
     688               le                       %% xA =< xB ? 
     689                  {}                          %% oui, c'est fini 
     690                  {                           %% non, on echange A et B 
     691                     4 -1 roll 
     692                     4 -1 roll 
     693                  } 
     694               ifelse 
     695            } 
     696            {                           %% non : yA < yB => on echange A et B 
     697               pop 
     698               4 -1 roll 
     699               4 -1 roll 
     700            } 
     701         ifelse 
     702      }  
     703   ifelse 
     704} def 
     705 
     706%%%%% ### distance ### 
     707%% syntaxe~: A B distance 
     708/distance {      %% xA yA xB yB 
     709   vecteur       %% x y 
     710   dup mul exch  %% y^2 x 
     711   dup mul       %% y^2 x^2 
     712   add 
     713   sqrt 
     714} def 
     715 
     716%%%%% ### dup ### 
     717/dupp {2 copy} def 
     718/dupc {3 copy} def 
     719/dupd {4 copy} def 
     720 
    654721%%%%% ### fin insertion ### 
    655722/interdroites {interdroite} def 
     
    762829/oldarrowpointe {xunit 5 div} def 
    763830/oldarrowplume {xunit 10 div} def  
    764 /oldarrow@ngle 60 def         
     831/oldarrow@ngle 45 def         
    765832/oldarrowscale {1 1} def 
    766833/oldarrowangle 0 def     %% pour l'utilisateur 
     
    781848/orthovecteur { 
    782849   neg exch 
     850} def 
     851 
     852%%%%% ### fin insertion ### 
     853 
     854%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     855%%%%                  cercles                           %%%% 
     856%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     857 
     858%%%%% ### defcercle ### 
     859%% syntaxe : A r /d defcercle 
     860/defcercle { 
     8611 dict begin 
     862   /t@mp@r@ire exch def 
     863   [ 4 1 roll ] cvx t@mp@r@ire exch  
     864end def 
     865} def 
     866 
     867%%%%% ### interdroitecercle ### 
     868%% intersection de la droite y = ax+b avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 
     869%% { --       b - y                   2          2           3 
     870%% { |  x = - -----, y = (b + a x0 + a  y0 + (2 a  b y0 - 2 a  b x0 + 
     871%% { --         a 
     872%%  
     873%%       3          2  2    2  2    4  2    2   2    4   2             2 
     874%%    2 a  x0 y0 - a  b  + a  r  + a  r  - a  y0  - a  x0 )^(1/2)) / (a  + 1) 
     875%%  
     876%%  
     877%%    --  
     878%%     |, 
     879%%    --  
     880%%     --       b - y                   2          2           3 
     881%%     |  x = - -----, y = (b + a x0 + a  y0 - (2 a  b y0 - 2 a  b x0 + 
     882%%     --         a 
     883%%  
     884%%       3          2  2    2  2    4  2    2   2    4   2             2 
     885%%    2 a  x0 y0 - a  b  + a  r  + a  r  - a  y0  - a  x0 )^(1/2)) / (a  + 1) 
     886%%  
     887%%    -- } 
     888%%     | } 
     889%%    -- } 
     890 
     891%% intersection de la droite x = a avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 
     892%%                              2    2     2 1/2 
     893%% {[x = a, y = y0 + (2 a x0 - a  + r  - x0 )   ], 
     894%%  
     895%%                                2    2     2 1/2 
     896%%    [x = a, y = y0 - (2 a x0 - a  + r  - x0 )   ]} 
     897 
     898%% intersection de la droite y = b avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 
     899%%                              2    2     2 1/2 
     900%% {[y = b, x = x0 + (2 b y0 - b  + r  - y0 )   ], 
     901%%  
     902%%                                2    2     2 1/2 
     903%%    [y = b, x = x0 - (2 b y0 - b  + r  - y0 )   ]} 
     904 
     905%% syntaxe : D I r interdroitecercle 
     906/interdroitecercle { 
     90716 dict begin 
     908   /r exch def 
     909   /y0 exch def 
     910   /x0 exch def 
     911   /yB exch def 
     912   /xB exch def 
     913   /yA exch def 
     914   /xA exch def 
     915 
     916   xA yA xB yB verticale? 
     917 
     918   %% la droite est verticale 
     919   { 
     920      /xpt1 xA def 
     921      /xpt2 xA def 
     922      /quantite  
     923         2 xA mul x0 mul xA dup mul sub r dup mul add x0 dup mul sub sqrt 
     924      def 
     925      /ypt1 
     926         y0 quantite add 
     927      def 
     928      /ypt2 
     929         y0 quantite sub 
     930      def 
     931   } 
     932 
     933   %% la droite n'est pas verticale 
     934   { 
     935      /a xA yA xB yB coeffdir def 
     936      /b xA yA xB yB ordorig def 
     937 
     938      0 a eq  
     939      %% la droite est horizontale 
     940      { 
     941         /quantite 
     942            2 b mul y0 mul  
     943            b dup mul sub 
     944            r dup mul add 
     945            y0 dup mul sub 
     946            sqrt 
     947         def 
     948         /xpt1  
     949            x0 quantite add 
     950         def 
     951         /xpt2  
     952            x0 quantite sub 
     953         def 
     954         /ypt1 b def 
     955         /ypt2 b def 
     956      }  
     957 
     958      %% la droite n'est pas horizontale 
     959      { 
     960         /quantite1  
     961            b  
     962            a x0 mul add 
     963            a dup mul y0 mul add 
     964         def 
     965         /quantite2 
     966            2 a dup mul mul b mul y0 mul  
     967            2 a 3 exp mul b mul x0 mul sub 
     968            2 a 3 exp mul x0 mul y0 mul add 
     969            a dup mul b dup mul mul sub 
     970            a dup mul r dup mul mul add 
     971            a 4 exp r dup mul mul add 
     972            a dup mul y0 dup mul mul sub 
     973            a 4 exp x0 dup mul mul sub  
     974            sqrt  
     975         def 
     976         /quantite3  
     977            a dup mul 1 add  
     978         def 
     979         /ypt1 
     980            quantite1 quantite2 add quantite3 div 
     981         def 
     982         /xpt1  
     983            ypt1 b sub a div  
     984         def 
     985         /ypt2 
     986            quantite1 quantite2 sub quantite3 div 
     987         def 
     988         /xpt2  
     989            ypt2 b sub a div  
     990         def 
     991      }  
     992      ifelse 
     993   } 
     994   ifelse 
     995    
     996   xpt1 ypt1  
     997   xpt2 ypt2  
     998   ordonnepoints 
     999end 
     1000} def 
     1001 
     1002%%%%% ### intercercle ### 
     1003%% syntaxe : cerc1 cerc2 intercercle --> A B les points d'intersection 
     1004%% des 2 cercles, tries par 'ordonnepoints' 
     1005/intercercle { 
     100612 dict begin 
     1007   /r2 exch def 
     1008   /y2 exch def 
     1009   /x2 exch def 
     1010   /r1 exch def 
     1011   /y1 exch def 
     1012   /x1 exch def 
     1013 
     1014   %% on translate pour se ramener a (x1, y1) = (0, 0) 
     1015   x2 y2 x1 y1 subv 
     1016   /y2 exch def 
     1017   /x2 exch def 
     1018 
     1019   %% on prepare l'equation du 2nd degre 
     1020 
     1021%%                    2       2    2 
     1022%%   {y = RootOf((4 x2  + 4 y2 ) _Z 
     1023%%  
     1024%%                  3        2              2       2            4 
     1025%%          + (-4 y2  - 4 r1~  y2 + 4 y2 r2~  - 4 x2  y2) _Z + x2 
     1026%%  
     1027%%               4       2    2       2   2       2    2        2   2 
     1028%%          + r2~  - 2 y2  r2~  + 2 x2  y2  - 2 x2  r2~  - 2 r1~  x2 
     1029%%  
     1030%%               4     4        2   2        2    2 
     1031%%          + r1~  + y2  + 2 r1~  y2  - 2 r1~  r2~ ), x = 1/2 (-2 y2 
     1032%%  
     1033%%                     2       2    2 
     1034%%         RootOf((4 x2  + 4 y2 ) _Z 
     1035%%  
     1036%%                  3        2              2       2            4 
     1037%%          + (-4 y2  - 4 r1~  y2 + 4 y2 r2~  - 4 x2  y2) _Z + x2 
     1038%%  
     1039%%               4       2    2       2   2       2    2        2   2 
     1040%%          + r2~  - 2 y2  r2~  + 2 x2  y2  - 2 x2  r2~  - 2 r1~  x2 
     1041%%  
     1042%%               4     4        2   2        2    2       2     2     2 
     1043%%          + r1~  + y2  + 2 r1~  y2  - 2 r1~  r2~ ) + r1~  + x2  + y2 
     1044%%  
     1045%%               2 
     1046%%          - r2~ )/x2} 
     1047 
     1048   %% coeff pour le degre 2 
     1049   /a  
     1050      %%                    2       2    2 
     1051      %%   {y = RootOf((4 x2  + 4 y2 ) _Z 
     1052      4 x2 dup mul mul 
     1053      4 y2 dup mul mul add 
     1054   def 
     1055 
     1056   %% coeff pour le degre 1 
     1057   %% 
     1058   /b  
     1059      %%                    3        2              2       2         
     1060      %%            + (-4 y2  - 4 r1~  y2 + 4 y2 r2~  - 4 x2  y2) _Z  
     1061      -4 y2 3 exp mul 
     1062      4 r1 dup mul mul y2 mul sub 
     1063      4 r2 dup mul mul y2 mul add 
     1064      4 x2 dup mul mul y2 mul sub 
     1065   def 
     1066 
     1067   %% coeff pour le degre 0 
     1068   %% 
     1069   /c { 
     1070      %%              4 
     1071      %%          + x2 
     1072      x2 4 exp 
     1073      %%  
     1074      %%               4       2    2       2   2       2    2        2   2 
     1075      %%          + r2~  - 2 y2  r2~  + 2 x2  y2  - 2 x2  r2~  - 2 r1~  x2 
     1076      r2 4 exp add 
     1077      2 y2 dup mul mul r2 dup mul mul sub 
     1078      2 x2 dup mul mul y2 dup mul mul add 
     1079      2 x2 dup mul mul r2 dup mul mul sub 
     1080      2 x2 dup mul mul r1 dup mul mul sub 
     1081      %%  
     1082      %%               4     4        2   2        2    2 
     1083      %%          + r1~  + y2  + 2 r1~  y2  - 2 r1~  r2~ ) 
     1084      r1 4 exp add 
     1085      y2 4 exp add 
     1086      2 r1 dup mul mul y2 dup mul mul add 
     1087      2 r1 dup mul mul r2 dup mul mul sub 
     1088   } def 
     1089 
     1090   a b c solve2nddegre 
     1091   /Y1 exch def 
     1092   /Y0 exch def 
     1093    
     1094   /X0 
     1095      %% x = 1/2 (-2 y2  Y 
     1096      -2 y2 mul Y0 mul 
     1097      %%  
     1098      %%        2     2     2 
     1099      %% + r1~  + x2  + y2 
     1100      r1 dup mul add 
     1101      x2 dup mul add 
     1102      y2 dup mul add 
     1103      %%  
     1104      %%                 2 
     1105      %%            - r2~ )/x2} 
     1106      r2 dup mul sub 
     1107    
     1108      2 x2 mul div 
     1109   def 
     1110    
     1111   /X1 
     1112      %% x = 1/2 (-2 y2  Y 
     1113      -2 y2 mul Y1 mul 
     1114      %%  
     1115      %%        2     2     2 
     1116      %% + r1~  + x2  + y2 
     1117      r1 dup mul add 
     1118      x2 dup mul add 
     1119      y2 dup mul add 
     1120      %%  
     1121      %%                 2 
     1122      %%            - r2~ )/x2} 
     1123      r2 dup mul sub 
     1124    
     1125      2 x2 mul div 
     1126   def 
     1127 
     1128   %% on depose le resultat, en n'oubliant pas de retranslater en sens 
     1129   %% inverse 
     1130 
     1131   X0 Y0 x1 y1 addv 
     1132   X1 Y1 x1 y1 addv 
     1133   ordonnepoints 
     1134end 
     1135} def 
     1136 
     1137%%%%% ### ABcercle ### 
     1138%% syntaxe : A B C ABcercle --> le cercle passant par A, B, C 
     1139/ABcercle { 
     11403 dict begin 
     1141   /@3 defpoint 
     1142   /@2 defpoint 
     1143   /@1 defpoint 
     1144   @1 @2 mediatrice 
     1145   @1 @3 mediatrice 
     1146   interdroite 
     1147   dupp 
     1148   @3 distance 
     1149end    
     1150} def 
     1151 
     1152%%%%% ### diamcercle ### 
     1153%% syntaxe : A B diamcercle --> le cercle de diametre [AB] 
     1154/diamcercle { 
     1155   4 copy 
     1156   distance 2 div 
     1157   5 1 roll  
     1158   milieu 
     1159   3 -1 roll  
    7831160} def 
    7841161 
     
    10001377   A B alpha rotatepoint 
    10011378   A milieu 
     1379end 
     1380} def 
     1381 
     1382%%%%% ### angledroit  ### 
     1383 /widthangledroit 5 def 
     1384 
     1385%% syntaxe : A B C angledroit --> dessine un angle droit en B 
     1386/angledroit { 
     138710 dict begin 
     1388   dup xcheck { 
     1389      /widthangledroit exch def 
     1390   } if 
     1391   /C defpoint 
     1392   /B defpoint 
     1393   /A defpoint 
     1394   B C vecteur normalize widthangledroit 20 div mulv /u defpoint 
     1395   B A vecteur normalize widthangledroit 20 div mulv /v defpoint 
     1396   [B u addv dupp v addv B v addv] ligne 
    10021397end 
    10031398} def 
     
    64016796 
    64026797/drawpieset { 
    6403    sortpieset {drawsolid**} apply 
     67981 dict begin 
     6799   /startest true def 
     6800   sortpieset dup {drawsolid**} apply {0 dessinefacevisible} apply 
     6801end 
    64046802} def 
    64056803 
     
    1019210590   /projname where { 
    1019310591      pop 
    10194       proj-args proj-definition cvx exec projname cvlit defpoint 
     10592      [proj-args proj-definition cvx exec] 
     10593      dup 0 getp projname cvlit defpoint 
     10594      dup length 2 gt { 
     10595         1 getp projname (0) append cvlit defpoint 
     10596      } if 
    1019510597      /projname where pop /projname undef 
    1019610598   } if 
     
    1019810600      solidlinewidth setlinewidth 
    1019910601      linecolor 
    10200       proj-args proj-definition cvx exec point_ 
     10602      [proj-args proj-definition cvx exec] 0 getp point_ 
    1020110603      gere_pstricks_proj_opt 
    1020210604      stroke 
    1020310605   } if 
     10606%   1 1 0 0 1 1 Diamond 
    1020410607   texte length 0 gt { 
    1020510608      20 setfontsize 
     
    1020810611      newpath 
    1020910612      linecolor 
    10210       texte proj-args proj-definition cvx exec 
     10613      texte [proj-args proj-definition cvx exec] 0 getp  
    1021110614      pos (text_) append cvx exec 
    1021210615      gere_pstricks_proj_opt 
     
    1026910672      } ifelse 
    1027010673      proj-definition cvx exec projname cvlit exch def 
     10674      /projname where pop /projname undef 
     10675   } if 
     10676} def 
     10677 
     10678/proj-pst-cercle { 
     10679   action (none) eqstring not { 
     10680      planprojpst bprojscene 
     10681      solidlinewidth setlinewidth 
     10682      linestyle 
     10683      linecolor 
     10684      range aload pop proj-args  
     10685      proj-definition cvx exec Cercle 
     10686      eprojscene 
     10687   } if 
     10688   /projname where { 
     10689      pop 
     10690      proj-args proj-definition cvx exec projname cvlit defcercle 
     10691      /projname where pop /projname undef 
     10692   } if 
     10693} def 
     10694 
     10695/proj-pst-line { 
     10696   action (none) eqstring not { 
     10697      planprojpst bprojscene 
     10698      solidlinewidth setlinewidth 
     10699      linestyle 
     10700      linecolor 
     10701      [proj-args proj-definition cvx exec ] ligne 
     10702      eprojscene 
     10703   } if 
     10704   /projname where { 
     10705      pop 
     10706      [proj-args proj-definition cvx exec] projname cvlit exch def 
     10707      /projname where pop /projname undef 
     10708   } if 
     10709} def 
     10710 
     10711/proj-pst-angledroit { 
     10712   action (none) eqstring not { 
     10713      planprojpst bprojscene 
     10714      solidlinewidth setlinewidth 
     10715      linestyle 
     10716      linecolor 
     10717      proj-args proj-definition cvx exec angledroit 
     10718      eprojscene 
    1027110719   } if 
    1027210720} def