| 1 | %! |
|---|
| 2 | % PostScript prologue for pst-solides3d.tex. |
|---|
| 3 | % Version 4.16, 2010/01/07 |
|---|
| 4 | % |
|---|
| 5 | %% COPYRIGHT 2009 by Jean-Paul Vignault |
|---|
| 6 | %% |
|---|
| 7 | %% This program can be redistributed and/or modified under the terms |
|---|
| 8 | %% of the LaTeX Project Public License Distributed from CTAN |
|---|
| 9 | %% archives in directory macros/latex/base/lppl.txt. |
|---|
| 10 | % |
|---|
| 11 | /SolidesDict 100 dict def |
|---|
| 12 | /SolidesbisDict 100 dict def |
|---|
| 13 | SolidesDict begin |
|---|
| 14 | |
|---|
| 15 | %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 16 | %% %% les variables globales gerees par PSTricks %% |
|---|
| 17 | %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 18 | %% %% les lignes dessous sont a decommenter si l on veut utiliser le |
|---|
| 19 | %% %% fichier solides.pro independamment du package PSTricks |
|---|
| 20 | %% /Dobs 20 def |
|---|
| 21 | %% /THETA 20 def |
|---|
| 22 | %% /PHI 50 def |
|---|
| 23 | %% /Decran 30 def |
|---|
| 24 | %% /XpointVue {Dobs Cos1Cos2 mul} def |
|---|
| 25 | %% /YpointVue {Dobs Sin1Cos2 mul} def |
|---|
| 26 | %% /ZpointVue {Dobs Sin2 mul} def |
|---|
| 27 | %% /xunit 28.14 def |
|---|
| 28 | %% /solidhollow false def |
|---|
| 29 | %% /solidbiface false def |
|---|
| 30 | %% /xunit 28.45 def |
|---|
| 31 | %% /tracelignedeniveau? true def |
|---|
| 32 | %% /hauteurlignedeniveau 1 def |
|---|
| 33 | %% /couleurlignedeniveau {rouge} def |
|---|
| 34 | %% /linewidthlignedeniveau 4 def |
|---|
| 35 | %% /solidgrid true def |
|---|
| 36 | /aretescachees true def |
|---|
| 37 | /defaultsolidmode 2 def |
|---|
| 38 | % |
|---|
| 39 | /Stroke { strokeopacity .setopacityalpha stroke } def |
|---|
| 40 | /Fill { fillopacity .setopacityalpha fill } def |
|---|
| 41 | % |
|---|
| 42 | %% variables globales specifiques a PSTricks |
|---|
| 43 | %% /activationgestioncouleurs true def |
|---|
| 44 | /xmin -10 def |
|---|
| 45 | /xmax 10 def |
|---|
| 46 | /ymin -10 def |
|---|
| 47 | /ymax 10 def |
|---|
| 48 | |
|---|
| 49 | /fillstyle {} def |
|---|
| 50 | /startest false def |
|---|
| 51 | /cm {} def |
|---|
| 52 | /cm_1 {} def |
|---|
| 53 | /yunit {xunit} def |
|---|
| 54 | /angle_repere 90 def |
|---|
| 55 | |
|---|
| 56 | /hadjust 2.5 def |
|---|
| 57 | /vadjust 2.5 def |
|---|
| 58 | /pl@n-en-cours false def |
|---|
| 59 | |
|---|
| 60 | /pointilles { [6.25 3.75] 1.25 setdash } def |
|---|
| 61 | /stockcurrentcpath {} def |
|---|
| 62 | /newarrowpath {} def |
|---|
| 63 | /chaine 15 string def |
|---|
| 64 | |
|---|
| 65 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 66 | %% choix d une fonte accentuee pour le .ps %% |
|---|
| 67 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 68 | /ReEncode { exch findfont |
|---|
| 69 | dup length dict begin { 1 index /FID eq {pop pop} {def} ifelse |
|---|
| 70 | }forall /Encoding ISOLatin1Encoding def currentdict end definefont |
|---|
| 71 | pop }bind def |
|---|
| 72 | /Font /Times-Roman /ISOfont ReEncode /ISOfont def |
|---|
| 73 | %Font findfont 10 scalefont setfont |
|---|
| 74 | |
|---|
| 75 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 76 | %% extrait de color.pro pour pouvoir recuperer ses couleurs %% |
|---|
| 77 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 78 | /GreenYellow{0.15 0 0.69 0 setcmykcolor}def |
|---|
| 79 | /Yellow{0 0 1 0 setcmykcolor}def |
|---|
| 80 | /Goldenrod{0 0.10 0.84 0 setcmykcolor}def |
|---|
| 81 | /Dandelion{0 0.29 0.84 0 setcmykcolor}def |
|---|
| 82 | /Apricotq{0 0.32 0.52 0 setcmykcolor}def |
|---|
| 83 | /Peach{0 0.50 0.70 0 setcmykcolor}def |
|---|
| 84 | /Melon{0 0.46 0.50 0 setcmykcolor}def |
|---|
| 85 | /YellowOrange{0 0.42 1 0 setcmykcolor}def |
|---|
| 86 | /Orange{0 0.61 0.87 0 setcmykcolor}def |
|---|
| 87 | /BurntOrange{0 0.51 1 0 setcmykcolor}def |
|---|
| 88 | /Bittersweet{0 0.75 1 0.24 setcmykcolor}def |
|---|
| 89 | /RedOrange{0 0.77 0.87 0 setcmykcolor}def |
|---|
| 90 | /Mahogany{0 0.85 0.87 0.35 setcmykcolor}def |
|---|
| 91 | /Maroon{0 0.87 0.68 0.32 setcmykcolor}def |
|---|
| 92 | /BrickRed{0 0.89 0.94 0.28 setcmykcolor}def |
|---|
| 93 | /Red{0 1 1 0 setcmykcolor}def |
|---|
| 94 | /OrangeRed{0 1 0.50 0 setcmykcolor}def |
|---|
| 95 | /RubineRed{0 1 0.13 0 setcmykcolor}def |
|---|
| 96 | /WildStrawberry{0 0.96 0.39 0 setcmykcolor}def |
|---|
| 97 | /Salmon{0 0.53 0.38 0 setcmykcolor}def |
|---|
| 98 | /CarnationPink{0 0.63 0 0 setcmykcolor}def |
|---|
| 99 | /Magenta{0 1 0 0 setcmykcolor}def |
|---|
| 100 | /VioletRed{0 0.81 0 0 setcmykcolor}def |
|---|
| 101 | /Rhodamine{0 0.82 0 0 setcmykcolor}def |
|---|
| 102 | /Mulberry{0.34 0.90 0 0.02 setcmykcolor}def |
|---|
| 103 | /RedViolet{0.07 0.90 0 0.34 setcmykcolor}def |
|---|
| 104 | /Fuchsia{0.47 0.91 0 0.08 setcmykcolor}def |
|---|
| 105 | /Lavender{0 0.48 0 0 setcmykcolor}def |
|---|
| 106 | /Thistle{0.12 0.59 0 0 setcmykcolor}def |
|---|
| 107 | /Orchid{0.32 0.64 0 0 setcmykcolor}def |
|---|
| 108 | /DarkOrchid{0.40 0.80 0.20 0 setcmykcolor}def |
|---|
| 109 | /Purple{0.45 0.86 0 0 setcmykcolor}def |
|---|
| 110 | /Plum{0.50 1 0 0 setcmykcolor}def |
|---|
| 111 | /Violet{0.79 0.88 0 0 setcmykcolor}def |
|---|
| 112 | /RoyalPurple{0.75 0.90 0 0 setcmykcolor}def |
|---|
| 113 | /BlueViolet{0.86 0.91 0 0.04 setcmykcolor}def |
|---|
| 114 | /Periwinkle{0.57 0.55 0 0 setcmykcolor}def |
|---|
| 115 | /CadetBlue{0.62 0.57 0.23 0 setcmykcolor}def |
|---|
| 116 | /CornflowerBlue{0.65 0.13 0 0 setcmykcolor}def |
|---|
| 117 | /MidnightBlue{0.98 0.13 0 0.43 setcmykcolor}def |
|---|
| 118 | /NavyBlue{0.94 0.54 0 0 setcmykcolor}def |
|---|
| 119 | /RoyalBlue{1 0.50 0 0 setcmykcolor}def |
|---|
| 120 | /Blue{1 1 0 0 setcmykcolor}def |
|---|
| 121 | /Cerulean{0.94 0.11 0 0 setcmykcolor}def |
|---|
| 122 | /Cyan{1 0 0 0 setcmykcolor}def |
|---|
| 123 | /ProcessBlue{0.96 0 0 0 setcmykcolor}def |
|---|
| 124 | /SkyBlue{0.62 0 0.12 0 setcmykcolor}def |
|---|
| 125 | /Turquoise{0.85 0 0.20 0 setcmykcolor}def |
|---|
| 126 | /TealBlue{0.86 0 0.34 0.02 setcmykcolor}def |
|---|
| 127 | /Aquamarine{0.82 0 0.30 0 setcmykcolor}def |
|---|
| 128 | /BlueGreen{0.85 0 0.33 0 setcmykcolor}def |
|---|
| 129 | /Emerald{1 0 0.50 0 setcmykcolor}def |
|---|
| 130 | /JungleGreen{0.99 0 0.52 0 setcmykcolor}def |
|---|
| 131 | /SeaGreen{0.69 0 0.50 0 setcmykcolor}def |
|---|
| 132 | /Green{1 0 1 0 setcmykcolor}def |
|---|
| 133 | /ForestGreen{0.91 0 0.88 0.12 setcmykcolor}def |
|---|
| 134 | /PineGreen{0.92 0 0.59 0.25 setcmykcolor}def |
|---|
| 135 | /LimeGreen{0.50 0 1 0 setcmykcolor}def |
|---|
| 136 | /YellowGreen{0.44 0 0.74 0 setcmykcolor}def |
|---|
| 137 | /SpringGreen{0.26 0 0.76 0 setcmykcolor}def |
|---|
| 138 | /OliveGreen{0.64 0 0.95 0.40 setcmykcolor}def |
|---|
| 139 | /RawSienna{0 0.72 1 0.45 setcmykcolor}def |
|---|
| 140 | /Sepia{0 0.83 1 0.70 setcmykcolor}def |
|---|
| 141 | /Brown{0 0.81 1 0.60 setcmykcolor}def |
|---|
| 142 | /Tan{0.14 0.42 0.56 0 setcmykcolor}def |
|---|
| 143 | /Gray{0 0 0 0.50 setcmykcolor}def |
|---|
| 144 | /Black{0 0 0 1 setcmykcolor}def |
|---|
| 145 | /White{0 0 0 0 setcmykcolor}def |
|---|
| 146 | %% fin de l extrait color.pro |
|---|
| 147 | |
|---|
| 148 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 149 | %%%% autres couleurs %%%% |
|---|
| 150 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 151 | |
|---|
| 152 | /bleu {0 0 1 setrgbcolor} def |
|---|
| 153 | /rouge {1 0 0 setrgbcolor} def |
|---|
| 154 | /vert {0 .5 0 setrgbcolor} def |
|---|
| 155 | /gris {.4 .4 .4 setrgbcolor} def |
|---|
| 156 | /jaune {1 1 0 setrgbcolor} def |
|---|
| 157 | /noir {0 0 0 setrgbcolor} def |
|---|
| 158 | /blanc {1 1 1 setrgbcolor} def |
|---|
| 159 | /orange {1 .65 0 setrgbcolor} def |
|---|
| 160 | /rose {1 .01 .58 setrgbcolor} def |
|---|
| 161 | /cyan {1 0 0 0 setcmykcolor} def |
|---|
| 162 | /magenta {0 1 0 0 setcmykcolor} def |
|---|
| 163 | |
|---|
| 164 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 165 | %%%% definition du point de vue %%%% |
|---|
| 166 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 167 | %% pour la 3D conventionnelle |
|---|
| 168 | %% Dony : graphisme scientifique : page 187 |
|---|
| 169 | %% Editeur : Masson |
|---|
| 170 | |
|---|
| 171 | %% calcul des coefficients de la matrice |
|---|
| 172 | %% de transformation |
|---|
| 173 | /Sin1 {THETA sin} def |
|---|
| 174 | /Sin2 {PHI sin} def |
|---|
| 175 | /Cos1 {THETA cos} def |
|---|
| 176 | /Cos2 {PHI cos} def |
|---|
| 177 | /Cos1Sin2 {Cos1 Sin2 mul} def |
|---|
| 178 | /Sin1Sin2 {Sin1 Sin2 mul} def |
|---|
| 179 | /Cos1Cos2 {Cos1 Cos2 mul} def |
|---|
| 180 | /Sin1Cos2 {Sin1 Cos2 mul} def |
|---|
| 181 | |
|---|
| 182 | /3dto2d { |
|---|
| 183 | 6 dict begin |
|---|
| 184 | /Zcote exch def |
|---|
| 185 | /Yordonnee exch def |
|---|
| 186 | /Xabscisse exch def |
|---|
| 187 | /xObservateur |
|---|
| 188 | Xabscisse Sin1 mul neg Yordonnee Cos1 mul add |
|---|
| 189 | def |
|---|
| 190 | /yObservateur |
|---|
| 191 | Xabscisse Cos1Sin2 mul neg Yordonnee Sin1Sin2 mul sub Zcote Cos2 |
|---|
| 192 | mul add |
|---|
| 193 | def |
|---|
| 194 | /zObservateur |
|---|
| 195 | Xabscisse neg Cos1Cos2 mul Yordonnee Sin1Cos2 mul sub Zcote Sin2 |
|---|
| 196 | mul sub Dobs add |
|---|
| 197 | def |
|---|
| 198 | %% maintenant on depose les resultats sur la pile |
|---|
| 199 | Decran xObservateur mul zObservateur div cm |
|---|
| 200 | Decran yObservateur mul zObservateur div cm |
|---|
| 201 | end |
|---|
| 202 | } def |
|---|
| 203 | |
|---|
| 204 | /getpointVue { |
|---|
| 205 | XpointVue |
|---|
| 206 | YpointVue |
|---|
| 207 | ZpointVue |
|---|
| 208 | } def |
|---|
| 209 | |
|---|
| 210 | /GetCamPos { |
|---|
| 211 | getpointVue |
|---|
| 212 | } def |
|---|
| 213 | |
|---|
| 214 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 215 | %%%% jps modifie pour PSTricks %%%% |
|---|
| 216 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 217 | |
|---|
| 218 | /solid {continu} def |
|---|
| 219 | /dashed {pointilles} def |
|---|
| 220 | /dotted { [2] 0 setdash } def |
|---|
| 221 | |
|---|
| 222 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 223 | %%%% geometrie basique %%%% |
|---|
| 224 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 225 | |
|---|
| 226 | %% syntaxe~: [x1 y1 ... xn yn] ligne |
|---|
| 227 | /ligne { |
|---|
| 228 | gsave |
|---|
| 229 | newpath |
|---|
| 230 | dup 0 getp smoveto |
|---|
| 231 | ligne_ |
|---|
| 232 | starfill |
|---|
| 233 | Stroke |
|---|
| 234 | grestore |
|---|
| 235 | } def |
|---|
| 236 | |
|---|
| 237 | %% syntaxe~: [x1 y1 ... xn yn] ligne_ |
|---|
| 238 | /ligne_ { |
|---|
| 239 | reversep |
|---|
| 240 | aload length 2 idiv |
|---|
| 241 | { |
|---|
| 242 | slineto |
|---|
| 243 | } repeat |
|---|
| 244 | } def |
|---|
| 245 | |
|---|
| 246 | %% syntaxe~: [x1 y1 ... xn yn] polygone |
|---|
| 247 | /polygone* { |
|---|
| 248 | 1 dict begin |
|---|
| 249 | /startest {true} def |
|---|
| 250 | polygone |
|---|
| 251 | end |
|---|
| 252 | } def |
|---|
| 253 | |
|---|
| 254 | /polygone_ { |
|---|
| 255 | newpath |
|---|
| 256 | aload length 2 idiv |
|---|
| 257 | 3 copy pop |
|---|
| 258 | smoveto |
|---|
| 259 | { |
|---|
| 260 | slineto |
|---|
| 261 | } repeat |
|---|
| 262 | closepath |
|---|
| 263 | } def |
|---|
| 264 | |
|---|
| 265 | /polygone { |
|---|
| 266 | gsave |
|---|
| 267 | polygone_ |
|---|
| 268 | starfill |
|---|
| 269 | currentlinewidth 0 eq {} { Stroke } ifelse |
|---|
| 270 | grestore |
|---|
| 271 | } def |
|---|
| 272 | |
|---|
| 273 | %% syntaxe : x y point |
|---|
| 274 | /point { |
|---|
| 275 | gsave |
|---|
| 276 | 1 setlinecap |
|---|
| 277 | newpath |
|---|
| 278 | smoveto |
|---|
| 279 | 0 0 rlineto |
|---|
| 280 | 5 setlinewidth |
|---|
| 281 | Stroke |
|---|
| 282 | grestore |
|---|
| 283 | } def |
|---|
| 284 | |
|---|
| 285 | /point_ { |
|---|
| 286 | 1 setlinecap |
|---|
| 287 | 5 setlinewidth |
|---|
| 288 | smoveto |
|---|
| 289 | 0 0 rlineto |
|---|
| 290 | } def |
|---|
| 291 | |
|---|
| 292 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 293 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 294 | %%%% %%%% |
|---|
| 295 | %%%% insertion librairie jps %%%% |
|---|
| 296 | %%%% %%%% |
|---|
| 297 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 298 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 299 | |
|---|
| 300 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 301 | %%%% le repere jps %%%% |
|---|
| 302 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 303 | |
|---|
| 304 | %%%%% ### AAAopacity ### |
|---|
| 305 | |
|---|
| 306 | %% les parametres pour la gestion de la transparence |
|---|
| 307 | |
|---|
| 308 | /setstrokeopacity { /strokeopacity exch def } def |
|---|
| 309 | /setfillopacity { /fillopacity exch def } def |
|---|
| 310 | |
|---|
| 311 | %% d apres un code de Jean-Michel Sarlat |
|---|
| 312 | %% http://melusine.eu.org/syracuse/swf/pdf2swf/setdash/ |
|---|
| 313 | %% Mise en reserve de la procedure stroke originelle. |
|---|
| 314 | /sysstroke {systemdict /stroke get exec} def |
|---|
| 315 | /sysfill {systemdict /fill get exec} def |
|---|
| 316 | /sysatan {systemdict /atan get exec} def |
|---|
| 317 | /atan {2 copy 0 0 eqp {pop pop 0} {sysatan} ifelse} def |
|---|
| 318 | % Mise en place de la nouvelle procedure |
|---|
| 319 | /Stroke { /strokeopacity where { /strokeopacity get }{ 1 } ifelse |
|---|
| 320 | .setopacityalpha sysstroke |
|---|
| 321 | } def |
|---|
| 322 | /Fill { /fillopacity where { /fillopacity get }{ 1 } ifelse |
|---|
| 323 | .setopacityalpha sysfill |
|---|
| 324 | } def |
|---|
| 325 | |
|---|
| 326 | %%%%% ### AAAscale ### |
|---|
| 327 | %%%%%%%%%%%%%%%% les deplacements a l echelle %%%%%%%%%%%%%%%%%%% |
|---|
| 328 | |
|---|
| 329 | /v@ct_I {xunit 0} def |
|---|
| 330 | /v@ct_J {angle_repere cos yunit mul angle_repere sin yunit mul} def |
|---|
| 331 | |
|---|
| 332 | /xscale {} def |
|---|
| 333 | /yscale {} def |
|---|
| 334 | |
|---|
| 335 | /xscale-1 {} def |
|---|
| 336 | /yscale-1 {} def |
|---|
| 337 | |
|---|
| 338 | /gtransform {} def |
|---|
| 339 | /gtransform-1 {} def |
|---|
| 340 | |
|---|
| 341 | /jtoppoint { |
|---|
| 342 | 2 dict begin |
|---|
| 343 | gtransform |
|---|
| 344 | /y exch yscale def |
|---|
| 345 | /x exch xscale def |
|---|
| 346 | v@ct_I x mulv |
|---|
| 347 | v@ct_J y mulv |
|---|
| 348 | addv |
|---|
| 349 | end |
|---|
| 350 | } def |
|---|
| 351 | |
|---|
| 352 | /rptojpoint { |
|---|
| 353 | xtranslate ytranslate |
|---|
| 354 | 3 1 roll %% xA yB yA xB |
|---|
| 355 | 4 1 roll %% xB xA yB yA |
|---|
| 356 | sub neg 3 1 roll %% yB-yA xB xA |
|---|
| 357 | sub neg exch |
|---|
| 358 | ptojpoint |
|---|
| 359 | } def |
|---|
| 360 | |
|---|
| 361 | /rptoppoint { |
|---|
| 362 | xtranslate ytranslate |
|---|
| 363 | 3 1 roll %% xA yB yA xB |
|---|
| 364 | 4 1 roll %% xB xA yB yA |
|---|
| 365 | sub neg 3 1 roll %% yB-yA xB xA |
|---|
| 366 | sub neg exch |
|---|
| 367 | } def |
|---|
| 368 | |
|---|
| 369 | /ptojpoint { |
|---|
| 370 | 4 dict begin |
|---|
| 371 | /Y exch yscale-1 def |
|---|
| 372 | /X exch xscale-1 def |
|---|
| 373 | /y Y yunit angle_repere sin mul div def |
|---|
| 374 | /x X y yunit mul angle_repere cos mul sub xunit div def |
|---|
| 375 | x y |
|---|
| 376 | gtransform-1 |
|---|
| 377 | end |
|---|
| 378 | } def |
|---|
| 379 | |
|---|
| 380 | /smoveto { |
|---|
| 381 | jtoppoint |
|---|
| 382 | moveto |
|---|
| 383 | } def |
|---|
| 384 | |
|---|
| 385 | /srmoveto { |
|---|
| 386 | jtoppoint |
|---|
| 387 | rmoveto |
|---|
| 388 | } def |
|---|
| 389 | |
|---|
| 390 | /slineto { |
|---|
| 391 | jtoppoint |
|---|
| 392 | lineto |
|---|
| 393 | } def |
|---|
| 394 | |
|---|
| 395 | /srlineto { |
|---|
| 396 | jtoppoint |
|---|
| 397 | rlineto |
|---|
| 398 | } def |
|---|
| 399 | |
|---|
| 400 | /stranslate { |
|---|
| 401 | jtoppoint |
|---|
| 402 | translate |
|---|
| 403 | } def |
|---|
| 404 | |
|---|
| 405 | %%%%% ### fin insertion ### |
|---|
| 406 | |
|---|
| 407 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 408 | %%%% methodes numeriques %%%% |
|---|
| 409 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 410 | |
|---|
| 411 | %%%%% ### solve2nddegre ### |
|---|
| 412 | %% syntaxe : a b c solve2nddegre --> x1 x2 |
|---|
| 413 | /solve2nddegre { |
|---|
| 414 | 5 dict begin |
|---|
| 415 | /@c exch def |
|---|
| 416 | /@b exch def |
|---|
| 417 | /@a exch def |
|---|
| 418 | /delt@ @b dup mul 4 @a mul @c mul sub def |
|---|
| 419 | @b neg delt@ sqrt sub 2 @a mul div |
|---|
| 420 | @b neg delt@ sqrt add 2 @a mul div |
|---|
| 421 | end |
|---|
| 422 | } def |
|---|
| 423 | |
|---|
| 424 | %%%%% ### fin insertion ### |
|---|
| 425 | |
|---|
| 426 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 427 | %%%% la 2D %%%% |
|---|
| 428 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 429 | |
|---|
| 430 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 431 | %%%% points %%%% |
|---|
| 432 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 433 | |
|---|
| 434 | %%%%% ### tripointangle ### |
|---|
| 435 | %% syntaxe : A B C tripointangle --> angle ABC |
|---|
| 436 | /tripointangle { |
|---|
| 437 | 9 dict begin |
|---|
| 438 | /yC exch def |
|---|
| 439 | /xC exch def |
|---|
| 440 | /yB exch def |
|---|
| 441 | /xB exch def |
|---|
| 442 | /yA exch def |
|---|
| 443 | /xA exch def |
|---|
| 444 | /A {xA yA} def |
|---|
| 445 | /B {xB yB} def |
|---|
| 446 | /C {xC yC} def |
|---|
| 447 | B C angle |
|---|
| 448 | B A angle |
|---|
| 449 | sub |
|---|
| 450 | end |
|---|
| 451 | } def |
|---|
| 452 | |
|---|
| 453 | %%%%% ### angle ### |
|---|
| 454 | %% syntaxe : A B angle |
|---|
| 455 | %% --> num, l'angle defini par le vecteur AB dans le repere orthonorme jps |
|---|
| 456 | /angle { |
|---|
| 457 | vecteur exch atan |
|---|
| 458 | dup 180 gt |
|---|
| 459 | {360 sub} |
|---|
| 460 | if |
|---|
| 461 | } def |
|---|
| 462 | |
|---|
| 463 | %% syntaxe : A B pangle |
|---|
| 464 | %% --> num, l'angle defini par le vecteur AB dans le repere postscript |
|---|
| 465 | /pangle { |
|---|
| 466 | jtoppoint exchp jtoppoint exchp vecteur exch atan |
|---|
| 467 | dup 180 gt |
|---|
| 468 | {360 sub} |
|---|
| 469 | if |
|---|
| 470 | } def |
|---|
| 471 | |
|---|
| 472 | %%%%% ### setxrange ### |
|---|
| 473 | /setxrange { |
|---|
| 474 | /xmax exch def |
|---|
| 475 | /xmin exch def |
|---|
| 476 | } def |
|---|
| 477 | |
|---|
| 478 | %%%%% ### setyrange ### |
|---|
| 479 | /setyrange { |
|---|
| 480 | /ymax exch def |
|---|
| 481 | /ymin exch def |
|---|
| 482 | } def |
|---|
| 483 | |
|---|
| 484 | %%%%% ### defpoint ### |
|---|
| 485 | %% syntaxe : xA yA /A defpoint |
|---|
| 486 | /defpoint { |
|---|
| 487 | 1 dict begin |
|---|
| 488 | /t@mp@r@ire exch def |
|---|
| 489 | [ 3 1 roll ] cvx t@mp@r@ire exch |
|---|
| 490 | end def |
|---|
| 491 | } def |
|---|
| 492 | |
|---|
| 493 | %%%%% ### milieu ### |
|---|
| 494 | %% syntaxe~: A B milieu |
|---|
| 495 | /milieu { |
|---|
| 496 | %% xA yA xB yB |
|---|
| 497 | 3 -1 roll %% xA xB yB yA |
|---|
| 498 | add 2 div %% xA xB yM |
|---|
| 499 | 3 1 roll %% yM xA xB |
|---|
| 500 | add 2 div %% yM xM |
|---|
| 501 | exch |
|---|
| 502 | } def |
|---|
| 503 | |
|---|
| 504 | %%%%% ### parallelopoint ### |
|---|
| 505 | %% syntaxe : A B C parallelopoint --> point D, tel que ABCD parallelogramme |
|---|
| 506 | /parallelopoint { |
|---|
| 507 | 11 dict begin |
|---|
| 508 | /yC exch def |
|---|
| 509 | /xC exch def |
|---|
| 510 | /yB exch def |
|---|
| 511 | /xB exch def |
|---|
| 512 | /yA exch def |
|---|
| 513 | /xA exch def |
|---|
| 514 | /A {xA yA} def |
|---|
| 515 | /B {xB yB} def |
|---|
| 516 | /C {xC yC} def |
|---|
| 517 | /d1 {A B C paral} def |
|---|
| 518 | /d2 {B C A paral} def |
|---|
| 519 | d1 d2 interdroite |
|---|
| 520 | end |
|---|
| 521 | } def |
|---|
| 522 | |
|---|
| 523 | %%%%% ### translatepoint ### |
|---|
| 524 | %% syntaxe : A u translatepoint --> B image de A par la translation de vecteur u |
|---|
| 525 | /translatepoint { |
|---|
| 526 | addv |
|---|
| 527 | } def |
|---|
| 528 | |
|---|
| 529 | %%%%% ### rotatepoint ### |
|---|
| 530 | %% syntaxe : B A r rotatepoint --> C image de B par la rotation de centre A, |
|---|
| 531 | %% d'angle r (en degre) |
|---|
| 532 | %% En prenant les affixes des pts associes, il vient |
|---|
| 533 | %% (zC - zA) = (zB-zA) e^(ir) |
|---|
| 534 | %% soit |
|---|
| 535 | %% zC = (zB-zA) e^(ir) + zA |
|---|
| 536 | /rotatepoint { %% B, A, r |
|---|
| 537 | 5 copy %% B, A, r, B, A, r |
|---|
| 538 | cos 5 1 roll %% B, A, r, cos r, B, A |
|---|
| 539 | 4 1 roll %% B, A, r, cos r, yA, B, xA |
|---|
| 540 | 4 1 roll %% B, A, r, cos r, A, B |
|---|
| 541 | vecteur %% B, A, r, cos r, xB-xA, yB-yA |
|---|
| 542 | 4 -1 roll sin %% B, A, cos r, xB-xA, yB-yA, sin r |
|---|
| 543 | 4 copy mul %% B, A, cos r, xB-xA, yB-yA, sin r, cos r, xB-xA, (yB-yA) sin r |
|---|
| 544 | 7 1 roll mul %% B, A, (yB-yA) sin r, cos r, xB-xA, yB-yA, sin r, cos r (xB-xA) |
|---|
| 545 | 5 1 roll %% B, A, (yB-yA) sin r, cos r (xB-xA), cos r, xB-xA, yB-yA, sin r |
|---|
| 546 | exch %% B, A, (yB-yA) sin r, cos r (xB-xA), cos r, xB-xA, sin r, yB-yA |
|---|
| 547 | 4 -1 roll mul %% B, A, (yB-yA) sin r, cos r (xB-xA), xB-xA, sin r, (yB-yA)cos r |
|---|
| 548 | 3 1 roll mul %% B, A, (yB-yA) sin r, cos r (xB-xA), (yB-yA) cos r, (xB-xA) sin r |
|---|
| 549 | add %% B, A, (yB-yA) sin r, cos r (xB-xA), (yB-yA) cos r +(xB-xA) sin r |
|---|
| 550 | 3 1 roll %% B, A, (yB-yA) cos r + (xB-xA) sin r, (yB-yA) sin r, cos r (xB-xA), |
|---|
| 551 | exch sub %% B, A, (yB-yA) cos r + (xB-xA) sin r, cos r (xB-xA)-(yB-yA) sin r |
|---|
| 552 | exch %% B, zA, (zB-zA) e^(ir) |
|---|
| 553 | addv |
|---|
| 554 | 3 -1 roll pop |
|---|
| 555 | 3 -1 roll pop |
|---|
| 556 | } def |
|---|
| 557 | |
|---|
| 558 | %%%%% ### hompoint ### |
|---|
| 559 | %% syntaxe : B A alpha hompoint -> le point A' tel que AA' = alpha AB |
|---|
| 560 | /hompoint { |
|---|
| 561 | 5 copy |
|---|
| 562 | pop |
|---|
| 563 | vecteur %% vecteur BA |
|---|
| 564 | 3 -1 roll |
|---|
| 565 | neg |
|---|
| 566 | mulv %% alpha x vecteur AB |
|---|
| 567 | addv |
|---|
| 568 | 4 -1 roll |
|---|
| 569 | 4 -1 roll |
|---|
| 570 | pop pop |
|---|
| 571 | } def |
|---|
| 572 | |
|---|
| 573 | %%%%% ### orthoproj ### |
|---|
| 574 | %% syntaxe : A D orthoproj --> B, le projete orthogonal de A sur D |
|---|
| 575 | /orthoproj { |
|---|
| 576 | 6 -1 roll |
|---|
| 577 | 6 -1 roll %% D A |
|---|
| 578 | 6 copy %% D A D A |
|---|
| 579 | 7 -1 roll pop |
|---|
| 580 | 7 -1 roll pop %% D D A |
|---|
| 581 | perp |
|---|
| 582 | interdroite |
|---|
| 583 | } def |
|---|
| 584 | |
|---|
| 585 | %% syntaxe : A projx --> le projete orthogonal de A sur Ox |
|---|
| 586 | /projx { |
|---|
| 587 | pop 0 |
|---|
| 588 | } def |
|---|
| 589 | |
|---|
| 590 | %% syntaxe : A projy --> le projete orthogonal de A sur Oy |
|---|
| 591 | /projy { |
|---|
| 592 | exch pop 0 exch |
|---|
| 593 | } def |
|---|
| 594 | |
|---|
| 595 | %%%%% ### sympoint ### |
|---|
| 596 | %% syntaxe : A I sympoint --> point A', le symetrique de A par rapport |
|---|
| 597 | %% au point I |
|---|
| 598 | /sympoint { |
|---|
| 599 | 4 copy |
|---|
| 600 | pop pop |
|---|
| 601 | vecteur |
|---|
| 602 | -2 mulv |
|---|
| 603 | addv |
|---|
| 604 | } def |
|---|
| 605 | |
|---|
| 606 | %%%%% ### axesympoint ### |
|---|
| 607 | %% syntaxe : A D axesympoint --> point B, le symetrique de A par rapport |
|---|
| 608 | %% a la droite D |
|---|
| 609 | /axesympoint { |
|---|
| 610 | 2 dict begin |
|---|
| 611 | 6 copy |
|---|
| 612 | pop pop pop pop |
|---|
| 613 | /yA exch def |
|---|
| 614 | /xA exch def |
|---|
| 615 | orthoproj |
|---|
| 616 | xA yA vecteur |
|---|
| 617 | -2 mulv |
|---|
| 618 | xA yA addv |
|---|
| 619 | end |
|---|
| 620 | } def |
|---|
| 621 | |
|---|
| 622 | %%%%% ### cpoint ### |
|---|
| 623 | %% syntaxe : alpha C cpoint -> M, le point du cercle C correspondant a |
|---|
| 624 | %% l'angle alpha |
|---|
| 625 | /cpoint { %% a, xI, yI, r |
|---|
| 626 | 1 dict begin |
|---|
| 627 | dup %% a, xI, yI, r, r |
|---|
| 628 | 5 -1 roll %% xI, yI, r, r, a |
|---|
| 629 | /alpha exch def |
|---|
| 630 | alpha cos mul %% xI, yI, r, r cos a |
|---|
| 631 | exch |
|---|
| 632 | alpha sin mul %% xI, yI, r cos a, r sin a |
|---|
| 633 | 3 -1 roll add %% xI, r cos a, yI + r sin a |
|---|
| 634 | 3 1 roll %% yI + r sin a, xI, r cos a, |
|---|
| 635 | add exch %% xI + r cos a, yI + r sin a |
|---|
| 636 | end |
|---|
| 637 | } def |
|---|
| 638 | |
|---|
| 639 | %%%%% ### xdpoint ### |
|---|
| 640 | %% x A B xdpoint : le point de la droite (AB) d'abscisse x |
|---|
| 641 | /xdpoint { |
|---|
| 642 | 5 dict begin |
|---|
| 643 | /pt2 defpoint |
|---|
| 644 | /pt1 defpoint |
|---|
| 645 | /x exch def |
|---|
| 646 | /a pt1 pt2 coeffdir def |
|---|
| 647 | /b pt1 pt2 ordorig def |
|---|
| 648 | x dup a mul b add |
|---|
| 649 | end |
|---|
| 650 | } def |
|---|
| 651 | |
|---|
| 652 | %%%%% ### ydpoint ### |
|---|
| 653 | %% y A B ydpoint : le point de la droite (AB) d'ordonnee y |
|---|
| 654 | /ydpoint { |
|---|
| 655 | 5 dict begin |
|---|
| 656 | /pt2 defpoint |
|---|
| 657 | /pt1 defpoint |
|---|
| 658 | /y exch def |
|---|
| 659 | pt1 pt2 verticale? |
|---|
| 660 | { |
|---|
| 661 | pt1 pop y |
|---|
| 662 | } |
|---|
| 663 | { |
|---|
| 664 | /a pt1 pt2 coeffdir def |
|---|
| 665 | /b pt1 pt2 ordorig def |
|---|
| 666 | y b sub a div y |
|---|
| 667 | } |
|---|
| 668 | ifelse |
|---|
| 669 | end |
|---|
| 670 | } def |
|---|
| 671 | |
|---|
| 672 | %%%%% ### ordonnepoints ### |
|---|
| 673 | %% syntaxe : xA yA xB yB ordonnepoints --> idem si yB>yA ou si yB=yA |
|---|
| 674 | %% avec xB>xA, sinon xB yB xA yA |
|---|
| 675 | /ordonnepoints { |
|---|
| 676 | 4 copy |
|---|
| 677 | exch pop %% ... xA, yA, yB |
|---|
| 678 | lt %% yA < yB ? |
|---|
| 679 | {pop} %% oui, c'est fini |
|---|
| 680 | { %% non : yA >= yB |
|---|
| 681 | pop 4 copy |
|---|
| 682 | exch pop %% ... xA, yA, yB |
|---|
| 683 | eq %% yA = yB ? |
|---|
| 684 | { |
|---|
| 685 | 3 copy %% oui, yA = yB |
|---|
| 686 | pop pop %% ... xA, xB |
|---|
| 687 | le %% xA =< xB ? |
|---|
| 688 | {} %% oui, c'est fini |
|---|
| 689 | { %% non, on echange A et B |
|---|
| 690 | 4 -1 roll |
|---|
| 691 | 4 -1 roll |
|---|
| 692 | } |
|---|
| 693 | ifelse |
|---|
| 694 | } |
|---|
| 695 | { %% non : yA < yB => on echange A et B |
|---|
| 696 | pop |
|---|
| 697 | 4 -1 roll |
|---|
| 698 | 4 -1 roll |
|---|
| 699 | } |
|---|
| 700 | ifelse |
|---|
| 701 | } |
|---|
| 702 | ifelse |
|---|
| 703 | } def |
|---|
| 704 | |
|---|
| 705 | %%%%% ### distance ### |
|---|
| 706 | %% syntaxe~: A B distance |
|---|
| 707 | /distance { %% xA yA xB yB |
|---|
| 708 | vecteur %% x y |
|---|
| 709 | dup mul exch %% y^2 x |
|---|
| 710 | dup mul %% y^2 x^2 |
|---|
| 711 | add |
|---|
| 712 | sqrt |
|---|
| 713 | } def |
|---|
| 714 | |
|---|
| 715 | %%%%% ### dup ### |
|---|
| 716 | /dupp {2 copy} def |
|---|
| 717 | /dupc {3 copy} def |
|---|
| 718 | /dupd {4 copy} def |
|---|
| 719 | |
|---|
| 720 | %%%%% ### fin insertion ### |
|---|
| 721 | /interdroites {interdroite} def |
|---|
| 722 | |
|---|
| 723 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 724 | %%%% vecteurs %%%% |
|---|
| 725 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 726 | |
|---|
| 727 | %%%%% ### vecteur ### |
|---|
| 728 | %% syntaxe~: A B vecteur |
|---|
| 729 | /vecteur { |
|---|
| 730 | %% xA yA xB yB |
|---|
| 731 | 3 -1 roll %% xA xB yB yA |
|---|
| 732 | sub %% xA xB yB-yA |
|---|
| 733 | 3 1 roll %% yB-yA xA xB |
|---|
| 734 | exch sub %% yB-yA xB-xA |
|---|
| 735 | exch |
|---|
| 736 | } def |
|---|
| 737 | |
|---|
| 738 | %%%%% ### normalize ### |
|---|
| 739 | %% syntaxe : u normalize -> u / ||u|| |
|---|
| 740 | /normalize { |
|---|
| 741 | 2 dict begin |
|---|
| 742 | /u defpoint |
|---|
| 743 | /n u norme def |
|---|
| 744 | u 1 n div mulv |
|---|
| 745 | end |
|---|
| 746 | } def |
|---|
| 747 | |
|---|
| 748 | %%%%% ### addv ### |
|---|
| 749 | %% syntaxe : u v addv --> u+v |
|---|
| 750 | /addv { %% xA yA xB yB |
|---|
| 751 | 3 1 roll %% xA yB yA xB |
|---|
| 752 | 4 1 roll %% xB xA yB yA |
|---|
| 753 | add 3 1 roll %% yB+yA xB xA |
|---|
| 754 | add exch |
|---|
| 755 | } def |
|---|
| 756 | |
|---|
| 757 | %%%%% ### subv ### |
|---|
| 758 | %% syntaxe : u v subv --> u - v |
|---|
| 759 | /subv { %% xA yA xB yB |
|---|
| 760 | -1 mulv |
|---|
| 761 | addv |
|---|
| 762 | } def |
|---|
| 763 | |
|---|
| 764 | %%%%% ### mulv ### |
|---|
| 765 | %% syntaxe : u a mulv --> au |
|---|
| 766 | /mulv { %% xA, yA, a |
|---|
| 767 | dup %% xA, yA, a, a |
|---|
| 768 | 3 1 roll %% xA, a, yA, a |
|---|
| 769 | mul 3 1 roll %% ayA, xA, a |
|---|
| 770 | mul exch |
|---|
| 771 | } def |
|---|
| 772 | |
|---|
| 773 | %%%%% ### scalprod ### |
|---|
| 774 | %% syntaxe : u v scalprod --> le produit scalaire de u par v |
|---|
| 775 | /scalprod { |
|---|
| 776 | 2 dict begin |
|---|
| 777 | /y' exch def |
|---|
| 778 | exch |
|---|
| 779 | /y exch def |
|---|
| 780 | mul y y' mul add |
|---|
| 781 | end |
|---|
| 782 | } def |
|---|
| 783 | |
|---|
| 784 | %%%%% ### normal ### |
|---|
| 785 | %% syntaxe : u normal --> v tel u.v = 0 |
|---|
| 786 | /normal { |
|---|
| 787 | neg exch |
|---|
| 788 | } def |
|---|
| 789 | |
|---|
| 790 | %%%%% ### norme ### |
|---|
| 791 | %% syntaxe : u norme --> |u| |
|---|
| 792 | /norme { |
|---|
| 793 | dup mul |
|---|
| 794 | exch |
|---|
| 795 | dup mul |
|---|
| 796 | add sqrt |
|---|
| 797 | } def |
|---|
| 798 | |
|---|
| 799 | %%%%% ### oldarrow ### |
|---|
| 800 | %% syntaxe : A B oldarrow --> trace fleche en B, direction AB |
|---|
| 801 | /oldarrow { |
|---|
| 802 | 4 dict begin |
|---|
| 803 | gsave |
|---|
| 804 | /B defpoint |
|---|
| 805 | /A defpoint |
|---|
| 806 | oldarrowscale scale |
|---|
| 807 | oldarrowangle rotate |
|---|
| 808 | newpath |
|---|
| 809 | B smoveto |
|---|
| 810 | A B vecteur normalize /u defpoint |
|---|
| 811 | u neg exch /v defpoint |
|---|
| 812 | u oldarrowpointe neg mulv rmoveto %% ainsi c'est la pointe qui est en (0, 0) |
|---|
| 813 | %% le pt extremal arriere haut |
|---|
| 814 | u oldarrowplume neg mulv %% l'abscisse |
|---|
| 815 | v oldarrow@ngle sin oldarrow@ngle cos div oldarrowplume mul mulv addv %% l'ordonnee |
|---|
| 816 | rlineto |
|---|
| 817 | u oldarrowplume oldarrowpointe add mulv |
|---|
| 818 | v oldarrow@ngle sin oldarrow@ngle cos div oldarrowplume mul neg mulv addv |
|---|
| 819 | rlineto |
|---|
| 820 | u oldarrowplume oldarrowpointe add neg mulv |
|---|
| 821 | v oldarrow@ngle sin oldarrow@ngle cos div oldarrowplume mul neg mulv addv |
|---|
| 822 | rlineto |
|---|
| 823 | closepath Fill |
|---|
| 824 | grestore |
|---|
| 825 | end |
|---|
| 826 | } def |
|---|
| 827 | |
|---|
| 828 | /oldarrowpointe {xunit 5 div} def |
|---|
| 829 | /oldarrowplume {xunit 10 div} def |
|---|
| 830 | /oldarrow@ngle 45 def |
|---|
| 831 | /oldarrowscale {1 1} def |
|---|
| 832 | /oldarrowangle 0 def %% pour l'utilisateur |
|---|
| 833 | |
|---|
| 834 | %%%%% ### drawvecteur ### |
|---|
| 835 | %% syntaxe : A B drawvecteur |
|---|
| 836 | /drawvecteur { |
|---|
| 837 | 2 dict begin |
|---|
| 838 | /B defpoint |
|---|
| 839 | /A defpoint |
|---|
| 840 | [A B] ligne |
|---|
| 841 | A B oldarrow |
|---|
| 842 | end |
|---|
| 843 | } def |
|---|
| 844 | |
|---|
| 845 | %%%%% ### orthovecteur ### |
|---|
| 846 | %% syntaxe : u orthovecteur --> v, vecteur orthogonal a u |
|---|
| 847 | /orthovecteur { |
|---|
| 848 | neg exch |
|---|
| 849 | } def |
|---|
| 850 | |
|---|
| 851 | %%%%% ### fin insertion ### |
|---|
| 852 | |
|---|
| 853 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 854 | %%%% cercles %%%% |
|---|
| 855 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 856 | |
|---|
| 857 | %%%%% ### defcercle ### |
|---|
| 858 | %% syntaxe : A r /d defcercle |
|---|
| 859 | /defcercle { |
|---|
| 860 | 1 dict begin |
|---|
| 861 | /t@mp@r@ire exch def |
|---|
| 862 | [ 4 1 roll ] cvx t@mp@r@ire exch |
|---|
| 863 | end def |
|---|
| 864 | } def |
|---|
| 865 | |
|---|
| 866 | %%%%% ### interdroitecercle ### |
|---|
| 867 | %% intersection de la droite y = ax+b avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 |
|---|
| 868 | %% { -- b - y 2 2 3 |
|---|
| 869 | %% { | x = - -----, y = (b + a x0 + a y0 + (2 a b y0 - 2 a b x0 + |
|---|
| 870 | %% { -- a |
|---|
| 871 | %% |
|---|
| 872 | %% 3 2 2 2 2 4 2 2 2 4 2 2 |
|---|
| 873 | %% 2 a x0 y0 - a b + a r + a r - a y0 - a x0 )^(1/2)) / (a + 1) |
|---|
| 874 | %% |
|---|
| 875 | %% |
|---|
| 876 | %% -- |
|---|
| 877 | %% |, |
|---|
| 878 | %% -- |
|---|
| 879 | %% -- b - y 2 2 3 |
|---|
| 880 | %% | x = - -----, y = (b + a x0 + a y0 - (2 a b y0 - 2 a b x0 + |
|---|
| 881 | %% -- a |
|---|
| 882 | %% |
|---|
| 883 | %% 3 2 2 2 2 4 2 2 2 4 2 2 |
|---|
| 884 | %% 2 a x0 y0 - a b + a r + a r - a y0 - a x0 )^(1/2)) / (a + 1) |
|---|
| 885 | %% |
|---|
| 886 | %% -- } |
|---|
| 887 | %% | } |
|---|
| 888 | %% -- } |
|---|
| 889 | |
|---|
| 890 | %% intersection de la droite x = a avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 |
|---|
| 891 | %% 2 2 2 1/2 |
|---|
| 892 | %% {[x = a, y = y0 + (2 a x0 - a + r - x0 ) ], |
|---|
| 893 | %% |
|---|
| 894 | %% 2 2 2 1/2 |
|---|
| 895 | %% [x = a, y = y0 - (2 a x0 - a + r - x0 ) ]} |
|---|
| 896 | |
|---|
| 897 | %% intersection de la droite y = b avec le cercle (x-x0)^2 + (y-y0)^2 = r^2 |
|---|
| 898 | %% 2 2 2 1/2 |
|---|
| 899 | %% {[y = b, x = x0 + (2 b y0 - b + r - y0 ) ], |
|---|
| 900 | %% |
|---|
| 901 | %% 2 2 2 1/2 |
|---|
| 902 | %% [y = b, x = x0 - (2 b y0 - b + r - y0 ) ]} |
|---|
| 903 | |
|---|
| 904 | %% syntaxe : D I r interdroitecercle |
|---|
| 905 | /interdroitecercle { |
|---|
| 906 | 16 dict begin |
|---|
| 907 | /r exch def |
|---|
| 908 | /y0 exch def |
|---|
| 909 | /x0 exch def |
|---|
| 910 | /yB exch def |
|---|
| 911 | /xB exch def |
|---|
| 912 | /yA exch def |
|---|
| 913 | /xA exch def |
|---|
| 914 | |
|---|
| 915 | xA yA xB yB verticale? |
|---|
| 916 | |
|---|
| 917 | %% la droite est verticale |
|---|
| 918 | { |
|---|
| 919 | /xpt1 xA def |
|---|
| 920 | /xpt2 xA def |
|---|
| 921 | /quantite |
|---|
| 922 | 2 xA mul x0 mul xA dup mul sub r dup mul add x0 dup mul sub sqrt |
|---|
| 923 | def |
|---|
| 924 | /ypt1 |
|---|
| 925 | y0 quantite add |
|---|
| 926 | def |
|---|
| 927 | /ypt2 |
|---|
| 928 | y0 quantite sub |
|---|
| 929 | def |
|---|
| 930 | } |
|---|
| 931 | |
|---|
| 932 | %% la droite n'est pas verticale |
|---|
| 933 | { |
|---|
| 934 | /a xA yA xB yB coeffdir def |
|---|
| 935 | /b xA yA xB yB ordorig def |
|---|
| 936 | |
|---|
| 937 | 0 a eq |
|---|
| 938 | %% la droite est horizontale |
|---|
| 939 | { |
|---|
| 940 | /quantite |
|---|
| 941 | 2 b mul y0 mul |
|---|
| 942 | b dup mul sub |
|---|
| 943 | r dup mul add |
|---|
| 944 | y0 dup mul sub |
|---|
| 945 | sqrt |
|---|
| 946 | def |
|---|
| 947 | /xpt1 |
|---|
| 948 | x0 quantite add |
|---|
| 949 | def |
|---|
| 950 | /xpt2 |
|---|
| 951 | x0 quantite sub |
|---|
| 952 | def |
|---|
| 953 | /ypt1 b def |
|---|
| 954 | /ypt2 b def |
|---|
| 955 | } |
|---|
| 956 | |
|---|
| 957 | %% la droite n'est pas horizontale |
|---|
| 958 | { |
|---|
| 959 | /quantite1 |
|---|
| 960 | b |
|---|
| 961 | a x0 mul add |
|---|
| 962 | a dup mul y0 mul add |
|---|
| 963 | def |
|---|
| 964 | /quantite2 |
|---|
| 965 | 2 a dup mul mul b mul y0 mul |
|---|
| 966 | 2 a 3 exp mul b mul x0 mul sub |
|---|
| 967 | 2 a 3 exp mul x0 mul y0 mul add |
|---|
| 968 | a dup mul b dup mul mul sub |
|---|
| 969 | a dup mul r dup mul mul add |
|---|
| 970 | a 4 exp r dup mul mul add |
|---|
| 971 | a dup mul y0 dup mul mul sub |
|---|
| 972 | a 4 exp x0 dup mul mul sub |
|---|
| 973 | sqrt |
|---|
| 974 | def |
|---|
| 975 | /quantite3 |
|---|
| 976 | a dup mul 1 add |
|---|
| 977 | def |
|---|
| 978 | /ypt1 |
|---|
| 979 | quantite1 quantite2 add quantite3 div |
|---|
| 980 | def |
|---|
| 981 | /xpt1 |
|---|
| 982 | ypt1 b sub a div |
|---|
| 983 | def |
|---|
| 984 | /ypt2 |
|---|
| 985 | quantite1 quantite2 sub quantite3 div |
|---|
| 986 | def |
|---|
| 987 | /xpt2 |
|---|
| 988 | ypt2 b sub a div |
|---|
| 989 | def |
|---|
| 990 | } |
|---|
| 991 | ifelse |
|---|
| 992 | } |
|---|
| 993 | ifelse |
|---|
| 994 | |
|---|
| 995 | xpt1 ypt1 |
|---|
| 996 | xpt2 ypt2 |
|---|
| 997 | ordonnepoints |
|---|
| 998 | end |
|---|
| 999 | } def |
|---|
| 1000 | |
|---|
| 1001 | %%%%% ### intercercle ### |
|---|
| 1002 | %% syntaxe : cerc1 cerc2 intercercle --> A B les points d'intersection |
|---|
| 1003 | %% des 2 cercles, tries par 'ordonnepoints' |
|---|
| 1004 | /intercercle { |
|---|
| 1005 | 12 dict begin |
|---|
| 1006 | /r2 exch def |
|---|
| 1007 | /y2 exch def |
|---|
| 1008 | /x2 exch def |
|---|
| 1009 | /r1 exch def |
|---|
| 1010 | /y1 exch def |
|---|
| 1011 | /x1 exch def |
|---|
| 1012 | |
|---|
| 1013 | %% on translate pour se ramener a (x1, y1) = (0, 0) |
|---|
| 1014 | x2 y2 x1 y1 subv |
|---|
| 1015 | /y2 exch def |
|---|
| 1016 | /x2 exch def |
|---|
| 1017 | |
|---|
| 1018 | %% on prepare l'equation du 2nd degre |
|---|
| 1019 | |
|---|
| 1020 | %% 2 2 2 |
|---|
| 1021 | %% {y = RootOf((4 x2 + 4 y2 ) _Z |
|---|
| 1022 | %% |
|---|
| 1023 | %% 3 2 2 2 4 |
|---|
| 1024 | %% + (-4 y2 - 4 r1~ y2 + 4 y2 r2~ - 4 x2 y2) _Z + x2 |
|---|
| 1025 | %% |
|---|
| 1026 | %% 4 2 2 2 2 2 2 2 2 |
|---|
| 1027 | %% + r2~ - 2 y2 r2~ + 2 x2 y2 - 2 x2 r2~ - 2 r1~ x2 |
|---|
| 1028 | %% |
|---|
| 1029 | %% 4 4 2 2 2 2 |
|---|
| 1030 | %% + r1~ + y2 + 2 r1~ y2 - 2 r1~ r2~ ), x = 1/2 (-2 y2 |
|---|
| 1031 | %% |
|---|
| 1032 | %% 2 2 2 |
|---|
| 1033 | %% RootOf((4 x2 + 4 y2 ) _Z |
|---|
| 1034 | %% |
|---|
| 1035 | %% 3 2 2 2 4 |
|---|
| 1036 | %% + (-4 y2 - 4 r1~ y2 + 4 y2 r2~ - 4 x2 y2) _Z + x2 |
|---|
| 1037 | %% |
|---|
| 1038 | %% 4 2 2 2 2 2 2 2 2 |
|---|
| 1039 | %% + r2~ - 2 y2 r2~ + 2 x2 y2 - 2 x2 r2~ - 2 r1~ x2 |
|---|
| 1040 | %% |
|---|
| 1041 | %% 4 4 2 2 2 2 2 2 2 |
|---|
| 1042 | %% + r1~ + y2 + 2 r1~ y2 - 2 r1~ r2~ ) + r1~ + x2 + y2 |
|---|
| 1043 | %% |
|---|
| 1044 | %% 2 |
|---|
| 1045 | %% - r2~ )/x2} |
|---|
| 1046 | |
|---|
| 1047 | %% coeff pour le degre 2 |
|---|
| 1048 | /a |
|---|
| 1049 | %% 2 2 2 |
|---|
| 1050 | %% {y = RootOf((4 x2 + 4 y2 ) _Z |
|---|
| 1051 | 4 x2 dup mul mul |
|---|
| 1052 | 4 y2 dup mul mul add |
|---|
| 1053 | def |
|---|
| 1054 | |
|---|
| 1055 | %% coeff pour le degre 1 |
|---|
| 1056 | %% |
|---|
| 1057 | /b |
|---|
| 1058 | %% 3 2 2 2 |
|---|
| 1059 | %% + (-4 y2 - 4 r1~ y2 + 4 y2 r2~ - 4 x2 y2) _Z |
|---|
| 1060 | -4 y2 3 exp mul |
|---|
| 1061 | 4 r1 dup mul mul y2 mul sub |
|---|
| 1062 | 4 r2 dup mul mul y2 mul add |
|---|
| 1063 | 4 x2 dup mul mul y2 mul sub |
|---|
| 1064 | def |
|---|
| 1065 | |
|---|
| 1066 | %% coeff pour le degre 0 |
|---|
| 1067 | %% |
|---|
| 1068 | /c { |
|---|
| 1069 | %% 4 |
|---|
| 1070 | %% + x2 |
|---|
| 1071 | x2 4 exp |
|---|
| 1072 | %% |
|---|
| 1073 | %% 4 2 2 2 2 2 2 2 2 |
|---|
| 1074 | %% + r2~ - 2 y2 r2~ + 2 x2 y2 - 2 x2 r2~ - 2 r1~ x2 |
|---|
| 1075 | r2 4 exp add |
|---|
| 1076 | 2 y2 dup mul mul r2 dup mul mul sub |
|---|
| 1077 | 2 x2 dup mul mul y2 dup mul mul add |
|---|
| 1078 | 2 x2 dup mul mul r2 dup mul mul sub |
|---|
| 1079 | 2 x2 dup mul mul r1 dup mul mul sub |
|---|
| 1080 | %% |
|---|
| 1081 | %% 4 4 2 2 2 2 |
|---|
| 1082 | %% + r1~ + y2 + 2 r1~ y2 - 2 r1~ r2~ ) |
|---|
| 1083 | r1 4 exp add |
|---|
| 1084 | y2 4 exp add |
|---|
| 1085 | 2 r1 dup mul mul y2 dup mul mul add |
|---|
| 1086 | 2 r1 dup mul mul r2 dup mul mul sub |
|---|
| 1087 | } def |
|---|
| 1088 | |
|---|
| 1089 | a b c solve2nddegre |
|---|
| 1090 | /Y1 exch def |
|---|
| 1091 | /Y0 exch def |
|---|
| 1092 | |
|---|
| 1093 | /X0 |
|---|
| 1094 | %% x = 1/2 (-2 y2 Y |
|---|
| 1095 | -2 y2 mul Y0 mul |
|---|
| 1096 | %% |
|---|
| 1097 | %% 2 2 2 |
|---|
| 1098 | %% + r1~ + x2 + y2 |
|---|
| 1099 | r1 dup mul add |
|---|
| 1100 | x2 dup mul add |
|---|
| 1101 | y2 dup mul add |
|---|
| 1102 | %% |
|---|
| 1103 | %% 2 |
|---|
| 1104 | %% - r2~ )/x2} |
|---|
| 1105 | r2 dup mul sub |
|---|
| 1106 | |
|---|
| 1107 | 2 x2 mul div |
|---|
| 1108 | def |
|---|
| 1109 | |
|---|
| 1110 | /X1 |
|---|
| 1111 | %% x = 1/2 (-2 y2 Y |
|---|
| 1112 | -2 y2 mul Y1 mul |
|---|
| 1113 | %% |
|---|
| 1114 | %% 2 2 2 |
|---|
| 1115 | %% + r1~ + x2 + y2 |
|---|
| 1116 | r1 dup mul add |
|---|
| 1117 | x2 dup mul add |
|---|
| 1118 | y2 dup mul add |
|---|
| 1119 | %% |
|---|
| 1120 | %% 2 |
|---|
| 1121 | %% - r2~ )/x2} |
|---|
| 1122 | r2 dup mul sub |
|---|
| 1123 | |
|---|
| 1124 | 2 x2 mul div |
|---|
| 1125 | def |
|---|
| 1126 | |
|---|
| 1127 | %% on depose le resultat, en n'oubliant pas de retranslater en sens |
|---|
| 1128 | %% inverse |
|---|
| 1129 | |
|---|
| 1130 | X0 Y0 x1 y1 addv |
|---|
| 1131 | X1 Y1 x1 y1 addv |
|---|
| 1132 | ordonnepoints |
|---|
| 1133 | end |
|---|
| 1134 | } def |
|---|
| 1135 | |
|---|
| 1136 | %%%%% ### ABcercle ### |
|---|
| 1137 | %% syntaxe : A B C ABcercle --> le cercle passant par A, B, C |
|---|
| 1138 | /ABcercle { |
|---|
| 1139 | 3 dict begin |
|---|
| 1140 | /@3 defpoint |
|---|
| 1141 | /@2 defpoint |
|---|
| 1142 | /@1 defpoint |
|---|
| 1143 | @1 @2 mediatrice |
|---|
| 1144 | @1 @3 mediatrice |
|---|
| 1145 | interdroite |
|---|
| 1146 | dupp |
|---|
| 1147 | @3 distance |
|---|
| 1148 | end |
|---|
| 1149 | } def |
|---|
| 1150 | |
|---|
| 1151 | %%%%% ### diamcercle ### |
|---|
| 1152 | %% syntaxe : A B diamcercle --> le cercle de diametre [AB] |
|---|
| 1153 | /diamcercle { |
|---|
| 1154 | 4 copy |
|---|
| 1155 | distance 2 div |
|---|
| 1156 | 5 1 roll |
|---|
| 1157 | milieu |
|---|
| 1158 | 3 -1 roll |
|---|
| 1159 | } def |
|---|
| 1160 | |
|---|
| 1161 | %%%%% ### fin insertion ### |
|---|
| 1162 | |
|---|
| 1163 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1164 | %%%% droites %%%% |
|---|
| 1165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1166 | |
|---|
| 1167 | %%%%% ### horizontale ### |
|---|
| 1168 | %% syntaxe : y horizontale |
|---|
| 1169 | /horizontale { |
|---|
| 1170 | 1 dict begin |
|---|
| 1171 | /y exch def |
|---|
| 1172 | xmin y xmax y |
|---|
| 1173 | end |
|---|
| 1174 | } def |
|---|
| 1175 | |
|---|
| 1176 | %%%%% ### coeffdir ### |
|---|
| 1177 | %% syntaxe~: A B coeffdir |
|---|
| 1178 | /coeffdir { |
|---|
| 1179 | vecteur exch div |
|---|
| 1180 | } def |
|---|
| 1181 | |
|---|
| 1182 | %%%%% ### ordorig ### |
|---|
| 1183 | %% syntaxe : A B ordorig |
|---|
| 1184 | %% attention, la droite est supposee ne pas etre verticale |
|---|
| 1185 | /ordorig { |
|---|
| 1186 | /dr@ite 4 array def |
|---|
| 1187 | dr@ite 3 3 -1 roll put |
|---|
| 1188 | dr@ite 2 3 -1 roll put |
|---|
| 1189 | dr@ite 1 3 -1 roll put |
|---|
| 1190 | dr@ite 0 3 -1 roll put |
|---|
| 1191 | dr@ite aload pop coeffdir /c@eff exch def |
|---|
| 1192 | dr@ite aload pop pop pop %% xA yA |
|---|
| 1193 | exch %% yA xA |
|---|
| 1194 | c@eff mul neg add |
|---|
| 1195 | } def |
|---|
| 1196 | |
|---|
| 1197 | %%%%% ### verticale ### |
|---|
| 1198 | %% syntaxe~: A B verticale? |
|---|
| 1199 | /verticale? { |
|---|
| 1200 | pop 2 1 roll pop |
|---|
| 1201 | eq |
|---|
| 1202 | } def |
|---|
| 1203 | |
|---|
| 1204 | %% syntaxe : x verticale |
|---|
| 1205 | /verticale { |
|---|
| 1206 | 1 dict begin |
|---|
| 1207 | /x exch def |
|---|
| 1208 | x ymin x ymax |
|---|
| 1209 | end |
|---|
| 1210 | } def |
|---|
| 1211 | |
|---|
| 1212 | %%%%% ### droite ### |
|---|
| 1213 | %% %% syntaxe : A B droite |
|---|
| 1214 | %% /droite { |
|---|
| 1215 | %% gsave |
|---|
| 1216 | %% 6 dict begin |
|---|
| 1217 | %% /yB exch def |
|---|
| 1218 | %% /xB exch def |
|---|
| 1219 | %% /yA exch def |
|---|
| 1220 | %% /xA exch def |
|---|
| 1221 | %% xA yA xB yB |
|---|
| 1222 | %% eqp |
|---|
| 1223 | %% {} |
|---|
| 1224 | %% { |
|---|
| 1225 | %% xA yA xB yB |
|---|
| 1226 | %% verticale? |
|---|
| 1227 | %% { |
|---|
| 1228 | %% newpath |
|---|
| 1229 | %% xA ymin smoveto |
|---|
| 1230 | %% xA ymax slineto |
|---|
| 1231 | %% stockcurrentcpath |
|---|
| 1232 | %% stroke |
|---|
| 1233 | %% } |
|---|
| 1234 | %% { |
|---|
| 1235 | %% newpath |
|---|
| 1236 | %% /alpha xA yA xB yB coeffdir def |
|---|
| 1237 | %% /beta xA yA xB yB ordorig def |
|---|
| 1238 | %% xmin dup alpha mul beta add smoveto |
|---|
| 1239 | %% xmax dup alpha mul beta add slineto |
|---|
| 1240 | %% stockcurrentcpath |
|---|
| 1241 | %% stroke |
|---|
| 1242 | %% } |
|---|
| 1243 | %% ifelse |
|---|
| 1244 | %% } |
|---|
| 1245 | %% ifelse |
|---|
| 1246 | %% end |
|---|
| 1247 | %% grestore |
|---|
| 1248 | %% } def |
|---|
| 1249 | |
|---|
| 1250 | %% syntaxe : A B droite |
|---|
| 1251 | /droite { |
|---|
| 1252 | gsave |
|---|
| 1253 | 6 dict begin |
|---|
| 1254 | /B defpoint |
|---|
| 1255 | /A defpoint |
|---|
| 1256 | A pop B pop eq { |
|---|
| 1257 | %% droite verticale |
|---|
| 1258 | newpath |
|---|
| 1259 | A pop ymin smoveto |
|---|
| 1260 | A pop ymax slineto |
|---|
| 1261 | stockcurrentcpath |
|---|
| 1262 | Stroke |
|---|
| 1263 | } { |
|---|
| 1264 | %% on cherche le point le + a gauche |
|---|
| 1265 | xmin A B xdpoint /C defpoint |
|---|
| 1266 | C exch pop ymin lt { |
|---|
| 1267 | %% trop a gauche |
|---|
| 1268 | ymin A B ydpoint /C defpoint |
|---|
| 1269 | } if |
|---|
| 1270 | C exch pop ymax gt { |
|---|
| 1271 | %% trop a gauche |
|---|
| 1272 | ymax A B ydpoint /C defpoint |
|---|
| 1273 | } if |
|---|
| 1274 | %% on cherche le point le + a droite |
|---|
| 1275 | xmax A B xdpoint /D defpoint |
|---|
| 1276 | D exch pop ymin lt { |
|---|
| 1277 | %% trop a droite |
|---|
| 1278 | ymin A B ydpoint /D defpoint |
|---|
| 1279 | } if |
|---|
| 1280 | D exch pop ymax gt { |
|---|
| 1281 | %% trop a gauche |
|---|
| 1282 | ymax A B ydpoint /D defpoint |
|---|
| 1283 | } if |
|---|
| 1284 | newpath |
|---|
| 1285 | C smoveto |
|---|
| 1286 | D slineto |
|---|
| 1287 | stockcurrentcpath |
|---|
| 1288 | Stroke |
|---|
| 1289 | } ifelse |
|---|
| 1290 | end |
|---|
| 1291 | grestore |
|---|
| 1292 | } def |
|---|
| 1293 | |
|---|
| 1294 | %%%%% ### defdroite ### |
|---|
| 1295 | %% syntaxe : A B /d defdroite |
|---|
| 1296 | /defdroite { |
|---|
| 1297 | 1 dict begin |
|---|
| 1298 | /t@mp@r@ire exch def |
|---|
| 1299 | [ 5 1 roll ] cvx t@mp@r@ire exch |
|---|
| 1300 | end def |
|---|
| 1301 | } def |
|---|
| 1302 | |
|---|
| 1303 | %%%%% ### paral ### |
|---|
| 1304 | %% syntaxe : D A paral --> droite parallele a D passant par A |
|---|
| 1305 | /paral { |
|---|
| 1306 | 4 dict begin |
|---|
| 1307 | /yA exch def |
|---|
| 1308 | /xA exch def |
|---|
| 1309 | vecteur |
|---|
| 1310 | /u2 exch def |
|---|
| 1311 | /u1 exch def |
|---|
| 1312 | xA yA |
|---|
| 1313 | 2 copy |
|---|
| 1314 | u1 u2 translatepoint |
|---|
| 1315 | end |
|---|
| 1316 | } def |
|---|
| 1317 | |
|---|
| 1318 | %%%%% ### interdroite ### |
|---|
| 1319 | /interdroite { |
|---|
| 1320 | %% A B C D |
|---|
| 1321 | /dr@ite2 4 array def |
|---|
| 1322 | dr@ite2 3 3 -1 roll put |
|---|
| 1323 | dr@ite2 2 3 -1 roll put |
|---|
| 1324 | dr@ite2 1 3 -1 roll put |
|---|
| 1325 | dr@ite2 0 3 -1 roll put |
|---|
| 1326 | /dr@ite1 4 array def |
|---|
| 1327 | dr@ite1 3 3 -1 roll put |
|---|
| 1328 | dr@ite1 2 3 -1 roll put |
|---|
| 1329 | dr@ite1 1 3 -1 roll put |
|---|
| 1330 | dr@ite1 0 3 -1 roll put |
|---|
| 1331 | |
|---|
| 1332 | %%% %% trace pour deboguage |
|---|
| 1333 | %%% dr@ite1 aload pop droite |
|---|
| 1334 | %%% dr@ite2 aload pop droite |
|---|
| 1335 | |
|---|
| 1336 | %%% Dans tous les cas, on suppose que l'intersection existe |
|---|
| 1337 | %%% |
|---|
| 1338 | %%% * la 1ere droite est verticale. les equations reduites sont |
|---|
| 1339 | %%% x = a1 et y = a2 x + b2 |
|---|
| 1340 | %%% Le point d'intersection est : |
|---|
| 1341 | %%% {{x = a1, y = b2 + a1 a2}} |
|---|
| 1342 | %%% |
|---|
| 1343 | %%% * la 2eme droite est verticale. les equations reduites sont |
|---|
| 1344 | %%% x = a1 x+ b1 et x = a2 |
|---|
| 1345 | %%% Le point d'intersection est : |
|---|
| 1346 | %%% {{x = a2, y = b1 + a1 a2}} |
|---|
| 1347 | %%% |
|---|
| 1348 | %%% * aucune n'est verticale. Les equations reduites sont |
|---|
| 1349 | %%% y = a1 x + b1 et y = a2 x + b2 |
|---|
| 1350 | %%% Le point d'intersection est : |
|---|
| 1351 | %%% { { b2 - b1 a1 b2 - a2 b1 } } |
|---|
| 1352 | %%% { { x = -------, y = ------------- } } |
|---|
| 1353 | %%% { { a1 - a2 a1 - a2 } } |
|---|
| 1354 | |
|---|
| 1355 | %%% remarque : pour le moment, je n'arrive pas a rendre mes variables |
|---|
| 1356 | %%% locales : elle restent globales. Pour que cela ne soit pas trop |
|---|
| 1357 | %%% genant, je les note respectivement @1, @@1, @2 et @@2 au lieu de a1, |
|---|
| 1358 | %%% b1, a2 et b2. |
|---|
| 1359 | |
|---|
| 1360 | dr@ite1 aload pop verticale? |
|---|
| 1361 | { |
|---|
| 1362 | /@1 {dr@ite1 aload pop pop pop pop} def |
|---|
| 1363 | /@2 {dr@ite2 aload pop coeffdir} def |
|---|
| 1364 | /@@2 {dr@ite2 aload pop ordorig} def |
|---|
| 1365 | @1 |
|---|
| 1366 | @1 @2 mul @@2 add |
|---|
| 1367 | } |
|---|
| 1368 | { |
|---|
| 1369 | dr@ite2 aload pop verticale? |
|---|
| 1370 | { |
|---|
| 1371 | /@1 {dr@ite1 aload pop coeffdir} def |
|---|
| 1372 | /@@1 {dr@ite1 aload pop ordorig} def |
|---|
| 1373 | /@2 {dr@ite2 aload pop pop pop pop} def |
|---|
| 1374 | @2 |
|---|
| 1375 | @1 @2 mul @@1 add |
|---|
| 1376 | } |
|---|
| 1377 | { |
|---|
| 1378 | /@1 {dr@ite1 aload pop coeffdir} def |
|---|
| 1379 | /@@1 {dr@ite1 aload pop ordorig} def |
|---|
| 1380 | /@2 {dr@ite2 aload pop coeffdir} def |
|---|
| 1381 | /@@2 {dr@ite2 aload pop ordorig} def |
|---|
| 1382 | @@2 @@1 sub @1 @2 sub div |
|---|
| 1383 | @1 @@2 mul @2 @@1 mul sub |
|---|
| 1384 | @1 @2 sub div |
|---|
| 1385 | } |
|---|
| 1386 | ifelse |
|---|
| 1387 | } |
|---|
| 1388 | ifelse |
|---|
| 1389 | } def |
|---|
| 1390 | |
|---|
| 1391 | %%%%% ### perp ### |
|---|
| 1392 | %% syntaxe : D A perp --> droite perpendiculaire a D passant par A |
|---|
| 1393 | /perp { |
|---|
| 1394 | 4 dict begin |
|---|
| 1395 | /yA exch def |
|---|
| 1396 | /xA exch def |
|---|
| 1397 | vecteur orthovecteur |
|---|
| 1398 | /u2 exch def |
|---|
| 1399 | /u1 exch def |
|---|
| 1400 | xA yA |
|---|
| 1401 | 2 copy |
|---|
| 1402 | u1 u2 translatepoint |
|---|
| 1403 | end |
|---|
| 1404 | } def |
|---|
| 1405 | |
|---|
| 1406 | %%%%% ### mediatrice ### |
|---|
| 1407 | %% synaxe : A B mediatrice --> droite |
|---|
| 1408 | /mediatrice { |
|---|
| 1409 | 4 copy |
|---|
| 1410 | milieu |
|---|
| 1411 | perp |
|---|
| 1412 | } def |
|---|
| 1413 | |
|---|
| 1414 | %%%%% ### bissectrice ### |
|---|
| 1415 | %% syntaxe : A B C bissectrice --> B E ou E est un point de la bissectrice |
|---|
| 1416 | /bissectrice { |
|---|
| 1417 | 10 dict begin |
|---|
| 1418 | /yC exch def |
|---|
| 1419 | /xC exch def |
|---|
| 1420 | /yB exch def |
|---|
| 1421 | /xB exch def |
|---|
| 1422 | /yA exch def |
|---|
| 1423 | /xA exch def |
|---|
| 1424 | /A {xA yA} def |
|---|
| 1425 | /B {xB yB} def |
|---|
| 1426 | /C {xC yC} def |
|---|
| 1427 | /alpha {A B C tripointangle} def |
|---|
| 1428 | B |
|---|
| 1429 | A B alpha rotatepoint |
|---|
| 1430 | A milieu |
|---|
| 1431 | end |
|---|
| 1432 | } def |
|---|
| 1433 | |
|---|
| 1434 | %%%%% ### angledroit ### |
|---|
| 1435 | /widthangledroit 5 def |
|---|
| 1436 | |
|---|
| 1437 | %% syntaxe : A B C angledroit --> dessine un angle droit en B |
|---|
| 1438 | /angledroit { |
|---|
| 1439 | 10 dict begin |
|---|
| 1440 | dup xcheck { |
|---|
| 1441 | /widthangledroit exch def |
|---|
| 1442 | } if |
|---|
| 1443 | /C defpoint |
|---|
| 1444 | /B defpoint |
|---|
| 1445 | /A defpoint |
|---|
| 1446 | B C vecteur normalize widthangledroit 20 div mulv /u defpoint |
|---|
| 1447 | B A vecteur normalize widthangledroit 20 div mulv /v defpoint |
|---|
| 1448 | [B u addv dupp v addv B v addv] ligne |
|---|
| 1449 | end |
|---|
| 1450 | } def |
|---|
| 1451 | |
|---|
| 1452 | %%%%% ### translatedroite ### |
|---|
| 1453 | %% syntaxe : A B u translatedroite --> C D images resp de A et B par la translation de vecteur u |
|---|
| 1454 | /translatedroite { %% A B u |
|---|
| 1455 | 2 copy %% A B u u |
|---|
| 1456 | 6 1 roll |
|---|
| 1457 | 6 1 roll %% A u B u |
|---|
| 1458 | addv %% A u D |
|---|
| 1459 | 6 1 roll |
|---|
| 1460 | 6 1 roll %% D A u |
|---|
| 1461 | addv |
|---|
| 1462 | 4 1 roll |
|---|
| 1463 | 4 1 roll |
|---|
| 1464 | } def |
|---|
| 1465 | |
|---|
| 1466 | %%%%% ### rotatedroite ### |
|---|
| 1467 | %% syntaxe : A B O r rotatedroite --> C D images resp de A et B par la |
|---|
| 1468 | %% rotation de centre O et d'angle r (en degre) |
|---|
| 1469 | /rotatedroite { |
|---|
| 1470 | 5 copy rotatepoint %% A B O r D |
|---|
| 1471 | 6 -1 roll pop %% A xB O r D |
|---|
| 1472 | 6 -1 roll pop %% A O r D |
|---|
| 1473 | 7 1 roll |
|---|
| 1474 | 7 1 roll rotatepoint %% D C |
|---|
| 1475 | 4 1 roll 4 1 roll |
|---|
| 1476 | } def |
|---|
| 1477 | |
|---|
| 1478 | /rotatevecteur { |
|---|
| 1479 | rotatedroite |
|---|
| 1480 | } def |
|---|
| 1481 | |
|---|
| 1482 | /rotatesegment { |
|---|
| 1483 | rotatedroite |
|---|
| 1484 | } def |
|---|
| 1485 | |
|---|
| 1486 | %%%%% ### axesymdroite ### |
|---|
| 1487 | %% syntaxe : d D axesymdroite --> droite d', symetrique de la droite d par rapport |
|---|
| 1488 | %% a la droite D |
|---|
| 1489 | /axesymdroite { |
|---|
| 1490 | 2 dict begin |
|---|
| 1491 | /D defdroite |
|---|
| 1492 | /B defpoint |
|---|
| 1493 | D axesympoint |
|---|
| 1494 | B D axesympoint |
|---|
| 1495 | end |
|---|
| 1496 | } def |
|---|
| 1497 | |
|---|
| 1498 | %%%%% ### fin insertion ### |
|---|
| 1499 | |
|---|
| 1500 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1501 | %%%% polygones %%%% |
|---|
| 1502 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1503 | |
|---|
| 1504 | %%%%% ### poltransformfile ### |
|---|
| 1505 | %% syntaxe : pol u translatepol --> pol' |
|---|
| 1506 | /translatepol { |
|---|
| 1507 | 2 dict begin |
|---|
| 1508 | /uy exch def |
|---|
| 1509 | /ux exch def |
|---|
| 1510 | {ux uy translatepoint} papply |
|---|
| 1511 | end |
|---|
| 1512 | } def |
|---|
| 1513 | |
|---|
| 1514 | %% syntaxe : pol u rotatepol --> pol' |
|---|
| 1515 | /rotatepol { |
|---|
| 1516 | 2 dict begin |
|---|
| 1517 | /alpha exch def |
|---|
| 1518 | /I defpoint |
|---|
| 1519 | {I alpha rotatepoint} papply |
|---|
| 1520 | end |
|---|
| 1521 | } def |
|---|
| 1522 | |
|---|
| 1523 | %% syntaxe : pol I alpha hompol --> pol' |
|---|
| 1524 | /hompol { |
|---|
| 1525 | 2 dict begin |
|---|
| 1526 | /alpha exch def |
|---|
| 1527 | /I defpoint |
|---|
| 1528 | {I alpha hompoint} papply |
|---|
| 1529 | end |
|---|
| 1530 | } def |
|---|
| 1531 | |
|---|
| 1532 | %% syntaxe : pol I sympol --> pol' |
|---|
| 1533 | /sympol { |
|---|
| 1534 | 1 dict begin |
|---|
| 1535 | /I defpoint |
|---|
| 1536 | {I sympoint} papply |
|---|
| 1537 | end |
|---|
| 1538 | } def |
|---|
| 1539 | |
|---|
| 1540 | %% syntaxe : pol D axesympol --> pol' |
|---|
| 1541 | /axesympol { |
|---|
| 1542 | 1 dict begin |
|---|
| 1543 | /D defdroite |
|---|
| 1544 | {D axesympoint} papply |
|---|
| 1545 | end |
|---|
| 1546 | } def |
|---|
| 1547 | |
|---|
| 1548 | %%%%% ### fin insertion ### |
|---|
| 1549 | |
|---|
| 1550 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1551 | %%%% les tests %%%% |
|---|
| 1552 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1553 | |
|---|
| 1554 | %%%%% ### isbool ### |
|---|
| 1555 | %% syntaxe : any isbool --> booleen |
|---|
| 1556 | /isbool { |
|---|
| 1557 | type (booleantype) cvn eq |
|---|
| 1558 | } def |
|---|
| 1559 | |
|---|
| 1560 | %%%%% ### isarray ### |
|---|
| 1561 | %% syntaxe : any isarray --> booleen |
|---|
| 1562 | /isarray { |
|---|
| 1563 | type (arraytype) cvn eq |
|---|
| 1564 | } def |
|---|
| 1565 | |
|---|
| 1566 | %%%%% ### isstring ### |
|---|
| 1567 | %% syntaxe : any isstring --> booleen |
|---|
| 1568 | /isstring { |
|---|
| 1569 | type (stringtype) cvn eq |
|---|
| 1570 | } def |
|---|
| 1571 | |
|---|
| 1572 | %%%%% ### isinteger ### |
|---|
| 1573 | %% syntaxe : any isinteger --> booleen |
|---|
| 1574 | /isinteger { |
|---|
| 1575 | type (integertype) cvn eq |
|---|
| 1576 | } def |
|---|
| 1577 | |
|---|
| 1578 | %%%%% ### isnum ### |
|---|
| 1579 | %% syntaxe : any isnum --> booleen |
|---|
| 1580 | /isnum { |
|---|
| 1581 | dup isreal |
|---|
| 1582 | exch isinteger or |
|---|
| 1583 | } def |
|---|
| 1584 | |
|---|
| 1585 | %%%%% ### isreal ### |
|---|
| 1586 | %% syntaxe : any isreal --> booleen |
|---|
| 1587 | /isreal { |
|---|
| 1588 | type (realtype) cvn eq |
|---|
| 1589 | } def |
|---|
| 1590 | |
|---|
| 1591 | %%%%% ### eq ### |
|---|
| 1592 | %% syntaxe : A B eqp3d --> booleen = true si les points A et B sont identiques |
|---|
| 1593 | /eqp3d { |
|---|
| 1594 | %% x1 y1 z1 x2 y2 z2 |
|---|
| 1595 | 4 -1 roll %% x1 y1 x2 y2 z2 z1 |
|---|
| 1596 | eq { %% x1 y1 x2 y2 |
|---|
| 1597 | eqp |
|---|
| 1598 | } { |
|---|
| 1599 | pop pop pop pop false |
|---|
| 1600 | } ifelse |
|---|
| 1601 | } def |
|---|
| 1602 | |
|---|
| 1603 | %% syntaxe : A B eqp --> booleen = true si les points A et B sont identiques |
|---|
| 1604 | /eqp { |
|---|
| 1605 | 3 -1 roll |
|---|
| 1606 | eq |
|---|
| 1607 | { |
|---|
| 1608 | eq |
|---|
| 1609 | {true} |
|---|
| 1610 | {false} |
|---|
| 1611 | ifelse |
|---|
| 1612 | } |
|---|
| 1613 | {pop pop false} |
|---|
| 1614 | ifelse |
|---|
| 1615 | } def |
|---|
| 1616 | |
|---|
| 1617 | %% syntaxe : z z' eqc --> true si z = z', false sinon |
|---|
| 1618 | /eqc { |
|---|
| 1619 | eqp |
|---|
| 1620 | } def |
|---|
| 1621 | |
|---|
| 1622 | %%%%% ### eqstring ### |
|---|
| 1623 | /eqstring { |
|---|
| 1624 | 3 dict begin |
|---|
| 1625 | /str2 exch def |
|---|
| 1626 | /str1 exch def |
|---|
| 1627 | str1 length str2 length eq { |
|---|
| 1628 | /i 0 def |
|---|
| 1629 | true |
|---|
| 1630 | str1 length { |
|---|
| 1631 | str1 i get str2 i get eq and |
|---|
| 1632 | /i i 1 add store |
|---|
| 1633 | } repeat |
|---|
| 1634 | } { |
|---|
| 1635 | false |
|---|
| 1636 | } ifelse |
|---|
| 1637 | end |
|---|
| 1638 | } def |
|---|
| 1639 | |
|---|
| 1640 | %%%%% ### fin insertion ### |
|---|
| 1641 | |
|---|
| 1642 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1643 | %%%% conversions de types %%%% |
|---|
| 1644 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1645 | |
|---|
| 1646 | %%%%% ### astr2str ### |
|---|
| 1647 | %% syntaxe : array str astr2str --> str |
|---|
| 1648 | %% convertit le contenu de array en chaines de caracteres puis les |
|---|
| 1649 | %% concatene avec str, en inserant un caractere "space" apres chaque |
|---|
| 1650 | %% element du tableau array |
|---|
| 1651 | /astr2str { |
|---|
| 1652 | 5 dict begin |
|---|
| 1653 | /str exch def |
|---|
| 1654 | /table exch def |
|---|
| 1655 | /n table length def |
|---|
| 1656 | n 0 eq { |
|---|
| 1657 | str |
|---|
| 1658 | } { |
|---|
| 1659 | table 0 n 1 sub getinterval |
|---|
| 1660 | table n 1 sub get ( ) cvs |
|---|
| 1661 | ( ) append |
|---|
| 1662 | str append |
|---|
| 1663 | astr2str |
|---|
| 1664 | } ifelse |
|---|
| 1665 | end |
|---|
| 1666 | } def |
|---|
| 1667 | |
|---|
| 1668 | %%%%% ### numstr2array ### |
|---|
| 1669 | %% syntaxe : str str2num --> num |
|---|
| 1670 | /str2num { |
|---|
| 1671 | 5 dict begin |
|---|
| 1672 | /str exch def |
|---|
| 1673 | /n str length def |
|---|
| 1674 | /signnum 1 def |
|---|
| 1675 | /frct false def |
|---|
| 1676 | /k 0 def |
|---|
| 1677 | 0 1 n 1 sub { |
|---|
| 1678 | /i exch def |
|---|
| 1679 | str i get |
|---|
| 1680 | dup 46 eq { |
|---|
| 1681 | %% il y a un point |
|---|
| 1682 | /frct true def |
|---|
| 1683 | pop |
|---|
| 1684 | i 0 eq { |
|---|
| 1685 | 0 |
|---|
| 1686 | } if |
|---|
| 1687 | } { |
|---|
| 1688 | dup 45 eq { |
|---|
| 1689 | /signnum -1 def |
|---|
| 1690 | pop |
|---|
| 1691 | } { |
|---|
| 1692 | frct not { |
|---|
| 1693 | i 1 ge signnum 0 ge and i 2 ge or { |
|---|
| 1694 | exch 10 mul 48 sub add |
|---|
| 1695 | } { |
|---|
| 1696 | 48 sub |
|---|
| 1697 | } ifelse |
|---|
| 1698 | } { |
|---|
| 1699 | 48 sub |
|---|
| 1700 | /k k 1 add store |
|---|
| 1701 | 10 k exp div add |
|---|
| 1702 | } ifelse |
|---|
| 1703 | } ifelse |
|---|
| 1704 | } ifelse |
|---|
| 1705 | } for |
|---|
| 1706 | signnum mul |
|---|
| 1707 | end |
|---|
| 1708 | } def |
|---|
| 1709 | |
|---|
| 1710 | /str2num {cvx exec} def |
|---|
| 1711 | |
|---|
| 1712 | %% syntaxe : str numstr2array -> array |
|---|
| 1713 | %% ou str est une chaine de nombres reels separes par des espaces |
|---|
| 1714 | %% et array est constitue des elements numeriques de string. |
|---|
| 1715 | %% exemple : |
|---|
| 1716 | %% (0 -12 .234 54) --> [0 -12 0.234 54] |
|---|
| 1717 | /numstr2array { |
|---|
| 1718 | 6 dict begin |
|---|
| 1719 | /str exch def |
|---|
| 1720 | /n str length def |
|---|
| 1721 | /separateurs [] def |
|---|
| 1722 | [ |
|---|
| 1723 | 0 1 n 1 sub { |
|---|
| 1724 | /i exch def |
|---|
| 1725 | str i get |
|---|
| 1726 | 32 eq { |
|---|
| 1727 | /separateurs [separateurs aload pop i] def |
|---|
| 1728 | } if |
|---|
| 1729 | } for |
|---|
| 1730 | /j 0 def |
|---|
| 1731 | /oldsep 0 def |
|---|
| 1732 | 0 1 separateurs length 1 sub { |
|---|
| 1733 | /i exch def |
|---|
| 1734 | str j separateurs i get oldsep sub getinterval str2num |
|---|
| 1735 | /j separateurs i get 1 add def |
|---|
| 1736 | /oldsep separateurs i get 1 add def |
|---|
| 1737 | } for |
|---|
| 1738 | str j n oldsep sub getinterval str2num |
|---|
| 1739 | ] |
|---|
| 1740 | end |
|---|
| 1741 | } def |
|---|
| 1742 | |
|---|
| 1743 | %% syntaxe : array numstr2array -> array |
|---|
| 1744 | /arraynumstr2arrayarray { |
|---|
| 1745 | {numstr2array} apply |
|---|
| 1746 | } def |
|---|
| 1747 | |
|---|
| 1748 | %%%%% ### fin insertion ### |
|---|
| 1749 | |
|---|
| 1750 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1751 | %%%% macros de projection %%%% |
|---|
| 1752 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 1753 | |
|---|
| 1754 | %%%%% ### projtext ### |
|---|
| 1755 | %% syntaxe : str x0 y0 z0 [normal_vect] ultextp3d --> - |
|---|
| 1756 | %% syntaxe : str x0 y0 z0 [normal_vect] bool ultextp3d --> - |
|---|
| 1757 | %% syntaxe : str x0 y0 plantype ultextp3d --> - |
|---|
| 1758 | %% syntaxe : str x0 y0 plantype bool ultextp3d --> - |
|---|
| 1759 | %% syntaxe : str1 solid i str2 ultextp3d --> - |
|---|
| 1760 | %% syntaxe : str1 solid i str2 bool ultextp3d --> - |
|---|
| 1761 | %% syntaxe : str1 solid i alpha str2 bool ultextp3d --> - |
|---|
| 1762 | /initpr@jtext { |
|---|
| 1763 | 5 dict begin |
|---|
| 1764 | dup isbool { |
|---|
| 1765 | /mybool exch def |
|---|
| 1766 | } { |
|---|
| 1767 | /mybool true def |
|---|
| 1768 | } ifelse |
|---|
| 1769 | dup isplan { |
|---|
| 1770 | /type_plan_proj true def |
|---|
| 1771 | /lepl@n exch def |
|---|
| 1772 | lepl@n plangetbase aload pop |
|---|
| 1773 | /@V defpoint3d |
|---|
| 1774 | /@U defpoint3d |
|---|
| 1775 | lepl@n plangetorigine |
|---|
| 1776 | /z0 exch def |
|---|
| 1777 | /y0 exch def |
|---|
| 1778 | /x0 exch def |
|---|
| 1779 | /table [@U @U @V vectprod3d] def |
|---|
| 1780 | } { |
|---|
| 1781 | dup isarray { |
|---|
| 1782 | %% c est un planprojpath |
|---|
| 1783 | /type_plan_proj true def |
|---|
| 1784 | /table exch def |
|---|
| 1785 | /z0 exch def |
|---|
| 1786 | /y0 exch def |
|---|
| 1787 | /x0 exch def |
|---|
| 1788 | 0 0 |
|---|
| 1789 | } { |
|---|
| 1790 | %% c est un solidprojpath |
|---|
| 1791 | /type_plan_proj false def |
|---|
| 1792 | %% y a-t-il un str2 |
|---|
| 1793 | dup isstring { |
|---|
| 1794 | /str2 exch def |
|---|
| 1795 | } { |
|---|
| 1796 | /str2 {} def |
|---|
| 1797 | } ifelse |
|---|
| 1798 | %% y a-t-il un alpha |
|---|
| 1799 | 2 copy pop issolid { |
|---|
| 1800 | /alpha 0 def |
|---|
| 1801 | } { |
|---|
| 1802 | /alpha exch def |
|---|
| 1803 | } ifelse |
|---|
| 1804 | /i exch def |
|---|
| 1805 | /solid exch def |
|---|
| 1806 | 0 0 |
|---|
| 1807 | } ifelse |
|---|
| 1808 | } ifelse |
|---|
| 1809 | } def |
|---|
| 1810 | /closepr@jtext { |
|---|
| 1811 | type_plan_proj { |
|---|
| 1812 | x0 y0 z0 table mybool projpath |
|---|
| 1813 | } { |
|---|
| 1814 | solid i alpha str2 mybool projpath |
|---|
| 1815 | } ifelse |
|---|
| 1816 | Fill |
|---|
| 1817 | Stroke |
|---|
| 1818 | end |
|---|
| 1819 | } def |
|---|
| 1820 | |
|---|
| 1821 | %% syntaxe : str x0 y0 z0 [normal_vect] ultextp3d --> - |
|---|
| 1822 | %% syntaxe : str x0 y0 z0 [normal_vect] bool ultextp3d --> - |
|---|
| 1823 | %% syntaxe : str1 solid i str2 ultextp3d --> - |
|---|
| 1824 | %% syntaxe : str1 solid i str2 bool ultextp3d --> - |
|---|
| 1825 | %% syntaxe : str1 solid i alpha str2 bool ultextp3d --> - |
|---|
| 1826 | /ultextp3d {initpr@jtext ultext_ closepr@jtext} def |
|---|
| 1827 | /cltextp3d {initpr@jtext cltext_ closepr@jtext} def |
|---|
| 1828 | /bltextp3d {initpr@jtext bltext_ closepr@jtext} def |
|---|
| 1829 | /dltextp3d {initpr@jtext dltext_ closepr@jtext} def |
|---|
| 1830 | /ubtextp3d {initpr@jtext ubtext_ closepr@jtext} def |
|---|
| 1831 | /cbtextp3d {initpr@jtext cbtext_ closepr@jtext} def |
|---|
| 1832 | /bbtextp3d {initpr@jtext bbtext_ closepr@jtext} def |
|---|
| 1833 | /dbtextp3d {initpr@jtext dbtext_ closepr@jtext} def |
|---|
| 1834 | /uctextp3d {initpr@jtext uctext_ closepr@jtext} def |
|---|
| 1835 | /cctextp3d {initpr@jtext cctext_ closepr@jtext} def |
|---|
| 1836 | /bctextp3d {initpr@jtext bctext_ closepr@jtext} def |
|---|
| 1837 | /dctextp3d {initpr@jtext dctext_ closepr@jtext} def |
|---|
| 1838 | /urtextp3d {initpr@jtext urtext_ closepr@jtext} def |
|---|
| 1839 | /crtextp3d {initpr@jtext crtext_ closepr@jtext} def |
|---|
| 1840 | /brtextp3d {initpr@jtext brtext_ closepr@jtext} def |
|---|
| 1841 | /drtextp3d {initpr@jtext drtext_ closepr@jtext} def |
|---|
| 1842 | |
|---|
| 1843 | %%%%% ### currentppathtransform ### |
|---|
| 1844 | %% syntaxe : {f} currentppathtransform --> applique la transformation f |
|---|
| 1845 | %% au chemin courant |
|---|
| 1846 | /currentppathtransform { |
|---|
| 1847 | 6 dict begin |
|---|
| 1848 | /warp exch def |
|---|
| 1849 | %% pour remplacer 'move' |
|---|
| 1850 | /warpmove{ |
|---|
| 1851 | 2 index { |
|---|
| 1852 | newpath |
|---|
| 1853 | } if |
|---|
| 1854 | warp moveto |
|---|
| 1855 | pop false |
|---|
| 1856 | } def |
|---|
| 1857 | |
|---|
| 1858 | %% pour remplacer 'lineto' |
|---|
| 1859 | /warpline { |
|---|
| 1860 | warp lineto |
|---|
| 1861 | } bind def |
|---|
| 1862 | |
|---|
| 1863 | %% pour remplacer 'curveto' |
|---|
| 1864 | /warpcurve { |
|---|
| 1865 | 6 2 roll warp |
|---|
| 1866 | 6 2 roll warp |
|---|
| 1867 | 6 2 roll warp |
|---|
| 1868 | curveto |
|---|
| 1869 | } bind def |
|---|
| 1870 | |
|---|
| 1871 | true |
|---|
| 1872 | { warpmove } { warpline } { warpcurve } { closepath } pathforall |
|---|
| 1873 | pop |
|---|
| 1874 | end |
|---|
| 1875 | } def |
|---|
| 1876 | |
|---|
| 1877 | %% syntaxe : {f} currentpathtransform --> applique la transformation f |
|---|
| 1878 | %% au chemin courant |
|---|
| 1879 | /currentpathtransform { |
|---|
| 1880 | 7 dict begin |
|---|
| 1881 | /transform exch def |
|---|
| 1882 | /warp {ptojpoint transform} def |
|---|
| 1883 | %% pour remplacer 'move' |
|---|
| 1884 | /warpmove{ |
|---|
| 1885 | 2 index { |
|---|
| 1886 | newpath |
|---|
| 1887 | } if |
|---|
| 1888 | warp smoveto |
|---|
| 1889 | pop false |
|---|
| 1890 | } def |
|---|
| 1891 | |
|---|
| 1892 | %% pour remplacer 'lineto' |
|---|
| 1893 | /warpline { |
|---|
| 1894 | warp slineto |
|---|
| 1895 | } bind def |
|---|
| 1896 | |
|---|
| 1897 | %% pour remplacer 'curveto' |
|---|
| 1898 | /warpcurve { |
|---|
| 1899 | 6 2 roll warp |
|---|
| 1900 | 6 2 roll warp |
|---|
| 1901 | 6 2 roll warp |
|---|
| 1902 | scurveto |
|---|
| 1903 | } bind def |
|---|
| 1904 | |
|---|
| 1905 | true |
|---|
| 1906 | { warpmove } { warpline } { warpcurve } { closepath } pathforall |
|---|
| 1907 | pop |
|---|
| 1908 | end |
|---|
| 1909 | } def |
|---|
| 1910 | |
|---|
| 1911 | %%%%% ### normalvect_to_orthobase ### |
|---|
| 1912 | %% syntaxe : [normal_vect] normalvect_to_orthobase |
|---|
| 1913 | %% --> imI imJ imK |
|---|
| 1914 | /normalvect_to_orthobase { |
|---|
| 1915 | 4 dict begin |
|---|
| 1916 | dup length 3 eq { |
|---|
| 1917 | aload pop normalize3d /normal_vect defpoint3d |
|---|
| 1918 | normal_vect -1 0 0 eqp3d { |
|---|
| 1919 | /imageI {0 -1 0} def |
|---|
| 1920 | /imageK {-1 0 0} def |
|---|
| 1921 | /imageJ {0 0 1} def |
|---|
| 1922 | } { |
|---|
| 1923 | %% on calcule l image de la base (I,J,K) |
|---|
| 1924 | /imageJ {normal_vect 1 0 0 vectprod3d normalize3d} def |
|---|
| 1925 | /imageK {normal_vect} def |
|---|
| 1926 | /imageI {imageJ imageK vectprod3d} def |
|---|
| 1927 | 1 0 0 imageK angle3d 0 eq { |
|---|
| 1928 | 0 1 0 normal_vect vectprod3d /imageI defpoint3d |
|---|
| 1929 | /imageJ {0 1 0} def |
|---|
| 1930 | normal_vect /imageK defpoint3d |
|---|
| 1931 | } if |
|---|
| 1932 | } ifelse |
|---|
| 1933 | } { |
|---|
| 1934 | dup length 6 eq { |
|---|
| 1935 | aload pop |
|---|
| 1936 | normalize3d /imageK defpoint3d |
|---|
| 1937 | normalize3d /imageI defpoint3d |
|---|
| 1938 | imageK imageI vectprod3d /imageJ defpoint3d |
|---|
| 1939 | } { |
|---|
| 1940 | dup length 7 eq { |
|---|
| 1941 | aload pop |
|---|
| 1942 | /alpha exch 2 div def |
|---|
| 1943 | normalize3d /imageK defpoint3d |
|---|
| 1944 | normalize3d /imageI defpoint3d |
|---|
| 1945 | imageK imageI vectprod3d /imageJ defpoint3d |
|---|
| 1946 | %% et ensuite, on fait tourner la base autour de imageK |
|---|
| 1947 | imageI alpha cos mulv3d |
|---|
| 1948 | imageJ alpha sin mulv3d |
|---|
| 1949 | addv3d |
|---|
| 1950 | |
|---|
| 1951 | imageI alpha sin neg mulv3d |
|---|
| 1952 | imageJ alpha cos mulv3d |
|---|
| 1953 | addv3d |
|---|
| 1954 | |
|---|
| 1955 | /imageJ defpoint3d |
|---|
| 1956 | /imageI defpoint3d |
|---|
| 1957 | } { |
|---|
| 1958 | %% length = 4 |
|---|
| 1959 | aload pop |
|---|
| 1960 | /alpha exch def |
|---|
| 1961 | normalize3d /normal_vect defpoint3d |
|---|
| 1962 | |
|---|
| 1963 | normal_vect -1 0 0 eqp3d { |
|---|
| 1964 | /imageI {0 -1 0} def |
|---|
| 1965 | /imageK {-1 0 0} def |
|---|
| 1966 | /imageJ {0 0 1} def |
|---|
| 1967 | } { |
|---|
| 1968 | %% on calcule l image de la base (I,J,K) |
|---|
| 1969 | /imageJ {normal_vect 1 0 0 vectprod3d normalize3d} def |
|---|
| 1970 | /imageK {normal_vect} def |
|---|
| 1971 | /imageI {imageJ imageK vectprod3d} def |
|---|
| 1972 | 1 0 0 imageK angle3d 0 eq { |
|---|
| 1973 | 0 1 0 normal_vect vectprod3d /imageI defpoint3d |
|---|
| 1974 | /imageJ {0 1 0} def |
|---|
| 1975 | normal_vect /imageK defpoint3d |
|---|
| 1976 | } if |
|---|
| 1977 | } ifelse |
|---|
| 1978 | } ifelse |
|---|
| 1979 | |
|---|
| 1980 | %% et ensuite, on fait tourner la base autour de imageK |
|---|
| 1981 | imageI alpha cos mulv3d |
|---|
| 1982 | imageJ alpha sin mulv3d |
|---|
| 1983 | addv3d |
|---|
| 1984 | |
|---|
| 1985 | imageI alpha sin neg mulv3d |
|---|
| 1986 | imageJ alpha cos mulv3d |
|---|
| 1987 | addv3d |
|---|
| 1988 | |
|---|
| 1989 | /imageJ defpoint3d |
|---|
| 1990 | /imageI defpoint3d |
|---|
| 1991 | } ifelse |
|---|
| 1992 | } ifelse |
|---|
| 1993 | imageI |
|---|
| 1994 | imageJ |
|---|
| 1995 | imageK |
|---|
| 1996 | end |
|---|
| 1997 | } def |
|---|
| 1998 | |
|---|
| 1999 | %%%%% ### projpath ### |
|---|
| 2000 | %% syntaxe : x y z [normal] projpath --> planprojpath |
|---|
| 2001 | %% syntaxe : x y z [normal] bool projpath --> planprojpath |
|---|
| 2002 | %% syntaxe : solid i projpath --> solidprojpath |
|---|
| 2003 | %% syntaxe : solid i bool projpath --> solidprojpath |
|---|
| 2004 | %% syntaxe : solid i str bool projpath --> solidprojpath |
|---|
| 2005 | %% syntaxe : solid i alpha str bool projpath --> solidprojpath |
|---|
| 2006 | /projpath { |
|---|
| 2007 | 2 dict begin |
|---|
| 2008 | dup isbool { |
|---|
| 2009 | /mybool exch def |
|---|
| 2010 | } { |
|---|
| 2011 | /mybool true def |
|---|
| 2012 | } ifelse |
|---|
| 2013 | dup isplan { |
|---|
| 2014 | 3 dict begin |
|---|
| 2015 | /lepl@n exch def |
|---|
| 2016 | lepl@n plangetbase aload pop |
|---|
| 2017 | /@V defpoint3d |
|---|
| 2018 | /@U defpoint3d |
|---|
| 2019 | lepl@n plangetorigine |
|---|
| 2020 | [@U @U @V vectprod3d] mybool planprojpath |
|---|
| 2021 | end |
|---|
| 2022 | } { |
|---|
| 2023 | dup isarray { |
|---|
| 2024 | mybool planprojpath |
|---|
| 2025 | } { |
|---|
| 2026 | mybool solidprojpath |
|---|
| 2027 | } ifelse |
|---|
| 2028 | } ifelse |
|---|
| 2029 | end |
|---|
| 2030 | } def |
|---|
| 2031 | |
|---|
| 2032 | |
|---|
| 2033 | %% %% syntaxe : x y z [normal] projpath --> planprojpath |
|---|
| 2034 | %% %% syntaxe : x y z [normal] bool projpath --> planprojpath |
|---|
| 2035 | %% %% syntaxe : solid i projpath --> solidprojpath |
|---|
| 2036 | %% %% syntaxe : solid i bool projpath --> solidprojpath |
|---|
| 2037 | %% %% syntaxe : solid i str bool projpath --> solidprojpath |
|---|
| 2038 | %% %% syntaxe : solid i alpha str bool projpath --> solidprojpath |
|---|
| 2039 | %% /projpath { |
|---|
| 2040 | %% 2 dict begin |
|---|
| 2041 | %% dup isbool { |
|---|
| 2042 | %% /mybool exch def |
|---|
| 2043 | %% } { |
|---|
| 2044 | %% /mybool true def |
|---|
| 2045 | %% } ifelse |
|---|
| 2046 | %% dup isarray { |
|---|
| 2047 | %% mybool planprojpath |
|---|
| 2048 | %% } { |
|---|
| 2049 | %% mybool solidprojpath |
|---|
| 2050 | %% } ifelse |
|---|
| 2051 | %% end |
|---|
| 2052 | %% } def |
|---|
| 2053 | %% |
|---|
| 2054 | %% syntaxe : solid i str bool solidprojpath --> - |
|---|
| 2055 | %% ou |
|---|
| 2056 | %% syntaxe : solid i alpha str bool solidprojpath --> - |
|---|
| 2057 | %% projette le chemin courant sur la face i du solide, apres |
|---|
| 2058 | %% eventuellement une rotation d angle alpha autour de la normale |
|---|
| 2059 | %% bool : pour savoir si on tient compte de la visibilite |
|---|
| 2060 | /solidprojpath { |
|---|
| 2061 | 5 dict begin |
|---|
| 2062 | /visibility exch def |
|---|
| 2063 | dup isstring { |
|---|
| 2064 | /option exch def |
|---|
| 2065 | } if |
|---|
| 2066 | 2 copy pop |
|---|
| 2067 | issolid { |
|---|
| 2068 | /alpha 0 def |
|---|
| 2069 | } { |
|---|
| 2070 | /alpha exch def |
|---|
| 2071 | } ifelse |
|---|
| 2072 | /i exch def |
|---|
| 2073 | /solid exch def |
|---|
| 2074 | solid issolid not { |
|---|
| 2075 | (Error : mauvais type d argument dans solidprojpath) == |
|---|
| 2076 | } if |
|---|
| 2077 | /n solid solidnombrefaces def |
|---|
| 2078 | i n 1 sub le { |
|---|
| 2079 | visibility not solid i solidfacevisible? or { |
|---|
| 2080 | currentdict /option known { |
|---|
| 2081 | option cvx exec |
|---|
| 2082 | } { |
|---|
| 2083 | solid i solidcentreface |
|---|
| 2084 | } ifelse |
|---|
| 2085 | [ |
|---|
| 2086 | solid 0 i solidgetsommetface |
|---|
| 2087 | solid 1 i solidgetsommetface |
|---|
| 2088 | vecteur3d normalize3d |
|---|
| 2089 | solid i solidnormaleface alpha |
|---|
| 2090 | ] false planprojpath |
|---|
| 2091 | } { |
|---|
| 2092 | newpath 0 0 smoveto |
|---|
| 2093 | } ifelse |
|---|
| 2094 | } { |
|---|
| 2095 | (Error : indice trop grand dans solidprojpath) == |
|---|
| 2096 | quit |
|---|
| 2097 | } ifelse |
|---|
| 2098 | end |
|---|
| 2099 | } def |
|---|
| 2100 | |
|---|
| 2101 | %% syntaxe : x y z [normal] bool planprojpath |
|---|
| 2102 | /planprojpath { |
|---|
| 2103 | 6 dict begin |
|---|
| 2104 | /visibility exch def |
|---|
| 2105 | %% on calcule l image de la base (I,J,K) |
|---|
| 2106 | normalvect_to_orthobase |
|---|
| 2107 | /imageK defpoint3d |
|---|
| 2108 | /imageJ defpoint3d |
|---|
| 2109 | /imageI defpoint3d |
|---|
| 2110 | /z exch def |
|---|
| 2111 | /y exch def |
|---|
| 2112 | /x exch def |
|---|
| 2113 | |
|---|
| 2114 | visibility not x y z imageK planvisible? or { |
|---|
| 2115 | {ptojpoint 0 |
|---|
| 2116 | imageI |
|---|
| 2117 | imageJ |
|---|
| 2118 | imageK |
|---|
| 2119 | transformpoint3d |
|---|
| 2120 | x y z addv3d |
|---|
| 2121 | 3dto2d jtoppoint} currentppathtransform |
|---|
| 2122 | } { |
|---|
| 2123 | newpath |
|---|
| 2124 | } ifelse |
|---|
| 2125 | end |
|---|
| 2126 | } def |
|---|
| 2127 | |
|---|
| 2128 | %%%%% ### projscene ### |
|---|
| 2129 | %% syntaxe : plantype bool bprojscene ... eprojscene |
|---|
| 2130 | /bprojscene { |
|---|
| 2131 | 10 dict begin |
|---|
| 2132 | gsave |
|---|
| 2133 | dup isbool { |
|---|
| 2134 | /mybool exch def |
|---|
| 2135 | } { |
|---|
| 2136 | /mybool true def |
|---|
| 2137 | } ifelse |
|---|
| 2138 | /l@pl@n exch def |
|---|
| 2139 | /saveStroke {SolidesDict /Stroke get exec} def |
|---|
| 2140 | /Stroke {l@pl@n mybool projpath saveStroke} def |
|---|
| 2141 | /savefill {SolidesDict /Fill get exec} def |
|---|
| 2142 | /Fill {l@pl@n mybool projpath savefill} def |
|---|
| 2143 | /masque {} def |
|---|
| 2144 | l@pl@n plangetrange aload pop |
|---|
| 2145 | setyrange setxrange |
|---|
| 2146 | newpath |
|---|
| 2147 | %% xmin ymin l@pl@n pointplan smoveto |
|---|
| 2148 | %% xmin ymax l@pl@n pointplan slineto |
|---|
| 2149 | %% xmax ymax l@pl@n pointplan slineto |
|---|
| 2150 | %% xmax ymin l@pl@n pointplan slineto |
|---|
| 2151 | %% xmin ymin l@pl@n pointplan smoveto |
|---|
| 2152 | %% % closepath |
|---|
| 2153 | %% %gsave orange Fill grestore |
|---|
| 2154 | %% clip |
|---|
| 2155 | } def |
|---|
| 2156 | /eprojscene { |
|---|
| 2157 | grestore |
|---|
| 2158 | end |
|---|
| 2159 | } def |
|---|
| 2160 | |
|---|
| 2161 | %%%%% ### fin insertion ### |
|---|
| 2162 | |
|---|
| 2163 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2164 | %%%% fonctions numeriques %%%% |
|---|
| 2165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2166 | |
|---|
| 2167 | %%%%% ### courbeparam ### |
|---|
| 2168 | /setresolution { |
|---|
| 2169 | /resolution exch def |
|---|
| 2170 | } def |
|---|
| 2171 | /resolution 200 def |
|---|
| 2172 | |
|---|
| 2173 | /courbe_dic 2 dict def |
|---|
| 2174 | courbe_dic /X {} put |
|---|
| 2175 | courbe_dic /Y {} put |
|---|
| 2176 | |
|---|
| 2177 | %% syntaxe : tmin tmax C@urbeparam_ |
|---|
| 2178 | /C@urbeparam_ { |
|---|
| 2179 | 6 dict begin |
|---|
| 2180 | /tmax@ exch def |
|---|
| 2181 | /tmin@ exch def |
|---|
| 2182 | /t tmin@ def |
|---|
| 2183 | /dt tmax@ tmin@ sub resolution 1 sub div def |
|---|
| 2184 | tmin@ courbe_dic /X get exec |
|---|
| 2185 | pstrickactionR |
|---|
| 2186 | tmin@ courbe_dic /Y get exec |
|---|
| 2187 | pstrickactionR |
|---|
| 2188 | smoveto |
|---|
| 2189 | resolution 1 sub |
|---|
| 2190 | { |
|---|
| 2191 | t courbe_dic /X get exec |
|---|
| 2192 | pstrickactionR |
|---|
| 2193 | t courbe_dic /Y get exec |
|---|
| 2194 | pstrickactionR |
|---|
| 2195 | slineto |
|---|
| 2196 | |
|---|
| 2197 | /t t dt add store %% on incremente |
|---|
| 2198 | } |
|---|
| 2199 | repeat |
|---|
| 2200 | tmax@ courbe_dic /X get exec |
|---|
| 2201 | pstrickactionR |
|---|
| 2202 | tmax@ courbe_dic /Y get exec |
|---|
| 2203 | pstrickactionR |
|---|
| 2204 | slineto |
|---|
| 2205 | end |
|---|
| 2206 | } def |
|---|
| 2207 | |
|---|
| 2208 | %% syntaxe : tmin tmax {X} {Y} Courbeparam_ |
|---|
| 2209 | /Courbeparam_ { |
|---|
| 2210 | courbe_dic exch /Y exch put |
|---|
| 2211 | courbe_dic exch /X exch put |
|---|
| 2212 | C@urbeparam_ |
|---|
| 2213 | } def |
|---|
| 2214 | |
|---|
| 2215 | %% syntaxe : {X} {Y} courbeparam_ |
|---|
| 2216 | /courbeparam_ { |
|---|
| 2217 | tmin tmax |
|---|
| 2218 | 4 -1 roll |
|---|
| 2219 | 4 -1 roll |
|---|
| 2220 | Courbeparam_ |
|---|
| 2221 | } def |
|---|
| 2222 | |
|---|
| 2223 | %% syntaxe : tmin tmax {X} {Y} Courbeparam |
|---|
| 2224 | /Courbeparam { |
|---|
| 2225 | gsave |
|---|
| 2226 | 6 dict begin |
|---|
| 2227 | dup isstring |
|---|
| 2228 | { |
|---|
| 2229 | /option exch def |
|---|
| 2230 | } |
|---|
| 2231 | if |
|---|
| 2232 | courbe_dic exch /Y exch put |
|---|
| 2233 | courbe_dic exch /X exch put |
|---|
| 2234 | /tmax exch def |
|---|
| 2235 | /tmin exch def |
|---|
| 2236 | |
|---|
| 2237 | newpath |
|---|
| 2238 | tmin courbe_dic /X get exec |
|---|
| 2239 | pstrickactionR |
|---|
| 2240 | tmin courbe_dic /Y get exec |
|---|
| 2241 | pstrickactionR |
|---|
| 2242 | smoveto %% on commence le chemin |
|---|
| 2243 | tmin tmax C@urbeparam_ |
|---|
| 2244 | starfill |
|---|
| 2245 | |
|---|
| 2246 | stockcurrentcpath |
|---|
| 2247 | newarrowpath |
|---|
| 2248 | currentdict /option known |
|---|
| 2249 | { |
|---|
| 2250 | /dt tmax tmin sub resolution 1 sub div def |
|---|
| 2251 | tmin dt add courbe_dic /X get exec |
|---|
| 2252 | tmin dt add courbe_dic /Y get exec |
|---|
| 2253 | tmin courbe_dic /X get exec |
|---|
| 2254 | tmin courbe_dic /Y get exec |
|---|
| 2255 | arrowpath0 |
|---|
| 2256 | tmax dt sub courbe_dic /X get exec |
|---|
| 2257 | tmax dt sub courbe_dic /Y get exec |
|---|
| 2258 | tmax courbe_dic /X get exec |
|---|
| 2259 | tmax courbe_dic /Y get exec |
|---|
| 2260 | currentdict /dt undef |
|---|
| 2261 | arrowpath1 |
|---|
| 2262 | option |
|---|
| 2263 | gere_arrowhead |
|---|
| 2264 | } |
|---|
| 2265 | if |
|---|
| 2266 | |
|---|
| 2267 | currentlinewidth 0 eq {} { Stroke } ifelse |
|---|
| 2268 | |
|---|
| 2269 | end |
|---|
| 2270 | grestore |
|---|
| 2271 | } def |
|---|
| 2272 | |
|---|
| 2273 | %% syntaxe : {X} {Y} courbeparam |
|---|
| 2274 | /courbeparam { |
|---|
| 2275 | dup isstring |
|---|
| 2276 | { |
|---|
| 2277 | tmin tmax |
|---|
| 2278 | 5 -1 roll |
|---|
| 2279 | 5 -1 roll |
|---|
| 2280 | 5 -1 roll |
|---|
| 2281 | } |
|---|
| 2282 | { |
|---|
| 2283 | tmin tmax |
|---|
| 2284 | 4 -1 roll |
|---|
| 2285 | 4 -1 roll |
|---|
| 2286 | } |
|---|
| 2287 | ifelse |
|---|
| 2288 | Courbeparam |
|---|
| 2289 | } def |
|---|
| 2290 | |
|---|
| 2291 | %% syntaxe : tmin tmax {X} {Y} Courbeparam* |
|---|
| 2292 | /Courbeparam* { |
|---|
| 2293 | 1 dict begin |
|---|
| 2294 | /startest {true} def |
|---|
| 2295 | Courbeparam |
|---|
| 2296 | end |
|---|
| 2297 | } def |
|---|
| 2298 | |
|---|
| 2299 | %% syntaxe : {X} {Y} courbeparam* |
|---|
| 2300 | /courbeparam* { |
|---|
| 2301 | 1 dict begin |
|---|
| 2302 | /startest {true} def |
|---|
| 2303 | courbeparam |
|---|
| 2304 | end |
|---|
| 2305 | } def |
|---|
| 2306 | |
|---|
| 2307 | %%%%% ### courbe ### |
|---|
| 2308 | %% syntaxe : {f} courbe |
|---|
| 2309 | /courbe { |
|---|
| 2310 | dup isstring %% y a-t-il une option de fin de ligne ? |
|---|
| 2311 | { |
|---|
| 2312 | xmin xmax |
|---|
| 2313 | {} |
|---|
| 2314 | 5 -1 roll |
|---|
| 2315 | 5 -1 roll |
|---|
| 2316 | } |
|---|
| 2317 | { |
|---|
| 2318 | xmin xmax |
|---|
| 2319 | {} |
|---|
| 2320 | 4 -1 roll |
|---|
| 2321 | } |
|---|
| 2322 | ifelse |
|---|
| 2323 | Courbeparam |
|---|
| 2324 | } def |
|---|
| 2325 | |
|---|
| 2326 | %% syntaxe : mini maxi {f} Courbe |
|---|
| 2327 | /Courbe { |
|---|
| 2328 | dup isstring { |
|---|
| 2329 | {} |
|---|
| 2330 | 3 -1 roll |
|---|
| 2331 | 3 -1 roll |
|---|
| 2332 | } { |
|---|
| 2333 | {} |
|---|
| 2334 | 2 -1 roll |
|---|
| 2335 | } ifelse |
|---|
| 2336 | Courbeparam |
|---|
| 2337 | } def |
|---|
| 2338 | |
|---|
| 2339 | %% syntaxe : {f} courbe_ |
|---|
| 2340 | /courbe_ { |
|---|
| 2341 | xmin xmax |
|---|
| 2342 | {} |
|---|
| 2343 | 4 -1 roll |
|---|
| 2344 | Courbeparam_ |
|---|
| 2345 | } def |
|---|
| 2346 | |
|---|
| 2347 | %% syntaxe : mini maxi {f} Courbe_ |
|---|
| 2348 | /Courbe_ { |
|---|
| 2349 | {} |
|---|
| 2350 | 2 -1 roll |
|---|
| 2351 | Courbeparam_ |
|---|
| 2352 | } def |
|---|
| 2353 | |
|---|
| 2354 | %% syntaxe : mini maxi {f} Courbe* |
|---|
| 2355 | /Courbe* { |
|---|
| 2356 | 1 dict begin |
|---|
| 2357 | /startest {true} def |
|---|
| 2358 | Courbe |
|---|
| 2359 | end |
|---|
| 2360 | } def |
|---|
| 2361 | |
|---|
| 2362 | %% syntaxe : {f} courbe* |
|---|
| 2363 | /courbe* { |
|---|
| 2364 | 1 dict begin |
|---|
| 2365 | /startest {true} def |
|---|
| 2366 | courbe |
|---|
| 2367 | end |
|---|
| 2368 | } def |
|---|
| 2369 | |
|---|
| 2370 | %%%%% ### courbeR2 ### |
|---|
| 2371 | %% syntaxe : tmin tmax C@urbeR2_ |
|---|
| 2372 | /C@urbeR2_ { |
|---|
| 2373 | 6 dict begin |
|---|
| 2374 | /tmax@ exch def |
|---|
| 2375 | /tmin@ exch def |
|---|
| 2376 | /t tmin@ def |
|---|
| 2377 | /dt tmax@ tmin@ sub resolution 1 sub div def |
|---|
| 2378 | tmin@ courbe_dic /X get exec |
|---|
| 2379 | pstrickactionR2 |
|---|
| 2380 | smoveto |
|---|
| 2381 | /t t dt add store |
|---|
| 2382 | resolution 2 sub |
|---|
| 2383 | { |
|---|
| 2384 | t courbe_dic /X get exec |
|---|
| 2385 | pstrickactionR2 |
|---|
| 2386 | slineto |
|---|
| 2387 | /t t dt add store %% on incremente |
|---|
| 2388 | } |
|---|
| 2389 | repeat |
|---|
| 2390 | tmax@ courbe_dic /X get exec |
|---|
| 2391 | pstrickactionR2 |
|---|
| 2392 | slineto |
|---|
| 2393 | end |
|---|
| 2394 | } def |
|---|
| 2395 | |
|---|
| 2396 | %% syntaxe : tmin tmax {X} CourbeR2_ |
|---|
| 2397 | /CourbeR2_ { |
|---|
| 2398 | courbe_dic exch /X exch put |
|---|
| 2399 | C@urbeR2_ |
|---|
| 2400 | } def |
|---|
| 2401 | |
|---|
| 2402 | %% syntaxe : {X} courbeR2_ |
|---|
| 2403 | /courbeR2_ { |
|---|
| 2404 | tmin tmax |
|---|
| 2405 | 3 -1 roll |
|---|
| 2406 | 3 -1 roll |
|---|
| 2407 | CourbeR2_ |
|---|
| 2408 | } def |
|---|
| 2409 | |
|---|
| 2410 | %% syntaxe : tmin tmax {X} CourbeR2 |
|---|
| 2411 | /CourbeR2+ { |
|---|
| 2412 | 2 dict begin |
|---|
| 2413 | /slineto {} def |
|---|
| 2414 | /smoveto {} def |
|---|
| 2415 | CourbeR2 |
|---|
| 2416 | end |
|---|
| 2417 | } bind def |
|---|
| 2418 | |
|---|
| 2419 | /CourbeR2 { |
|---|
| 2420 | gsave |
|---|
| 2421 | 6 dict begin |
|---|
| 2422 | dup isstring |
|---|
| 2423 | { |
|---|
| 2424 | /option exch def |
|---|
| 2425 | } |
|---|
| 2426 | if |
|---|
| 2427 | courbe_dic exch /X exch put |
|---|
| 2428 | /tmax exch def |
|---|
| 2429 | /tmin exch def |
|---|
| 2430 | |
|---|
| 2431 | newpath |
|---|
| 2432 | tmin tmax C@urbeR2_ |
|---|
| 2433 | starfill |
|---|
| 2434 | currentlinewidth 0 eq {} { Stroke } ifelse |
|---|
| 2435 | |
|---|
| 2436 | end |
|---|
| 2437 | grestore |
|---|
| 2438 | } def |
|---|
| 2439 | |
|---|
| 2440 | %% syntaxe : {X} courbeR2 |
|---|
| 2441 | /courbeR2 { |
|---|
| 2442 | tmin tmax |
|---|
| 2443 | 3 -1 roll |
|---|
| 2444 | CourbeR2 |
|---|
| 2445 | } def |
|---|
| 2446 | |
|---|
| 2447 | %% syntaxe : tmin tmax {X} CourbeR2* |
|---|
| 2448 | /CourbeR2* { |
|---|
| 2449 | 1 dict begin |
|---|
| 2450 | /startest {true} def |
|---|
| 2451 | CourbeR2 |
|---|
| 2452 | end |
|---|
| 2453 | } def |
|---|
| 2454 | |
|---|
| 2455 | %% syntaxe : {X} {Y} courbeR2* |
|---|
| 2456 | /courbeR2* { |
|---|
| 2457 | 1 dict begin |
|---|
| 2458 | /startest {true} def |
|---|
| 2459 | courbeR2 |
|---|
| 2460 | end |
|---|
| 2461 | } def |
|---|
| 2462 | |
|---|
| 2463 | %%%%% ### courbeR3 ### |
|---|
| 2464 | %% syntaxe : t1 t2 {f} (option) CourbeR3 |
|---|
| 2465 | /CourbeR3 { |
|---|
| 2466 | 2 dict begin |
|---|
| 2467 | dup isstring { |
|---|
| 2468 | /option exch def |
|---|
| 2469 | } if |
|---|
| 2470 | /lafonction exch def |
|---|
| 2471 | {lafonction 3dto2d} |
|---|
| 2472 | currentdict /option known |
|---|
| 2473 | {option} |
|---|
| 2474 | if |
|---|
| 2475 | CourbeR2 |
|---|
| 2476 | end |
|---|
| 2477 | } def |
|---|
| 2478 | |
|---|
| 2479 | %% syntaxe : {f} (option) CourbeR3 |
|---|
| 2480 | /courbeR3 { |
|---|
| 2481 | tmin tmax 3 -1 roll CourbeR3 |
|---|
| 2482 | } def |
|---|
| 2483 | |
|---|
| 2484 | %%%%% ### cercle ### |
|---|
| 2485 | %% syntaxe : x0 y0 r cercle |
|---|
| 2486 | /cercle { |
|---|
| 2487 | 3 dict begin |
|---|
| 2488 | /r@y@n exch def |
|---|
| 2489 | /y@ exch def |
|---|
| 2490 | /x@ exch def |
|---|
| 2491 | 0 360 {cos r@y@n mul x@ add} {sin r@y@n mul y@ add} Courbeparam |
|---|
| 2492 | end |
|---|
| 2493 | } def |
|---|
| 2494 | |
|---|
| 2495 | %% syntaxe : x0 y0 r cercle_ |
|---|
| 2496 | /cercle_ { |
|---|
| 2497 | 3 dict begin |
|---|
| 2498 | /r@y@n exch def |
|---|
| 2499 | /y@ exch def |
|---|
| 2500 | /x@ exch def |
|---|
| 2501 | x@ r@y@n add y@ smoveto |
|---|
| 2502 | 0 360 {cos r@y@n mul x@ add} {sin r@y@n mul y@ add} Courbeparam_ |
|---|
| 2503 | end |
|---|
| 2504 | } def |
|---|
| 2505 | |
|---|
| 2506 | %% syntaxe : x0 y0 r cercle-_ |
|---|
| 2507 | /cercle-_ { |
|---|
| 2508 | 3 dict begin |
|---|
| 2509 | /r@y@n exch def |
|---|
| 2510 | /y@ exch def |
|---|
| 2511 | /x@ exch def |
|---|
| 2512 | x@ r@y@n add y@ smoveto |
|---|
| 2513 | 360 0 {cos r@y@n mul x@ add} {sin r@y@n mul y@ add} Courbeparam_ |
|---|
| 2514 | end |
|---|
| 2515 | } def |
|---|
| 2516 | |
|---|
| 2517 | %% syntaxe : x0 y0 r cercle* |
|---|
| 2518 | /cercle* { |
|---|
| 2519 | 1 dict begin |
|---|
| 2520 | /startest true def |
|---|
| 2521 | cercle |
|---|
| 2522 | end |
|---|
| 2523 | } def |
|---|
| 2524 | |
|---|
| 2525 | %% syntaxe : alpha beta x0 y0 r Cercle |
|---|
| 2526 | /Cercle { |
|---|
| 2527 | 4 dict begin |
|---|
| 2528 | dup isstring |
|---|
| 2529 | {/option exch def} |
|---|
| 2530 | if |
|---|
| 2531 | /r@y@n exch def |
|---|
| 2532 | /y@ exch def |
|---|
| 2533 | /x@ exch def |
|---|
| 2534 | {cos r@y@n mul x@ add} {sin r@y@n mul y@ add} |
|---|
| 2535 | currentdict /option known |
|---|
| 2536 | {option} |
|---|
| 2537 | if |
|---|
| 2538 | Courbeparam |
|---|
| 2539 | end |
|---|
| 2540 | } def |
|---|
| 2541 | |
|---|
| 2542 | %% syntaxe : alpha beta x0 y0 r Cercle_ |
|---|
| 2543 | /Cercle_ { |
|---|
| 2544 | 3 dict begin |
|---|
| 2545 | /r@y@n exch def |
|---|
| 2546 | /y@ exch def |
|---|
| 2547 | /x@ exch def |
|---|
| 2548 | {cos r@y@n mul x@ add} {sin r@y@n mul y@ add} Courbeparam_ |
|---|
| 2549 | end |
|---|
| 2550 | } def |
|---|
| 2551 | |
|---|
| 2552 | %% syntaxe : alpha beta x0 y0 r Cercle |
|---|
| 2553 | /Cercle* { |
|---|
| 2554 | 1 dict begin |
|---|
| 2555 | /startest {true} def |
|---|
| 2556 | Cercle |
|---|
| 2557 | end |
|---|
| 2558 | } def |
|---|
| 2559 | |
|---|
| 2560 | %%%%% ### fin insertion ### |
|---|
| 2561 | |
|---|
| 2562 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2563 | %%%% fonctions et constantes mathematiques %%%% |
|---|
| 2564 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2565 | |
|---|
| 2566 | %%%%% ### math ### |
|---|
| 2567 | %%%%%%%%%%% constantes mathematiques %%%%%%%%%%%%%% |
|---|
| 2568 | |
|---|
| 2569 | /pi 3.14159 def |
|---|
| 2570 | /e 2.71828 def |
|---|
| 2571 | |
|---|
| 2572 | %%%%%%%%%%% fonctions mathematiques %%%%%%%%%%%%%%% |
|---|
| 2573 | |
|---|
| 2574 | /rd {180 pi div mul} def %% transforme des rd en degres |
|---|
| 2575 | /deg {pi mul 180 div} def %% transforme des degres en rd |
|---|
| 2576 | /log {ln 10 ln div} def |
|---|
| 2577 | /Exp {e exch exp} def |
|---|
| 2578 | /Cos {rd cos} def |
|---|
| 2579 | /Sin {rd sin} def |
|---|
| 2580 | /tan {dup sin exch cos div} def |
|---|
| 2581 | /cotan {dup cos exch sin div} def |
|---|
| 2582 | /Tan {dup Sin exch Cos div} def |
|---|
| 2583 | /Cotan {dup Cos exch Sin div} def |
|---|
| 2584 | /coTan {Cotan} def |
|---|
| 2585 | /arctan { |
|---|
| 2586 | dup 0 ge |
|---|
| 2587 | {1 atan} |
|---|
| 2588 | {neg 1 atan neg} |
|---|
| 2589 | ifelse |
|---|
| 2590 | } def |
|---|
| 2591 | /Arctan {arctan deg} def |
|---|
| 2592 | /arccos { |
|---|
| 2593 | dup |
|---|
| 2594 | dup mul neg 1 add sqrt |
|---|
| 2595 | exch |
|---|
| 2596 | atan |
|---|
| 2597 | } def |
|---|
| 2598 | /Arccos {arccos deg} def |
|---|
| 2599 | /arcsin { |
|---|
| 2600 | dup 1 eq { |
|---|
| 2601 | 90 |
|---|
| 2602 | } { |
|---|
| 2603 | dup |
|---|
| 2604 | dup mul neg 1 add sqrt |
|---|
| 2605 | atan |
|---|
| 2606 | dup 90 lt |
|---|
| 2607 | {} |
|---|
| 2608 | {360 sub} |
|---|
| 2609 | ifelse |
|---|
| 2610 | } ifelse |
|---|
| 2611 | } def |
|---|
| 2612 | /Arcsin {arcsin deg} def |
|---|
| 2613 | /cosh {dup Exp exch neg Exp add 2 div} def |
|---|
| 2614 | /sinh {dup Exp exch neg Exp sub 2 div} def |
|---|
| 2615 | /tanh {dup sinh exch cosh div} def |
|---|
| 2616 | /cotanh {dup cosh exch sinh div} def |
|---|
| 2617 | /argcosh {dup dup mul 1 sub sqrt add ln} def |
|---|
| 2618 | /argsinh {dup dup mul 1 add sqrt add ln} def |
|---|
| 2619 | /argtanh { |
|---|
| 2620 | setxvar |
|---|
| 2621 | x 1 add |
|---|
| 2622 | 1 x sub |
|---|
| 2623 | div |
|---|
| 2624 | ln |
|---|
| 2625 | 2 div |
|---|
| 2626 | } def |
|---|
| 2627 | /factorielle { |
|---|
| 2628 | dup 0 eq |
|---|
| 2629 | {pop 1} |
|---|
| 2630 | {dup 1 sub factorielle mul} |
|---|
| 2631 | ifelse |
|---|
| 2632 | } def |
|---|
| 2633 | /Gauss { |
|---|
| 2634 | 3 dict begin |
|---|
| 2635 | /sigma exch def |
|---|
| 2636 | /m exch def |
|---|
| 2637 | /x exch def |
|---|
| 2638 | x m sub dup mul sigma dup mul 2 mul div neg Exp |
|---|
| 2639 | 2 pi mul sigma dup mul mul sqrt div |
|---|
| 2640 | end |
|---|
| 2641 | } def |
|---|
| 2642 | %% syntaxe : a n modulo |
|---|
| 2643 | /modulo { |
|---|
| 2644 | 2 dict begin |
|---|
| 2645 | /n exch def |
|---|
| 2646 | /a exch def |
|---|
| 2647 | { |
|---|
| 2648 | a 0 lt { |
|---|
| 2649 | /a a n add store |
|---|
| 2650 | } { |
|---|
| 2651 | exit |
|---|
| 2652 | } ifelse |
|---|
| 2653 | } loop |
|---|
| 2654 | a n mod |
|---|
| 2655 | end |
|---|
| 2656 | } def |
|---|
| 2657 | |
|---|
| 2658 | %%%%% ### max ### |
|---|
| 2659 | /max { |
|---|
| 2660 | 2 copy |
|---|
| 2661 | lt {exch} if |
|---|
| 2662 | pop |
|---|
| 2663 | } def |
|---|
| 2664 | |
|---|
| 2665 | %%%%% ### min ### |
|---|
| 2666 | /min { |
|---|
| 2667 | 2 dict begin |
|---|
| 2668 | dup isarray { |
|---|
| 2669 | duparray /table exch def pop |
|---|
| 2670 | table 0 get |
|---|
| 2671 | 1 1 table length 1 sub { |
|---|
| 2672 | /i exch def |
|---|
| 2673 | table i get |
|---|
| 2674 | min |
|---|
| 2675 | } for |
|---|
| 2676 | } { |
|---|
| 2677 | 2 copy |
|---|
| 2678 | gt {exch} if |
|---|
| 2679 | pop |
|---|
| 2680 | } ifelse |
|---|
| 2681 | end |
|---|
| 2682 | } def |
|---|
| 2683 | |
|---|
| 2684 | %%%%% ### setcolor ### |
|---|
| 2685 | %% syntaxe : tableau setcolor |
|---|
| 2686 | /setcolor { |
|---|
| 2687 | dup length 4 eq |
|---|
| 2688 | {aload pop setcmykcolor} |
|---|
| 2689 | {aload pop setrgbcolor} |
|---|
| 2690 | ifelse |
|---|
| 2691 | } def |
|---|
| 2692 | |
|---|
| 2693 | %%%%% ### in ### |
|---|
| 2694 | %% cherche si un elt donne appartient au tableau donne |
|---|
| 2695 | %% rque : utilise 3 variables locales |
|---|
| 2696 | %% syntaxe : elt array in --> index boolean |
|---|
| 2697 | /in { |
|---|
| 2698 | 3 dict begin |
|---|
| 2699 | /liste exch def |
|---|
| 2700 | /elt exch def |
|---|
| 2701 | /i 0 def |
|---|
| 2702 | false %% la reponse a priori |
|---|
| 2703 | liste length { |
|---|
| 2704 | liste i get elt eq { |
|---|
| 2705 | pop %% en enleve la reponse |
|---|
| 2706 | i true %% pour mettre la bonne |
|---|
| 2707 | exit |
|---|
| 2708 | } if |
|---|
| 2709 | /i i 1 add store |
|---|
| 2710 | } repeat |
|---|
| 2711 | end |
|---|
| 2712 | } def |
|---|
| 2713 | |
|---|
| 2714 | %% cherche si un elt donne appartient au tableau donne |
|---|
| 2715 | %% syntaxe : elt array in --> boolean |
|---|
| 2716 | /In { |
|---|
| 2717 | 3 dict begin |
|---|
| 2718 | /liste exch def |
|---|
| 2719 | /elt exch def |
|---|
| 2720 | /i 0 def |
|---|
| 2721 | false %% la reponse a priori |
|---|
| 2722 | liste length { |
|---|
| 2723 | liste i get elt eq { |
|---|
| 2724 | pop %% en enleve la reponse |
|---|
| 2725 | true %% pour mettre la bonne |
|---|
| 2726 | exit |
|---|
| 2727 | } if |
|---|
| 2728 | /i i 1 add store |
|---|
| 2729 | } repeat |
|---|
| 2730 | end |
|---|
| 2731 | } def |
|---|
| 2732 | |
|---|
| 2733 | %%%%% ### starfill ### |
|---|
| 2734 | %% la procedure pour les objets "star" |
|---|
| 2735 | %% si c est "star" on fait le fillstyle, sinon non |
|---|
| 2736 | /starfill { |
|---|
| 2737 | startest { |
|---|
| 2738 | gsave |
|---|
| 2739 | clip |
|---|
| 2740 | fillstyle |
|---|
| 2741 | grestore |
|---|
| 2742 | /startest false def |
|---|
| 2743 | } if |
|---|
| 2744 | } def |
|---|
| 2745 | |
|---|
| 2746 | %%%%% ### addv ### |
|---|
| 2747 | %% syntaxe : u v addv --> u+v |
|---|
| 2748 | /addv { %% xA yA xB yB |
|---|
| 2749 | 3 1 roll %% xA yB yA xB |
|---|
| 2750 | 4 1 roll %% xB xA yB yA |
|---|
| 2751 | add 3 1 roll %% yB+yA xB xA |
|---|
| 2752 | add exch |
|---|
| 2753 | } def |
|---|
| 2754 | |
|---|
| 2755 | %%%%% ### continu ### |
|---|
| 2756 | /continu { |
|---|
| 2757 | [] 0 setdash |
|---|
| 2758 | } def |
|---|
| 2759 | |
|---|
| 2760 | %%%%% ### trigospherique ### |
|---|
| 2761 | %% passage spherique --> cartesiennes |
|---|
| 2762 | %% les formules de passage ont été récupérées ici : |
|---|
| 2763 | %% http://fr.wikipedia.org/wiki/Coordonn%C3%A9es_polaires |
|---|
| 2764 | %% syntaxe : r theta phi rtp2xyz -> x y z |
|---|
| 2765 | /rtp2xyz { |
|---|
| 2766 | 6 dict begin |
|---|
| 2767 | /phi exch def |
|---|
| 2768 | /theta exch def |
|---|
| 2769 | /r exch def |
|---|
| 2770 | /x phi cos theta cos mul r mul def |
|---|
| 2771 | /y phi cos theta sin mul r mul def |
|---|
| 2772 | /z phi sin r mul def |
|---|
| 2773 | x y z |
|---|
| 2774 | end |
|---|
| 2775 | } def |
|---|
| 2776 | |
|---|
| 2777 | %% trace d'un arc sur une sphere de centre O |
|---|
| 2778 | %% syntaxe : r theta1 phi1 r theta2 phi2 arcspherique |
|---|
| 2779 | /arcspherique { |
|---|
| 2780 | 9 dict begin |
|---|
| 2781 | dup isstring { |
|---|
| 2782 | /option exch def |
|---|
| 2783 | } if |
|---|
| 2784 | /phi2 exch def |
|---|
| 2785 | /theta2 exch def |
|---|
| 2786 | pop |
|---|
| 2787 | /phi1 exch def |
|---|
| 2788 | /theta1 exch def |
|---|
| 2789 | /r exch def |
|---|
| 2790 | /n 12 def |
|---|
| 2791 | |
|---|
| 2792 | 1 theta1 phi1 rtp2xyz /u defpoint3d |
|---|
| 2793 | 1 theta2 phi2 rtp2xyz /v defpoint3d |
|---|
| 2794 | u v vectprod3d u vectprod3d dupp3d norme3d 1 exch div mulv3d /w defpoint3d |
|---|
| 2795 | |
|---|
| 2796 | /sinalpha u v vectprod3d norme3d def |
|---|
| 2797 | /cosalpha u v scalprod3d def |
|---|
| 2798 | /alpha sinalpha cosalpha atan def |
|---|
| 2799 | /n 12 def |
|---|
| 2800 | /pas alpha n div def |
|---|
| 2801 | |
|---|
| 2802 | gsave |
|---|
| 2803 | /t pas neg def |
|---|
| 2804 | [ |
|---|
| 2805 | n 1 add { |
|---|
| 2806 | /t t pas add store |
|---|
| 2807 | u t cos r mul mulv3d |
|---|
| 2808 | w t sin r mul mulv3d |
|---|
| 2809 | addv3d |
|---|
| 2810 | } repeat |
|---|
| 2811 | ] |
|---|
| 2812 | currentdict /option known { |
|---|
| 2813 | option |
|---|
| 2814 | } if |
|---|
| 2815 | ligne3d |
|---|
| 2816 | grestore |
|---|
| 2817 | end |
|---|
| 2818 | } def |
|---|
| 2819 | |
|---|
| 2820 | %% trace d'un arc sur une sphere de centre O |
|---|
| 2821 | %% syntaxe : r theta1 phi1 r theta2 phi2 arcspherique |
|---|
| 2822 | /arcspherique_ { |
|---|
| 2823 | 8 dict begin |
|---|
| 2824 | /phi2 exch def |
|---|
| 2825 | /theta2 exch def |
|---|
| 2826 | pop |
|---|
| 2827 | /phi1 exch def |
|---|
| 2828 | /theta1 exch def |
|---|
| 2829 | /r exch def |
|---|
| 2830 | /n 12 def |
|---|
| 2831 | |
|---|
| 2832 | 1 theta1 phi1 rtp2xyz /u defpoint3d |
|---|
| 2833 | 1 theta2 phi2 rtp2xyz /v defpoint3d |
|---|
| 2834 | u v vectprod3d u vectprod3d dupp3d norme3d 1 exch div mulv3d /w defpoint3d |
|---|
| 2835 | |
|---|
| 2836 | /sinalpha u v vectprod3d norme3d def |
|---|
| 2837 | /cosalpha u v scalprod3d def |
|---|
| 2838 | /alpha sinalpha cosalpha atan def |
|---|
| 2839 | /n 12 def |
|---|
| 2840 | /pas alpha n div def |
|---|
| 2841 | |
|---|
| 2842 | /t pas neg def |
|---|
| 2843 | [ |
|---|
| 2844 | n 1 add { |
|---|
| 2845 | /t t pas add store |
|---|
| 2846 | u t cos r mul mulv3d |
|---|
| 2847 | w t sin r mul mulv3d |
|---|
| 2848 | addv3d |
|---|
| 2849 | } repeat |
|---|
| 2850 | ] ligne3d_ |
|---|
| 2851 | end |
|---|
| 2852 | } def |
|---|
| 2853 | |
|---|
| 2854 | %% trace d'une geodesique sur une sphere de centre O |
|---|
| 2855 | %% syntaxe : r theta1 phi1 r theta2 phi2 geodesique_sphere |
|---|
| 2856 | /geodesique_sphere { |
|---|
| 2857 | 13 dict begin |
|---|
| 2858 | /phi2 exch def |
|---|
| 2859 | /theta2 exch def |
|---|
| 2860 | pop |
|---|
| 2861 | /phi1 exch def |
|---|
| 2862 | /theta1 exch def |
|---|
| 2863 | /r exch def |
|---|
| 2864 | /n 360 def |
|---|
| 2865 | |
|---|
| 2866 | 1 theta1 phi1 rtp2xyz /u defpoint3d |
|---|
| 2867 | 1 theta2 phi2 rtp2xyz /v defpoint3d |
|---|
| 2868 | u v vectprod3d u vectprod3d dupp3d norme3d 1 exch div mulv3d /w defpoint3d |
|---|
| 2869 | |
|---|
| 2870 | /sinalpha u v vectprod3d norme3d def |
|---|
| 2871 | /cosalpha u v scalprod3d def |
|---|
| 2872 | /alpha sinalpha cosalpha atan def |
|---|
| 2873 | /pas 360 n div def |
|---|
| 2874 | |
|---|
| 2875 | gsave |
|---|
| 2876 | /t pas neg def |
|---|
| 2877 | [ |
|---|
| 2878 | n 1 add { |
|---|
| 2879 | /t t pas add store |
|---|
| 2880 | u t cos r mul mulv3d |
|---|
| 2881 | w t sin r mul mulv3d |
|---|
| 2882 | addv3d |
|---|
| 2883 | } repeat |
|---|
| 2884 | ] ligne3d |
|---|
| 2885 | grestore |
|---|
| 2886 | end |
|---|
| 2887 | } def |
|---|
| 2888 | |
|---|
| 2889 | |
|---|
| 2890 | %% syntaxe : A B C trianglespherique --> trace le rtiangle ABC |
|---|
| 2891 | %% (coordonnees spheriques) |
|---|
| 2892 | /trianglespherique* { |
|---|
| 2893 | 1 dict begin |
|---|
| 2894 | /startest {true} def |
|---|
| 2895 | trianglespherique |
|---|
| 2896 | end |
|---|
| 2897 | } def |
|---|
| 2898 | |
|---|
| 2899 | /trianglespherique { |
|---|
| 2900 | 10 dict begin |
|---|
| 2901 | /C defpoint3d |
|---|
| 2902 | /B defpoint3d |
|---|
| 2903 | /A defpoint3d |
|---|
| 2904 | gsave |
|---|
| 2905 | newpath |
|---|
| 2906 | A rtp2xyz 3dto2d smoveto |
|---|
| 2907 | A B arcspherique_ |
|---|
| 2908 | B C arcspherique_ |
|---|
| 2909 | C A arcspherique_ |
|---|
| 2910 | closepath |
|---|
| 2911 | starfill |
|---|
| 2912 | currentlinewidth 0 eq {} { Stroke } ifelse |
|---|
| 2913 | grestore |
|---|
| 2914 | end |
|---|
| 2915 | } def |
|---|
| 2916 | |
|---|
| 2917 | %%%%% ### fin insertion ### |
|---|
| 2918 | |
|---|
| 2919 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2920 | %%%% operations sur les tableaux %%%% |
|---|
| 2921 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2922 | |
|---|
| 2923 | %%%%% ### duparray ### |
|---|
| 2924 | /duparray { |
|---|
| 2925 | 1 dict begin |
|---|
| 2926 | /table exch def |
|---|
| 2927 | table |
|---|
| 2928 | [ table aload pop ] |
|---|
| 2929 | end |
|---|
| 2930 | } def |
|---|
| 2931 | |
|---|
| 2932 | %%%%% ### append ### |
|---|
| 2933 | %% syntaxe : string1 string2 append --> concatene les 2 chaines ou fusionne 2 tableaux |
|---|
| 2934 | /append { |
|---|
| 2935 | 3 dict begin |
|---|
| 2936 | dup isarray { |
|---|
| 2937 | /tab2 exch def |
|---|
| 2938 | /tab1 exch def |
|---|
| 2939 | [ tab1 aload pop tab2 aload pop ] |
|---|
| 2940 | } { |
|---|
| 2941 | /str2 exch def |
|---|
| 2942 | /str1 exch def |
|---|
| 2943 | /result str1 length str2 length add string def |
|---|
| 2944 | str1 result copy pop |
|---|
| 2945 | result str1 length str2 putinterval |
|---|
| 2946 | result |
|---|
| 2947 | } ifelse |
|---|
| 2948 | end |
|---|
| 2949 | } def |
|---|
| 2950 | |
|---|
| 2951 | %%%%% ### rollparray ### |
|---|
| 2952 | %% syntaxe : array n rollparray -> array |
|---|
| 2953 | %% opere une rotation de n sur les couplets du tableau array |
|---|
| 2954 | /rollparray { |
|---|
| 2955 | 4 dict begin |
|---|
| 2956 | /k exch def |
|---|
| 2957 | /table exch def |
|---|
| 2958 | /n table length def |
|---|
| 2959 | k 0 eq { |
|---|
| 2960 | table |
|---|
| 2961 | } { |
|---|
| 2962 | k 0 ge { |
|---|
| 2963 | [ table aload pop 2 {n 1 roll} repeat ] |
|---|
| 2964 | k 1 sub |
|---|
| 2965 | } { |
|---|
| 2966 | [ table aload pop 2 {n -1 roll} repeat ] |
|---|
| 2967 | k 1 add |
|---|
| 2968 | } ifelse |
|---|
| 2969 | rollparray |
|---|
| 2970 | } ifelse |
|---|
| 2971 | end |
|---|
| 2972 | } def |
|---|
| 2973 | |
|---|
| 2974 | %%%%% ### bubblesort ### |
|---|
| 2975 | %% syntaxe : array bubblesort --> array2 trie par ordre croissant |
|---|
| 2976 | %% code de Bill Casselman |
|---|
| 2977 | %% http://www.math.ubc.ca/people/faculty/cass/graphics/text/www/ |
|---|
| 2978 | /bubblesort { |
|---|
| 2979 | 4 dict begin |
|---|
| 2980 | /a exch def |
|---|
| 2981 | /n a length 1 sub def |
|---|
| 2982 | n 0 gt { |
|---|
| 2983 | % at this point only the n+1 items in the bottom of a remain to |
|---|
| 2984 | % the sorted largest item in that blocks is to be moved up into |
|---|
| 2985 | % position n |
|---|
| 2986 | n { |
|---|
| 2987 | 0 1 n 1 sub { |
|---|
| 2988 | /i exch def |
|---|
| 2989 | a i get a i 1 add get gt { |
|---|
| 2990 | % if a[i] > a[i+1] swap a[i] and a[i+1] |
|---|
| 2991 | a i 1 add |
|---|
| 2992 | a i get |
|---|
| 2993 | a i a i 1 add get |
|---|
| 2994 | % set new a[i] = old a[i+1] |
|---|
| 2995 | put |
|---|
| 2996 | % set new a[i+1] = old a[i] |
|---|
| 2997 | put |
|---|
| 2998 | } if |
|---|
| 2999 | } for |
|---|
| 3000 | /n n 1 sub def |
|---|
| 3001 | } repeat |
|---|
| 3002 | } if |
|---|
| 3003 | a |
|---|
| 3004 | end |
|---|
| 3005 | } def |
|---|
| 3006 | |
|---|
| 3007 | %% syntaxe : array1 doublebubblesort --> array2 array3, array3 est |
|---|
| 3008 | %% trie par ordre croissant et array2 correspond a la position des |
|---|
| 3009 | %% indices de depart, ie si array1 = [3 2 4 1], alors array2 = [3 1 0 2] |
|---|
| 3010 | %% code de Bill Casselman, modifie par jpv, 15/08/2006 |
|---|
| 3011 | %% http://www.math.ubc.ca/people/faculty/cass/graphics/text/www/ |
|---|
| 3012 | /doublebubblesort { |
|---|
| 3013 | 5 dict begin |
|---|
| 3014 | /table exch def |
|---|
| 3015 | /n table length 1 sub def |
|---|
| 3016 | /indices [ 0 1 n {} for ] def |
|---|
| 3017 | n 0 gt { |
|---|
| 3018 | % at this point only the n+1 items in the bottom of a remain to |
|---|
| 3019 | % the sorted largest item in that blocks is to be moved up into |
|---|
| 3020 | % position n |
|---|
| 3021 | n { |
|---|
| 3022 | 0 1 n 1 sub { |
|---|
| 3023 | /i exch def |
|---|
| 3024 | table i get table i 1 add get gt { |
|---|
| 3025 | % if a[i] > a[i+1] swap a[i] and a[i+1] |
|---|
| 3026 | table i 1 add |
|---|
| 3027 | table i get |
|---|
| 3028 | table i table i 1 add get |
|---|
| 3029 | % set new a[i] = old a[i+1] |
|---|
| 3030 | put |
|---|
| 3031 | % set new a[i+1] = old a[i] |
|---|
| 3032 | put |
|---|
| 3033 | |
|---|
| 3034 | indices i 1 add |
|---|
| 3035 | indices i get |
|---|
| 3036 | indices i indices i 1 add get |
|---|
| 3037 | % set new a[i] = old a[i+1] |
|---|
| 3038 | put |
|---|
| 3039 | % set new a[i+1] = old a[i] |
|---|
| 3040 | put |
|---|
| 3041 | } if |
|---|
| 3042 | } for |
|---|
| 3043 | /n n 1 sub def |
|---|
| 3044 | } repeat |
|---|
| 3045 | } if |
|---|
| 3046 | indices table |
|---|
| 3047 | end |
|---|
| 3048 | } def |
|---|
| 3049 | |
|---|
| 3050 | %%%%% ### quicksort ### |
|---|
| 3051 | %% src : http://www.math.ubc.ca/~cass/graphics/text/www/code/sort.inc |
|---|
| 3052 | %% code de Bill Casselman, modifie par jpv, 18/10/2007 |
|---|
| 3053 | |
|---|
| 3054 | /qsortdict 8 dict def |
|---|
| 3055 | |
|---|
| 3056 | qsortdict begin |
|---|
| 3057 | |
|---|
| 3058 | % args: /comp a L R x |
|---|
| 3059 | % effect: effects a partition into two pieces [L j] [i R] |
|---|
| 3060 | % leaves i j on stack |
|---|
| 3061 | |
|---|
| 3062 | /partition { 8 dict begin |
|---|
| 3063 | /x exch def |
|---|
| 3064 | /j exch def |
|---|
| 3065 | /i exch def |
|---|
| 3066 | /a exch def |
|---|
| 3067 | load /comp exch def |
|---|
| 3068 | { |
|---|
| 3069 | { |
|---|
| 3070 | a i get x comp exec not { |
|---|
| 3071 | exit |
|---|
| 3072 | } if |
|---|
| 3073 | /i i 1 add def |
|---|
| 3074 | } loop |
|---|
| 3075 | { |
|---|
| 3076 | x a j get comp exec not { |
|---|
| 3077 | exit |
|---|
| 3078 | } if |
|---|
| 3079 | /j j 1 sub def |
|---|
| 3080 | } loop |
|---|
| 3081 | |
|---|
| 3082 | i j le { |
|---|
| 3083 | % swap a[i] a[j] |
|---|
| 3084 | a j a i get |
|---|
| 3085 | a i a j get |
|---|
| 3086 | put put |
|---|
| 3087 | indices j indices i get |
|---|
| 3088 | indices i indices j get |
|---|
| 3089 | put put |
|---|
| 3090 | /i i 1 add def |
|---|
| 3091 | /j j 1 sub def |
|---|
| 3092 | } if |
|---|
| 3093 | i j gt { |
|---|
| 3094 | exit |
|---|
| 3095 | } if |
|---|
| 3096 | } loop |
|---|
| 3097 | i j |
|---|
| 3098 | end } def |
|---|
| 3099 | |
|---|
| 3100 | % args: /comp a L R |
|---|
| 3101 | % effect: sorts a[L .. R] according to comp |
|---|
| 3102 | |
|---|
| 3103 | /subsort { |
|---|
| 3104 | % /c a L R |
|---|
| 3105 | [ 3 1 roll ] 3 copy |
|---|
| 3106 | % /c a [L R] /c a [L R] |
|---|
| 3107 | aload aload pop |
|---|
| 3108 | % /c a [L R] /c a L R L R |
|---|
| 3109 | add 2 idiv |
|---|
| 3110 | % /c a [L R] /c a L R (L+R)/2 |
|---|
| 3111 | 3 index exch get |
|---|
| 3112 | % /c a [L R] /c a L R x |
|---|
| 3113 | partition |
|---|
| 3114 | % /c a [L R] i j |
|---|
| 3115 | % if j > L subsort(a, L, j) |
|---|
| 3116 | dup |
|---|
| 3117 | % /c a [L R] i j j |
|---|
| 3118 | 3 index 0 get gt { |
|---|
| 3119 | % /c a [L R] i j |
|---|
| 3120 | 5 copy |
|---|
| 3121 | % /c a [L R] i j /c a [L R] i j |
|---|
| 3122 | exch pop |
|---|
| 3123 | % /c a [L R] i j /c a [L R] j |
|---|
| 3124 | exch 0 get exch |
|---|
| 3125 | % ... /c a L j |
|---|
| 3126 | subsort |
|---|
| 3127 | } if |
|---|
| 3128 | % /c a [L R] i j |
|---|
| 3129 | pop dup |
|---|
| 3130 | % /c a [L R] i i |
|---|
| 3131 | % if i < R subsort(a, i, R) |
|---|
| 3132 | 2 index 1 get lt { |
|---|
| 3133 | % /c a [L R] i |
|---|
| 3134 | exch 1 get |
|---|
| 3135 | % /c a i R |
|---|
| 3136 | subsort |
|---|
| 3137 | }{ |
|---|
| 3138 | 4 { pop } repeat |
|---|
| 3139 | } ifelse |
|---|
| 3140 | } def |
|---|
| 3141 | |
|---|
| 3142 | end |
|---|
| 3143 | |
|---|
| 3144 | % args: /comp a |
|---|
| 3145 | % effect: sorts the array a |
|---|
| 3146 | % comp returns truth of x < y for entries in a |
|---|
| 3147 | |
|---|
| 3148 | /quicksort { qsortdict begin |
|---|
| 3149 | dup length 1 gt { |
|---|
| 3150 | % /comp a |
|---|
| 3151 | dup |
|---|
| 3152 | % /comp a a |
|---|
| 3153 | length 1 sub |
|---|
| 3154 | % /comp a n-1 |
|---|
| 3155 | 0 exch subsort |
|---|
| 3156 | } { |
|---|
| 3157 | pop pop |
|---|
| 3158 | } ifelse |
|---|
| 3159 | end } def |
|---|
| 3160 | |
|---|
| 3161 | % ---------------------------------------- |
|---|
| 3162 | |
|---|
| 3163 | %% fin du code de Bill Casselman |
|---|
| 3164 | |
|---|
| 3165 | %% syntaxe : array1 doublebubblesort --> array2 array3, array3 est |
|---|
| 3166 | %% trie par ordre croissant et array2 correspond a la position des |
|---|
| 3167 | %% indices de depart, ie si array1 = [3 2 4 1], alors array2 = [3 1 0 2] |
|---|
| 3168 | %% code de Bill Casselman, modifie par jpv, 18/10/2007 |
|---|
| 3169 | %% http://www.math.ubc.ca/people/faculty/cass/graphics/text/www/ |
|---|
| 3170 | /doublequicksort { |
|---|
| 3171 | qsortdict begin |
|---|
| 3172 | /comp exch |
|---|
| 3173 | /a exch def |
|---|
| 3174 | a dup length /n exch def |
|---|
| 3175 | /indices [0 1 n 1 sub {} for ] def |
|---|
| 3176 | dup length 1 gt { |
|---|
| 3177 | % /comp a |
|---|
| 3178 | dup |
|---|
| 3179 | % /comp a a |
|---|
| 3180 | length 1 sub |
|---|
| 3181 | % /comp a n-1 |
|---|
| 3182 | 0 exch subsort |
|---|
| 3183 | } { |
|---|
| 3184 | pop pop |
|---|
| 3185 | } ifelse |
|---|
| 3186 | indices a |
|---|
| 3187 | end |
|---|
| 3188 | } def |
|---|
| 3189 | |
|---|
| 3190 | /comp {lt} def |
|---|
| 3191 | |
|---|
| 3192 | %%%%% ### apply ### |
|---|
| 3193 | %% syntaxe : [x1 ... xn] (f) apply --> [f(x1) ... f(xn)] |
|---|
| 3194 | /apply { |
|---|
| 3195 | 3 dict begin |
|---|
| 3196 | dup isstring |
|---|
| 3197 | {/fonction exch cvx def} |
|---|
| 3198 | {/fonction exch def} |
|---|
| 3199 | ifelse |
|---|
| 3200 | /liste exch def |
|---|
| 3201 | /@i 0 def |
|---|
| 3202 | [ |
|---|
| 3203 | liste length { |
|---|
| 3204 | liste @i get fonction |
|---|
| 3205 | /@i @i 1 add store |
|---|
| 3206 | } repeat |
|---|
| 3207 | counttomark |
|---|
| 3208 | 0 eq |
|---|
| 3209 | {pop} |
|---|
| 3210 | {]} |
|---|
| 3211 | ifelse |
|---|
| 3212 | end |
|---|
| 3213 | } def |
|---|
| 3214 | |
|---|
| 3215 | %% syntaxe : [x1 ... xn] (f) papply |
|---|
| 3216 | /papply { |
|---|
| 3217 | 3 dict begin |
|---|
| 3218 | dup isstring |
|---|
| 3219 | {/fonction exch cvx def} |
|---|
| 3220 | {/fonction exch def} |
|---|
| 3221 | ifelse |
|---|
| 3222 | /liste exch def |
|---|
| 3223 | /@i 0 def |
|---|
| 3224 | [ |
|---|
| 3225 | liste length 2 idiv { |
|---|
| 3226 | liste @i get |
|---|
| 3227 | liste @i 1 add get |
|---|
| 3228 | fonction |
|---|
| 3229 | /@i @i 2 add store |
|---|
| 3230 | } repeat |
|---|
| 3231 | counttomark |
|---|
| 3232 | 0 eq |
|---|
| 3233 | {pop} |
|---|
| 3234 | {]} |
|---|
| 3235 | ifelse |
|---|
| 3236 | end |
|---|
| 3237 | } def |
|---|
| 3238 | |
|---|
| 3239 | %% syntaxe : [x1 ... xn] (f) capply |
|---|
| 3240 | /capply { |
|---|
| 3241 | 3 dict begin |
|---|
| 3242 | dup isstring |
|---|
| 3243 | {/fonction exch cvx def} |
|---|
| 3244 | {/fonction exch def} |
|---|
| 3245 | ifelse |
|---|
| 3246 | /liste exch def |
|---|
| 3247 | /@i 0 def |
|---|
| 3248 | [ |
|---|
| 3249 | liste length 3 idiv { |
|---|
| 3250 | liste @i get |
|---|
| 3251 | liste @i 1 add get |
|---|
| 3252 | liste @i 2 add get |
|---|
| 3253 | fonction |
|---|
| 3254 | /@i @i 3 add store |
|---|
| 3255 | } repeat |
|---|
| 3256 | counttomark |
|---|
| 3257 | 0 eq |
|---|
| 3258 | {pop} |
|---|
| 3259 | {]} |
|---|
| 3260 | ifelse |
|---|
| 3261 | end |
|---|
| 3262 | } def |
|---|
| 3263 | |
|---|
| 3264 | %%%%% ### reverse ### |
|---|
| 3265 | %% syntaxe : array reverse --> inverse l ordre des items dans |
|---|
| 3266 | %% le tableau |
|---|
| 3267 | /reverse { |
|---|
| 3268 | 3 dict begin |
|---|
| 3269 | /le_tableau exch def |
|---|
| 3270 | /n le_tableau length def |
|---|
| 3271 | /i n 1 sub def |
|---|
| 3272 | [ |
|---|
| 3273 | n { |
|---|
| 3274 | le_tableau i get |
|---|
| 3275 | /i i 1 sub store |
|---|
| 3276 | } repeat |
|---|
| 3277 | ] |
|---|
| 3278 | end |
|---|
| 3279 | } def |
|---|
| 3280 | |
|---|
| 3281 | %% syntaxe : array_points reversep --> inverse l ordre des points dans |
|---|
| 3282 | %% le tableau |
|---|
| 3283 | /reversep { |
|---|
| 3284 | 3 dict begin |
|---|
| 3285 | /le_tableau exch def |
|---|
| 3286 | /n le_tableau length 2 idiv def |
|---|
| 3287 | /i n 1 sub def |
|---|
| 3288 | [ |
|---|
| 3289 | n { |
|---|
| 3290 | le_tableau i getp |
|---|
| 3291 | /i i 1 sub store |
|---|
| 3292 | } repeat |
|---|
| 3293 | ] |
|---|
| 3294 | end |
|---|
| 3295 | } def |
|---|
| 3296 | |
|---|
| 3297 | %%%%% ### get ### |
|---|
| 3298 | %% syntaxe : array_points n getp --> le n-ieme point du tableau de |
|---|
| 3299 | %% points array_points |
|---|
| 3300 | /getp { |
|---|
| 3301 | 2 copy |
|---|
| 3302 | 2 mul get |
|---|
| 3303 | 3 1 roll |
|---|
| 3304 | 2 mul 1 add get |
|---|
| 3305 | } def |
|---|
| 3306 | |
|---|
| 3307 | %%%%% ### fin insertion ### |
|---|
| 3308 | |
|---|
| 3309 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3310 | %%%% matrices %%%% |
|---|
| 3311 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3312 | |
|---|
| 3313 | %%%%% ### linear ### |
|---|
| 3314 | %% syntaxe : M i j any --> depose any dans M en a_ij |
|---|
| 3315 | /put_ij { |
|---|
| 3316 | 5 dict begin |
|---|
| 3317 | /a exch def |
|---|
| 3318 | /j exch def |
|---|
| 3319 | /i exch def |
|---|
| 3320 | /M exch def |
|---|
| 3321 | /L M i get_Li def |
|---|
| 3322 | L j a put |
|---|
| 3323 | M i L put_Li |
|---|
| 3324 | end |
|---|
| 3325 | } def |
|---|
| 3326 | |
|---|
| 3327 | %% syntaxe : M i j get_ij --> le coeff c_ij |
|---|
| 3328 | /get_ij { |
|---|
| 3329 | 3 1 roll %% j M i |
|---|
| 3330 | get_Li %% j L_i |
|---|
| 3331 | exch get |
|---|
| 3332 | } def |
|---|
| 3333 | |
|---|
| 3334 | %% syntaxe : M i L put_Li --> remplace dans M la ligne Li par L |
|---|
| 3335 | /put_Li { |
|---|
| 3336 | put |
|---|
| 3337 | } def |
|---|
| 3338 | |
|---|
| 3339 | %% syntaxe : M i get_Li --> la ligne Li de M |
|---|
| 3340 | /get_Li { |
|---|
| 3341 | get |
|---|
| 3342 | } def |
|---|
| 3343 | |
|---|
| 3344 | %%%%% ### fin insertion ### |
|---|
| 3345 | |
|---|
| 3346 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3347 | %%%% geometrie 3d (calculs) %%%% |
|---|
| 3348 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3349 | |
|---|
| 3350 | %%%%% ### p3dtoplane ### |
|---|
| 3351 | %% syntaxe : x y z P p3dtoplane --> X Y |
|---|
| 3352 | /p3dtoplane { |
|---|
| 3353 | 5 dict begin |
|---|
| 3354 | /leplan exch def |
|---|
| 3355 | /M defpoint3d |
|---|
| 3356 | leplan plangetbase 0 getp3d /U defpoint3d |
|---|
| 3357 | leplan plangetbase 1 getp3d /V defpoint3d |
|---|
| 3358 | leplan plangetorigine /I defpoint3d |
|---|
| 3359 | I M vecteur3d U scalprod3d |
|---|
| 3360 | I M vecteur3d V scalprod3d |
|---|
| 3361 | end |
|---|
| 3362 | } def |
|---|
| 3363 | |
|---|
| 3364 | %%%%% ### pplaneto3d ### |
|---|
| 3365 | %% syntaxe : x y P pplaneto3d --> X Y Z |
|---|
| 3366 | /pplaneto3d { |
|---|
| 3367 | 6 dict begin |
|---|
| 3368 | /leplan exch def |
|---|
| 3369 | /y exch def |
|---|
| 3370 | /x exch def |
|---|
| 3371 | leplan plangetbase 0 getp3d /U defpoint3d |
|---|
| 3372 | leplan plangetbase 1 getp3d /V defpoint3d |
|---|
| 3373 | leplan plangetorigine /I defpoint3d |
|---|
| 3374 | U x mulv3d |
|---|
| 3375 | V y mulv3d addv3d |
|---|
| 3376 | I addv3d |
|---|
| 3377 | end |
|---|
| 3378 | } def |
|---|
| 3379 | |
|---|
| 3380 | %%%%% ### orthoprojplane3d ### |
|---|
| 3381 | %% Projection orthogonale d'un point 3d sur un plan |
|---|
| 3382 | %% Mx My Mz (=le point a projeter) |
|---|
| 3383 | %% Ax Ay Az (=un point du plan) |
|---|
| 3384 | %% Vx Vy Vz (un vecteur normal au plan) |
|---|
| 3385 | /orthoprojplane3d { |
|---|
| 3386 | 4 dict begin |
|---|
| 3387 | dup isplan { |
|---|
| 3388 | /monplan exch def |
|---|
| 3389 | monplan plangetorigine |
|---|
| 3390 | monplan plangetbase aload pop vectprod3d |
|---|
| 3391 | } if |
|---|
| 3392 | /V defpoint3d |
|---|
| 3393 | /A defpoint3d |
|---|
| 3394 | /M defpoint3d |
|---|
| 3395 | /VN {V unitaire3d} def |
|---|
| 3396 | VN M A vecteur3d VN scalprod3d mulv3d |
|---|
| 3397 | M addv3d |
|---|
| 3398 | end |
|---|
| 3399 | } def |
|---|
| 3400 | |
|---|
| 3401 | %%%%% ### sortp3d ### |
|---|
| 3402 | /sortp3d { |
|---|
| 3403 | 6 dict begin |
|---|
| 3404 | /M1 defpoint3d |
|---|
| 3405 | /M0 defpoint3d |
|---|
| 3406 | M1 |
|---|
| 3407 | /z1 exch def |
|---|
| 3408 | /y1 exch def |
|---|
| 3409 | /x1 exch def |
|---|
| 3410 | M0 |
|---|
| 3411 | /z0 exch def |
|---|
| 3412 | /y0 exch def |
|---|
| 3413 | /x0 exch def |
|---|
| 3414 | x0 x1 lt { |
|---|
| 3415 | M0 M1 |
|---|
| 3416 | } { |
|---|
| 3417 | x0 x1 gt { |
|---|
| 3418 | M1 M0 |
|---|
| 3419 | } { |
|---|
| 3420 | y0 y1 lt { |
|---|
| 3421 | M0 M1 |
|---|
| 3422 | } { |
|---|
| 3423 | y0 y1 gt { |
|---|
| 3424 | M1 M0 |
|---|
| 3425 | } { |
|---|
| 3426 | z0 z1 lt { |
|---|
| 3427 | M0 M1 |
|---|
| 3428 | } { |
|---|
| 3429 | M1 M0 |
|---|
| 3430 | } ifelse |
|---|
| 3431 | } ifelse |
|---|
| 3432 | } ifelse |
|---|
| 3433 | } ifelse |
|---|
| 3434 | } ifelse |
|---|
| 3435 | end |
|---|
| 3436 | } def |
|---|
| 3437 | |
|---|
| 3438 | %%%%% ### dupp3d ### |
|---|
| 3439 | %% duplique le vecteur 3d |
|---|
| 3440 | /dupp3d { %% x y z |
|---|
| 3441 | 3 copy |
|---|
| 3442 | } def |
|---|
| 3443 | /dupv3d {dupp3d} def |
|---|
| 3444 | |
|---|
| 3445 | %%%%% ### angle3d ### |
|---|
| 3446 | %% syntaxe : vect1 vect2 angle3d |
|---|
| 3447 | /angle3d { |
|---|
| 3448 | 4 dict begin |
|---|
| 3449 | normalize3d /vect2 defpoint3d |
|---|
| 3450 | normalize3d /vect1 defpoint3d |
|---|
| 3451 | /cosalpha vect1 vect2 scalprod3d def |
|---|
| 3452 | /sinalpha vect1 vect2 vectprod3d norme3d def |
|---|
| 3453 | sinalpha cosalpha atan |
|---|
| 3454 | end |
|---|
| 3455 | } def |
|---|
| 3456 | |
|---|
| 3457 | %%%%% ### transformpoint3d ### |
|---|
| 3458 | %% syntaxe : x y z a11 a21 a31 a12 a22 a32 a13 a23 a33 |
|---|
| 3459 | %% transformpoint3d -> X Y Z |
|---|
| 3460 | /transformpoint3d { |
|---|
| 3461 | 12 dict begin |
|---|
| 3462 | /a33 exch def |
|---|
| 3463 | /a23 exch def |
|---|
| 3464 | /a13 exch def |
|---|
| 3465 | /a32 exch def |
|---|
| 3466 | /a22 exch def |
|---|
| 3467 | /a12 exch def |
|---|
| 3468 | /a31 exch def |
|---|
| 3469 | /a21 exch def |
|---|
| 3470 | /a11 exch def |
|---|
| 3471 | /z exch def |
|---|
| 3472 | /y exch def |
|---|
| 3473 | /x exch def |
|---|
| 3474 | a11 x mul a12 y mul add a13 z mul add |
|---|
| 3475 | a21 x mul a22 y mul add a23 z mul add |
|---|
| 3476 | a31 x mul a32 y mul add a33 z mul add |
|---|
| 3477 | end |
|---|
| 3478 | } def |
|---|
| 3479 | |
|---|
| 3480 | %%%%% ### normalize3d ### |
|---|
| 3481 | %% rend le vecteur 3d unitaire. Ne fait rien si u=0 |
|---|
| 3482 | /unitaire3d { %% x y z |
|---|
| 3483 | 2 dict begin |
|---|
| 3484 | /u defpoint3d |
|---|
| 3485 | /norme u norme3d def |
|---|
| 3486 | norme 0 eq { |
|---|
| 3487 | u |
|---|
| 3488 | } { |
|---|
| 3489 | u 1 norme div mulv3d |
|---|
| 3490 | } ifelse |
|---|
| 3491 | end |
|---|
| 3492 | } def |
|---|
| 3493 | /normalize3d {unitaire3d} def |
|---|
| 3494 | |
|---|
| 3495 | %%%%% ### geom3d ### |
|---|
| 3496 | %% syntaxe : A k1 B k2 barycentre3d -> G, barycentre du systeme |
|---|
| 3497 | %% [(A, k1) (B, k2)] |
|---|
| 3498 | /barycentre3d { |
|---|
| 3499 | 4 dict begin |
|---|
| 3500 | /k2 exch def |
|---|
| 3501 | /B defpoint3d |
|---|
| 3502 | /k1 exch def |
|---|
| 3503 | /A defpoint3d |
|---|
| 3504 | A k1 mulv3d |
|---|
| 3505 | B k2 mulv3d |
|---|
| 3506 | addv3d |
|---|
| 3507 | 1 k1 k2 add div mulv3d |
|---|
| 3508 | end |
|---|
| 3509 | } def |
|---|
| 3510 | |
|---|
| 3511 | %% syntaxe : array isobarycentre3d --> G |
|---|
| 3512 | /isobarycentre3d { |
|---|
| 3513 | 2 dict begin |
|---|
| 3514 | /table exch def |
|---|
| 3515 | /n table length 3 idiv def |
|---|
| 3516 | table 0 getp3d |
|---|
| 3517 | 1 1 n 1 sub { |
|---|
| 3518 | table exch getp3d |
|---|
| 3519 | addv3d |
|---|
| 3520 | } for |
|---|
| 3521 | 1 n div mulv3d |
|---|
| 3522 | end |
|---|
| 3523 | } def |
|---|
| 3524 | |
|---|
| 3525 | %% syntaxe : M A alpha hompoint3d -> le point M' tel que AM' = alpha AM |
|---|
| 3526 | /hompoint3d { |
|---|
| 3527 | 3 dict begin |
|---|
| 3528 | /alpha exch def |
|---|
| 3529 | /A defpoint3d |
|---|
| 3530 | /M defpoint3d |
|---|
| 3531 | A M vecteur3d alpha mulv3d A addv3d |
|---|
| 3532 | end |
|---|
| 3533 | } def |
|---|
| 3534 | |
|---|
| 3535 | %% syntaxe : M A sympoint3d -> le point M' tel que AM' = -AM |
|---|
| 3536 | /sympoint3d { |
|---|
| 3537 | 2 dict begin |
|---|
| 3538 | /A defpoint3d |
|---|
| 3539 | /M defpoint3d |
|---|
| 3540 | A M vecteur3d -1 mulv3d A addv3d |
|---|
| 3541 | end |
|---|
| 3542 | } def |
|---|
| 3543 | |
|---|
| 3544 | %% syntaxe : A u translatepoint3d --> B image de A par la translation de vecteur u |
|---|
| 3545 | /translatepoint3d { |
|---|
| 3546 | addv3d |
|---|
| 3547 | } def |
|---|
| 3548 | |
|---|
| 3549 | /scaleOpoint3d { |
|---|
| 3550 | 6 dict begin |
|---|
| 3551 | /k3 exch def |
|---|
| 3552 | /k2 exch def |
|---|
| 3553 | /k1 exch def |
|---|
| 3554 | /z exch def |
|---|
| 3555 | /y exch def |
|---|
| 3556 | /x exch def |
|---|
| 3557 | k1 x mul |
|---|
| 3558 | k2 y mul |
|---|
| 3559 | k3 z mul |
|---|
| 3560 | end |
|---|
| 3561 | } def |
|---|
| 3562 | |
|---|
| 3563 | % syntaxe : M alpha_x alpha_y alpha_z rotateOpoint3d --> M' |
|---|
| 3564 | /rotateOpoint3d { |
|---|
| 3565 | 21 dict begin |
|---|
| 3566 | /RotZ exch def |
|---|
| 3567 | /RotY exch def |
|---|
| 3568 | /RotX exch def |
|---|
| 3569 | /Zpoint exch def |
|---|
| 3570 | /Ypoint exch def |
|---|
| 3571 | /Xpoint exch def |
|---|
| 3572 | /c1 {RotX cos} bind def |
|---|
| 3573 | /c2 {RotY cos} bind def |
|---|
| 3574 | /c3 {RotZ cos} bind def |
|---|
| 3575 | /s1 {RotX sin} bind def |
|---|
| 3576 | /s2 {RotY sin} bind def |
|---|
| 3577 | /s3 {RotZ sin} bind def |
|---|
| 3578 | /M11 {c2 c3 mul} bind def |
|---|
| 3579 | /M12 {c3 s1 mul s2 mul c1 s3 mul sub} bind def |
|---|
| 3580 | /M13 {c1 c3 mul s2 mul s1 s3 mul add} bind def |
|---|
| 3581 | /M21 {c2 s3 mul} bind def |
|---|
| 3582 | /M22 {s1 s2 mul s3 mul c1 c3 mul add} bind def |
|---|
| 3583 | /M23 {s3 s2 mul c1 mul c3 s1 mul sub} bind def |
|---|
| 3584 | /M31 {s2 neg} bind def |
|---|
| 3585 | /M32 {s1 c2 mul} bind def |
|---|
| 3586 | /M33 {c1 c2 mul} bind def |
|---|
| 3587 | M11 Xpoint mul M12 Ypoint mul add M13 Zpoint mul add |
|---|
| 3588 | M21 Xpoint mul M22 Ypoint mul add M23 Zpoint mul add |
|---|
| 3589 | M31 Xpoint mul M32 Ypoint mul add M33 Zpoint mul add |
|---|
| 3590 | end |
|---|
| 3591 | } def |
|---|
| 3592 | |
|---|
| 3593 | %%%%% ### symplan3d ### |
|---|
| 3594 | %% syntaxe : M eqplan/plantype symplan3d --> M' |
|---|
| 3595 | %% ou M' symetrique de M par rapport au plan P defini par eqplan/plantype |
|---|
| 3596 | /symplan3d { |
|---|
| 3597 | 13 dict begin |
|---|
| 3598 | dup isplan { |
|---|
| 3599 | plan2eq /args exch def |
|---|
| 3600 | } { |
|---|
| 3601 | /args exch def |
|---|
| 3602 | } ifelse |
|---|
| 3603 | /z exch def |
|---|
| 3604 | /y exch def |
|---|
| 3605 | /x exch def |
|---|
| 3606 | args aload pop |
|---|
| 3607 | /d1 exch def |
|---|
| 3608 | /c1 exch def |
|---|
| 3609 | /b1 exch def |
|---|
| 3610 | /a1 exch def |
|---|
| 3611 | /n_U a1 dup mul b1 dup mul add c1 dup mul add sqrt def |
|---|
| 3612 | /a a1 n_U div def |
|---|
| 3613 | /b b1 n_U div def |
|---|
| 3614 | /c c1 n_U div def |
|---|
| 3615 | /d d1 n_U div def |
|---|
| 3616 | /u a x mul b y mul add c z mul add d add def |
|---|
| 3617 | x 2 a mul u mul sub |
|---|
| 3618 | y 2 b mul u mul sub |
|---|
| 3619 | z 2 c mul u mul sub |
|---|
| 3620 | end |
|---|
| 3621 | } def |
|---|
| 3622 | |
|---|
| 3623 | %%%%% ### vecteur3d ### |
|---|
| 3624 | %% creation du vecteur AB a partir de A et B |
|---|
| 3625 | /vecteur3d { %% xA yA zA xB yB zB |
|---|
| 3626 | 6 dict begin |
|---|
| 3627 | /zB exch def |
|---|
| 3628 | /yB exch def |
|---|
| 3629 | /xB exch def |
|---|
| 3630 | /zA exch def |
|---|
| 3631 | /yA exch def |
|---|
| 3632 | /xA exch def |
|---|
| 3633 | xB xA sub |
|---|
| 3634 | yB yA sub |
|---|
| 3635 | zB zA sub |
|---|
| 3636 | end |
|---|
| 3637 | }def |
|---|
| 3638 | |
|---|
| 3639 | %%%%% ### vectprod3d ### |
|---|
| 3640 | %% produit vectoriel de deux vecteurs 3d |
|---|
| 3641 | /vectprod3d { %% x1 y1 z1 x2 y2 z2 |
|---|
| 3642 | 6 dict begin |
|---|
| 3643 | /zp exch def |
|---|
| 3644 | /yp exch def |
|---|
| 3645 | /xp exch def |
|---|
| 3646 | /z exch def |
|---|
| 3647 | /y exch def |
|---|
| 3648 | /x exch def |
|---|
| 3649 | y zp mul z yp mul sub |
|---|
| 3650 | z xp mul x zp mul sub |
|---|
| 3651 | x yp mul y xp mul sub |
|---|
| 3652 | end |
|---|
| 3653 | } def |
|---|
| 3654 | |
|---|
| 3655 | %%%%% ### scalprod3d ### |
|---|
| 3656 | %% produit scalaire de deux vecteurs 3d |
|---|
| 3657 | /scalprod3d { %% x1 y1 z1 x2 y2 z2 |
|---|
| 3658 | 6 dict begin |
|---|
| 3659 | /zp exch def |
|---|
| 3660 | /yp exch def |
|---|
| 3661 | /xp exch def |
|---|
| 3662 | /z exch def |
|---|
| 3663 | /y exch def |
|---|
| 3664 | /x exch def |
|---|
| 3665 | x xp mul y yp mul add z zp mul add |
|---|
| 3666 | end |
|---|
| 3667 | } def |
|---|
| 3668 | |
|---|
| 3669 | %%%%% ### papply3d ### |
|---|
| 3670 | %% syntaxe : [A1 ... An] (f) papply3d --> [f(A1) ... f(An)] |
|---|
| 3671 | /papply3d { |
|---|
| 3672 | 3 dict begin |
|---|
| 3673 | /fonction exch def |
|---|
| 3674 | /liste exch def |
|---|
| 3675 | /i 0 def |
|---|
| 3676 | [ |
|---|
| 3677 | liste length 3 idiv { |
|---|
| 3678 | liste i get |
|---|
| 3679 | liste i 1 add get |
|---|
| 3680 | liste i 2 add get |
|---|
| 3681 | fonction |
|---|
| 3682 | /i i 3 add store |
|---|
| 3683 | } repeat |
|---|
| 3684 | counttomark |
|---|
| 3685 | 0 eq |
|---|
| 3686 | {pop} |
|---|
| 3687 | {]} |
|---|
| 3688 | ifelse |
|---|
| 3689 | end |
|---|
| 3690 | } def |
|---|
| 3691 | |
|---|
| 3692 | %%%%% ### defpoint3d ### |
|---|
| 3693 | %% creation du point A a partir de xA yA yB et du nom /A |
|---|
| 3694 | /defpoint3d { %% xA yA zA /nom |
|---|
| 3695 | 1 dict begin |
|---|
| 3696 | /memo exch def |
|---|
| 3697 | [ 4 1 roll ] cvx memo exch |
|---|
| 3698 | end def |
|---|
| 3699 | }def |
|---|
| 3700 | |
|---|
| 3701 | %%%%% ### distance3d ### |
|---|
| 3702 | /distance3d { %% A B |
|---|
| 3703 | vecteur3d norme3d |
|---|
| 3704 | } def |
|---|
| 3705 | |
|---|
| 3706 | %%%%% ### get3d ### |
|---|
| 3707 | /getp3d { %% [tableau de points 3d] i --> donne le ieme point du tableau |
|---|
| 3708 | 2 copy 2 copy |
|---|
| 3709 | 3 mul get |
|---|
| 3710 | 5 1 roll |
|---|
| 3711 | 3 mul 1 add get |
|---|
| 3712 | 3 1 roll |
|---|
| 3713 | 3 mul 2 add get |
|---|
| 3714 | } def |
|---|
| 3715 | |
|---|
| 3716 | %%%%% ### norme3d ### |
|---|
| 3717 | %% norme d un vecteur 3d |
|---|
| 3718 | /norme3d { %% x y z |
|---|
| 3719 | 3 dict begin |
|---|
| 3720 | /z exch def |
|---|
| 3721 | /y exch def |
|---|
| 3722 | /x exch def |
|---|
| 3723 | x dup mul y dup mul add z dup mul add sqrt |
|---|
| 3724 | end |
|---|
| 3725 | } def |
|---|
| 3726 | |
|---|
| 3727 | %%%%% ### mulv3d ### |
|---|
| 3728 | %% (scalaire)*(vecteur 3d) Attention : dans l autre sens ! |
|---|
| 3729 | /mulv3d { %% x y z lambda |
|---|
| 3730 | 4 dict begin |
|---|
| 3731 | /lambda exch def |
|---|
| 3732 | /z exch def |
|---|
| 3733 | /y exch def |
|---|
| 3734 | /x exch def |
|---|
| 3735 | x lambda mul |
|---|
| 3736 | y lambda mul |
|---|
| 3737 | z lambda mul |
|---|
| 3738 | end |
|---|
| 3739 | } def |
|---|
| 3740 | |
|---|
| 3741 | %%%%% ### addv3d ### |
|---|
| 3742 | %% addition de deux vecteurs 3d |
|---|
| 3743 | /addv3d { %% x1 y1 z1 x2 y2 z2 |
|---|
| 3744 | 6 dict begin |
|---|
| 3745 | /zp exch def |
|---|
| 3746 | /yp exch def |
|---|
| 3747 | /xp exch def |
|---|
| 3748 | /z exch def |
|---|
| 3749 | /y exch def |
|---|
| 3750 | /x exch def |
|---|
| 3751 | x xp add |
|---|
| 3752 | y yp add |
|---|
| 3753 | z zp add |
|---|
| 3754 | end |
|---|
| 3755 | } def |
|---|
| 3756 | |
|---|
| 3757 | %%%%% ### milieu3d ### |
|---|
| 3758 | /milieu3d { %% A B --> I le milieu de [AB] |
|---|
| 3759 | addv3d 0.5 mulv3d |
|---|
| 3760 | } def |
|---|
| 3761 | |
|---|
| 3762 | %%%%% ### exch ### |
|---|
| 3763 | /exchp { |
|---|
| 3764 | 4 -1 roll |
|---|
| 3765 | 4 -1 roll |
|---|
| 3766 | } def |
|---|
| 3767 | /exchc { |
|---|
| 3768 | 6 -1 roll |
|---|
| 3769 | 6 -1 roll |
|---|
| 3770 | 6 -1 roll |
|---|
| 3771 | } def |
|---|
| 3772 | /exchd { |
|---|
| 3773 | 4 {8 -1 roll} repeat |
|---|
| 3774 | } def |
|---|
| 3775 | /exchp3d { |
|---|
| 3776 | 6 -1 roll |
|---|
| 3777 | 6 -1 roll |
|---|
| 3778 | 6 -1 roll |
|---|
| 3779 | } def |
|---|
| 3780 | |
|---|
| 3781 | %%%%% ### ABpoint3d ### |
|---|
| 3782 | %% syntaxe : A B k ABpoint3d --> M |
|---|
| 3783 | %% M tel que vect(AM) = k vect (AB) |
|---|
| 3784 | /ABpoint3d { |
|---|
| 3785 | 3 dict begin |
|---|
| 3786 | /k exch def |
|---|
| 3787 | /B defpoint3d |
|---|
| 3788 | /A defpoint3d |
|---|
| 3789 | A B vecteur3d |
|---|
| 3790 | k mulv3d |
|---|
| 3791 | A addv3d |
|---|
| 3792 | end |
|---|
| 3793 | } def |
|---|
| 3794 | |
|---|
| 3795 | %%%%% ### angle3doriente ### |
|---|
| 3796 | %% syntaxe : vect1 vect2 vect3 angle3d |
|---|
| 3797 | %% vect3 est la normale au plan (vect1, vect2) |
|---|
| 3798 | /angle3doriente { |
|---|
| 3799 | 4 dict begin |
|---|
| 3800 | normalize3d /vect3 defpoint3d |
|---|
| 3801 | normalize3d /vect2 defpoint3d |
|---|
| 3802 | normalize3d /vect1 defpoint3d |
|---|
| 3803 | /cosalpha vect1 vect2 scalprod3d def |
|---|
| 3804 | /sinalpha vect1 vect2 vectprod3d vect3 scalprod3d def |
|---|
| 3805 | sinalpha cosalpha atan |
|---|
| 3806 | end |
|---|
| 3807 | } def |
|---|
| 3808 | |
|---|
| 3809 | %%%%% ### points3dalignes ### |
|---|
| 3810 | %% syntaxe : A B C points3dalignes -> bool |
|---|
| 3811 | /points3dalignes { |
|---|
| 3812 | 3 dict begin |
|---|
| 3813 | /C defpoint3d |
|---|
| 3814 | /B defpoint3d |
|---|
| 3815 | /A defpoint3d |
|---|
| 3816 | A B vecteur3d /u defpoint3d |
|---|
| 3817 | A C vecteur3d /v defpoint3d |
|---|
| 3818 | u v vectprod3d norme3d 1E-7 lt |
|---|
| 3819 | end |
|---|
| 3820 | } def |
|---|
| 3821 | |
|---|
| 3822 | %% syntaxe : M A B point3dsursegment --> true si M in [AB], false sinon |
|---|
| 3823 | /point3dsursegment { |
|---|
| 3824 | 3 dict begin |
|---|
| 3825 | /B defpoint3d |
|---|
| 3826 | /A defpoint3d |
|---|
| 3827 | /M defpoint3d |
|---|
| 3828 | M A B points3dalignes { |
|---|
| 3829 | M A vecteur3d |
|---|
| 3830 | M B vecteur3d |
|---|
| 3831 | scalprod3d 0 lt { |
|---|
| 3832 | true |
|---|
| 3833 | } { |
|---|
| 3834 | false |
|---|
| 3835 | } ifelse |
|---|
| 3836 | } { |
|---|
| 3837 | false |
|---|
| 3838 | } ifelse |
|---|
| 3839 | end |
|---|
| 3840 | } def |
|---|
| 3841 | |
|---|
| 3842 | %%%%% ### fin insertion ### |
|---|
| 3843 | |
|---|
| 3844 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3845 | %%%% geometrie 3d (dessins) %%%% |
|---|
| 3846 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3847 | |
|---|
| 3848 | %%%%% ### point3d ### |
|---|
| 3849 | /point3d { %% A |
|---|
| 3850 | 3dto2d point |
|---|
| 3851 | } def |
|---|
| 3852 | |
|---|
| 3853 | /points3d { %% tableau de points3d |
|---|
| 3854 | tab3dto2d points |
|---|
| 3855 | } def |
|---|
| 3856 | |
|---|
| 3857 | %%%%% ### ligne3d ### |
|---|
| 3858 | %% [tableau de points3d] option --> trace la ligne brisee |
|---|
| 3859 | /ligne3d { |
|---|
| 3860 | 1 dict begin |
|---|
| 3861 | dup isstring |
|---|
| 3862 | {/option exch def} |
|---|
| 3863 | if |
|---|
| 3864 | tab3dto2d |
|---|
| 3865 | currentdict /option known |
|---|
| 3866 | {option} |
|---|
| 3867 | if |
|---|
| 3868 | ligne |
|---|
| 3869 | end |
|---|
| 3870 | } def |
|---|
| 3871 | |
|---|
| 3872 | %% [tableau de points3d] option --> trace la ligne brisee |
|---|
| 3873 | /ligne3d_ { |
|---|
| 3874 | 1 dict begin |
|---|
| 3875 | dup isstring |
|---|
| 3876 | {/option exch def} |
|---|
| 3877 | if |
|---|
| 3878 | tab3dto2d |
|---|
| 3879 | currentdict /option known |
|---|
| 3880 | {option} |
|---|
| 3881 | if |
|---|
| 3882 | ligne_ |
|---|
| 3883 | end |
|---|
| 3884 | } def |
|---|
| 3885 | |
|---|
| 3886 | %%%%% ### tab3dto2d ### |
|---|
| 3887 | %% transforme un tableau de points 3d en tableau de points 2d |
|---|
| 3888 | /tab3dto2d { |
|---|
| 3889 | 2 dict begin |
|---|
| 3890 | /T exch def |
|---|
| 3891 | /n T length def |
|---|
| 3892 | [ T aload pop |
|---|
| 3893 | n 1 sub -1 n 3 idiv 2 mul |
|---|
| 3894 | { 1 dict begin |
|---|
| 3895 | /i exch def |
|---|
| 3896 | 3dto2d i 2 roll |
|---|
| 3897 | end } for ] |
|---|
| 3898 | end |
|---|
| 3899 | } def |
|---|
| 3900 | |
|---|
| 3901 | %%%%% ### polygone3d ### |
|---|
| 3902 | /polygone3d { %% tableau de points3d |
|---|
| 3903 | tab3dto2d polygone |
|---|
| 3904 | } def |
|---|
| 3905 | |
|---|
| 3906 | /polygone3d* { %% tableau de points3d |
|---|
| 3907 | tab3dto2d polygone* |
|---|
| 3908 | } def |
|---|
| 3909 | |
|---|
| 3910 | %%%%% ### fin insertion ### |
|---|
| 3911 | |
|---|
| 3912 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3913 | %%%% gestion du texte %%%% |
|---|
| 3914 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 3915 | |
|---|
| 3916 | %%%%% ### marks ### |
|---|
| 3917 | /xmkstep 1 def % les marques sur Ox |
|---|
| 3918 | /xmarkstyle {dctext} def |
|---|
| 3919 | /ymarkstyle {(-1 0) bltext} def |
|---|
| 3920 | /setxmkstep { |
|---|
| 3921 | /xmkstep exch def |
|---|
| 3922 | } def |
|---|
| 3923 | /xmark { |
|---|
| 3924 | dup xtick |
|---|
| 3925 | /Courier findfont .8 fontsize mul scalefont setfont |
|---|
| 3926 | dup dup truncate eq { |
|---|
| 3927 | cvi dup chaine cvs exch |
|---|
| 3928 | } { |
|---|
| 3929 | dup chaine cvs exch |
|---|
| 3930 | } ifelse |
|---|
| 3931 | Oy xmarkstyle |
|---|
| 3932 | } def |
|---|
| 3933 | /xmarks { |
|---|
| 3934 | 2 dict begin |
|---|
| 3935 | /n xmax xmax xmin sub 1000 div sub xmkstep div truncate cvi |
|---|
| 3936 | xmkstep mul def % mark max |
|---|
| 3937 | /i xmin xmkstep div truncate cvi |
|---|
| 3938 | xmkstep mul def % la 1ere |
|---|
| 3939 | i xmin lt {/i i xmkstep add store} if |
|---|
| 3940 | { |
|---|
| 3941 | i 0 ne {i xmark} if |
|---|
| 3942 | /i i xmkstep abs add store |
|---|
| 3943 | i n gt {exit} if |
|---|
| 3944 | } loop |
|---|
| 3945 | end |
|---|
| 3946 | } def |
|---|
| 3947 | |
|---|
| 3948 | /ymkstep 1 def % les marques sur Oy |
|---|
| 3949 | /setymkstep { |
|---|
| 3950 | /ymkstep exch def |
|---|
| 3951 | } def |
|---|
| 3952 | /ymark { |
|---|
| 3953 | dup ytick |
|---|
| 3954 | /Courier findfont .8 fontsize mul scalefont setfont |
|---|
| 3955 | dup chaine cvs exch |
|---|
| 3956 | Ox exch ymarkstyle |
|---|
| 3957 | } def |
|---|
| 3958 | /ymarks { |
|---|
| 3959 | 2 dict begin |
|---|
| 3960 | /n ymax ymax ymin sub 1000 div sub ymkstep div truncate cvi |
|---|
| 3961 | ymkstep mul def % mark max |
|---|
| 3962 | /i ymin ymkstep div truncate cvi |
|---|
| 3963 | ymkstep mul def % la 1ere |
|---|
| 3964 | { |
|---|
| 3965 | i 0 ne {i ymark} if |
|---|
| 3966 | /i i ymkstep abs add store |
|---|
| 3967 | i n gt {exit} if |
|---|
| 3968 | } loop |
|---|
| 3969 | end |
|---|
| 3970 | } def |
|---|
| 3971 | |
|---|
| 3972 | /setmkstep { |
|---|
| 3973 | setymkstep |
|---|
| 3974 | setxmkstep |
|---|
| 3975 | } def |
|---|
| 3976 | /marks { |
|---|
| 3977 | xmarks |
|---|
| 3978 | ymarks |
|---|
| 3979 | } def |
|---|
| 3980 | |
|---|
| 3981 | %%%%% ### setfontsize ### |
|---|
| 3982 | /setfontsize { |
|---|
| 3983 | /fontsize exch def |
|---|
| 3984 | } def |
|---|
| 3985 | |
|---|
| 3986 | %%%%% ### setCourrier ### |
|---|
| 3987 | /Courier findfont |
|---|
| 3988 | dup length dict begin |
|---|
| 3989 | { |
|---|
| 3990 | 1 index /FID ne |
|---|
| 3991 | {def} |
|---|
| 3992 | {pop pop} |
|---|
| 3993 | ifelse |
|---|
| 3994 | } forall |
|---|
| 3995 | /Encoding ISOLatin1Encoding def |
|---|
| 3996 | currentdict |
|---|
| 3997 | end |
|---|
| 3998 | |
|---|
| 3999 | /Courier-ISOLatin1 exch definefont pop |
|---|
| 4000 | |
|---|
| 4001 | /setCourier { |
|---|
| 4002 | /Courier-ISOLatin1 findfont |
|---|
| 4003 | fontsize scalefont |
|---|
| 4004 | setfont |
|---|
| 4005 | } def |
|---|
| 4006 | |
|---|
| 4007 | %%%%% ### pathtext ### |
|---|
| 4008 | %% syntaxe : string x y initp@thtext |
|---|
| 4009 | /initp@thtext { |
|---|
| 4010 | 7 dict begin |
|---|
| 4011 | /y exch def |
|---|
| 4012 | /x exch def |
|---|
| 4013 | /str exch def |
|---|
| 4014 | str 0 0 show_dim |
|---|
| 4015 | /wy exch def |
|---|
| 4016 | /wx exch def |
|---|
| 4017 | /lly exch def |
|---|
| 4018 | /llx exch def |
|---|
| 4019 | pop pop pop |
|---|
| 4020 | newpath |
|---|
| 4021 | x y smoveto |
|---|
| 4022 | } def |
|---|
| 4023 | /closep@thtext { |
|---|
| 4024 | str true charpath |
|---|
| 4025 | end |
|---|
| 4026 | } def |
|---|
| 4027 | |
|---|
| 4028 | %% syntaxe : string x y cctext_ |
|---|
| 4029 | /cctext_ { |
|---|
| 4030 | initp@thtext |
|---|
| 4031 | llx wx add lly wy add -.5 mulv rmoveto |
|---|
| 4032 | closep@thtext |
|---|
| 4033 | } def |
|---|
| 4034 | |
|---|
| 4035 | /brtext_ { |
|---|
| 4036 | initp@thtext |
|---|
| 4037 | hadjust 0 rmoveto |
|---|
| 4038 | llx neg 0 rmoveto |
|---|
| 4039 | closep@thtext |
|---|
| 4040 | } def |
|---|
| 4041 | |
|---|
| 4042 | /bbtext_ { |
|---|
| 4043 | initp@thtext |
|---|
| 4044 | 0 0 rmoveto |
|---|
| 4045 | 0 0 rmoveto |
|---|
| 4046 | closep@thtext |
|---|
| 4047 | } def |
|---|
| 4048 | |
|---|
| 4049 | /bltext_ { |
|---|
| 4050 | initp@thtext |
|---|
| 4051 | hadjust neg 0 rmoveto |
|---|
| 4052 | wx neg 0 rmoveto |
|---|
| 4053 | closep@thtext |
|---|
| 4054 | } def |
|---|
| 4055 | |
|---|
| 4056 | /bctext_ { |
|---|
| 4057 | initp@thtext |
|---|
| 4058 | 0 0 rmoveto |
|---|
| 4059 | wx llx add -.5 mul 0 rmoveto |
|---|
| 4060 | closep@thtext |
|---|
| 4061 | } def |
|---|
| 4062 | |
|---|
| 4063 | /ubtext_ { |
|---|
| 4064 | initp@thtext |
|---|
| 4065 | 0 vadjust rmoveto |
|---|
| 4066 | 0 lly neg rmoveto |
|---|
| 4067 | closep@thtext |
|---|
| 4068 | } def |
|---|
| 4069 | |
|---|
| 4070 | /urtext_ { |
|---|
| 4071 | initp@thtext |
|---|
| 4072 | hadjust vadjust rmoveto |
|---|
| 4073 | llx neg lly neg rmoveto |
|---|
| 4074 | closep@thtext |
|---|
| 4075 | } def |
|---|
| 4076 | |
|---|
| 4077 | /ultext_ { |
|---|
| 4078 | initp@thtext |
|---|
| 4079 | hadjust neg vadjust rmoveto |
|---|
| 4080 | wx neg lly neg rmoveto |
|---|
| 4081 | closep@thtext |
|---|
| 4082 | } def |
|---|
| 4083 | |
|---|
| 4084 | /uctext_ { |
|---|
| 4085 | initp@thtext |
|---|
| 4086 | 0 vadjust rmoveto |
|---|
| 4087 | llx wx add -.5 mul lly neg rmoveto |
|---|
| 4088 | closep@thtext |
|---|
| 4089 | } def |
|---|
| 4090 | |
|---|
| 4091 | /drtext_ { |
|---|
| 4092 | initp@thtext |
|---|
| 4093 | hadjust vadjust neg rmoveto |
|---|
| 4094 | llx neg wy neg rmoveto |
|---|
| 4095 | closep@thtext |
|---|
| 4096 | } def |
|---|
| 4097 | |
|---|
| 4098 | /dbtext_ { |
|---|
| 4099 | initp@thtext |
|---|
| 4100 | 0 vadjust neg rmoveto |
|---|
| 4101 | 0 wy neg rmoveto |
|---|
| 4102 | closep@thtext |
|---|
| 4103 | } def |
|---|
| 4104 | |
|---|
| 4105 | /dltext_ { |
|---|
| 4106 | initp@thtext |
|---|
| 4107 | hadjust neg vadjust neg rmoveto |
|---|
| 4108 | wx neg wy neg rmoveto |
|---|
| 4109 | closep@thtext |
|---|
| 4110 | } def |
|---|
| 4111 | |
|---|
| 4112 | /dctext_ { |
|---|
| 4113 | initp@thtext |
|---|
| 4114 | 0 vadjust neg rmoveto |
|---|
| 4115 | llx wx add -2 div wy neg rmoveto |
|---|
| 4116 | closep@thtext |
|---|
| 4117 | } def |
|---|
| 4118 | |
|---|
| 4119 | /crtext_ { |
|---|
| 4120 | initp@thtext |
|---|
| 4121 | hadjust 0 rmoveto |
|---|
| 4122 | llx neg lly wy add -2 div rmoveto |
|---|
| 4123 | closep@thtext |
|---|
| 4124 | } def |
|---|
| 4125 | |
|---|
| 4126 | /cbtext_ { |
|---|
| 4127 | initp@thtext |
|---|
| 4128 | 0 0 rmoveto |
|---|
| 4129 | 0 lly wy add -2 div rmoveto |
|---|
| 4130 | closep@thtext |
|---|
| 4131 | } def |
|---|
| 4132 | |
|---|
| 4133 | /cltext_ { |
|---|
| 4134 | initp@thtext |
|---|
| 4135 | hadjust neg 0 rmoveto |
|---|
| 4136 | wx neg lly wy add -2 div rmoveto |
|---|
| 4137 | closep@thtext |
|---|
| 4138 | } def |
|---|
| 4139 | |
|---|
| 4140 | /cctext_ { |
|---|
| 4141 | initp@thtext |
|---|
| 4142 | 0 0 rmoveto |
|---|
| 4143 | llx wx add lly wy add -.5 mulv rmoveto |
|---|
| 4144 | closep@thtext |
|---|
| 4145 | } def |
|---|
| 4146 | |
|---|
| 4147 | %%%%% ### text3d ### |
|---|
| 4148 | %%%% Version 3d des commandes jps TEXTE |
|---|
| 4149 | /pr@p@re3d { |
|---|
| 4150 | 2 dict begin |
|---|
| 4151 | % /vect_echelle [1 1] def |
|---|
| 4152 | % /angle_de_rot {0} def |
|---|
| 4153 | % dup xcheck |
|---|
| 4154 | % {/angle_de_rot exch def} |
|---|
| 4155 | % if |
|---|
| 4156 | % dup isarray |
|---|
| 4157 | % {/vect_echelle exch def} |
|---|
| 4158 | % if% CamView vect_echelle {angle_de_rot} |
|---|
| 4159 | 3dto2d |
|---|
| 4160 | } def |
|---|
| 4161 | |
|---|
| 4162 | /bbtext3d { |
|---|
| 4163 | pr@p@re3d |
|---|
| 4164 | bbtext |
|---|
| 4165 | end |
|---|
| 4166 | } def |
|---|
| 4167 | |
|---|
| 4168 | /bbtexlabel3d { |
|---|
| 4169 | pr@p@re3d |
|---|
| 4170 | bbtexlabel |
|---|
| 4171 | end |
|---|
| 4172 | } def |
|---|
| 4173 | |
|---|
| 4174 | /bctext3d { |
|---|
| 4175 | pr@p@re3d |
|---|
| 4176 | bctext |
|---|
| 4177 | end |
|---|
| 4178 | } def |
|---|
| 4179 | |
|---|
| 4180 | /bctexlabel3d { |
|---|
| 4181 | pr@p@re3d |
|---|
| 4182 | bctexlabel |
|---|
| 4183 | end |
|---|
| 4184 | } def |
|---|
| 4185 | |
|---|
| 4186 | /bltext3d { |
|---|
| 4187 | pr@p@re3d |
|---|
| 4188 | bltext |
|---|
| 4189 | end |
|---|
| 4190 | } def |
|---|
| 4191 | |
|---|
| 4192 | /bltexlabel3d { |
|---|
| 4193 | pr@p@re3d |
|---|
| 4194 | bltexlabel |
|---|
| 4195 | end |
|---|
| 4196 | } def |
|---|
| 4197 | |
|---|
| 4198 | /brtext3d { |
|---|
| 4199 | pr@p@re3d |
|---|
| 4200 | brtext |
|---|
| 4201 | end |
|---|
| 4202 | } def |
|---|
| 4203 | |
|---|
| 4204 | /brtexlabel3d { |
|---|
| 4205 | pr@p@re3d |
|---|
| 4206 | brtexlabel |
|---|
| 4207 | end |
|---|
| 4208 | } def |
|---|
| 4209 | |
|---|
| 4210 | /cbtext3d { |
|---|
| 4211 | pr@p@re3d |
|---|
| 4212 | cbtext |
|---|
| 4213 | end |
|---|
| 4214 | } def |
|---|
| 4215 | |
|---|
| 4216 | /cbtexlabel3d { |
|---|
| 4217 | pr@p@re3d |
|---|
| 4218 | cbtexlabel |
|---|
| 4219 | end |
|---|
| 4220 | } def |
|---|
| 4221 | |
|---|
| 4222 | /cctext3d { |
|---|
| 4223 | pr@p@re3d |
|---|
| 4224 | cctext |
|---|
| 4225 | end |
|---|
| 4226 | } def |
|---|
| 4227 | |
|---|
| 4228 | /cctexlabel3d { |
|---|
| 4229 | pr@p@re3d |
|---|
| 4230 | cctexlabel |
|---|
| 4231 | end |
|---|
| 4232 | } def |
|---|
| 4233 | |
|---|
| 4234 | /cltext3d { |
|---|
| 4235 | pr@p@re3d |
|---|
| 4236 | cltext |
|---|
| 4237 | end |
|---|
| 4238 | } def |
|---|
| 4239 | |
|---|
| 4240 | /cltexlabel3d { |
|---|
| 4241 | pr@p@re3d |
|---|
| 4242 | cltexlabel |
|---|
| 4243 | end |
|---|
| 4244 | } def |
|---|
| 4245 | |
|---|
| 4246 | /crtext3d { |
|---|
| 4247 | pr@p@re3d |
|---|
| 4248 | crtext |
|---|
| 4249 | end |
|---|
| 4250 | } def |
|---|
| 4251 | |
|---|
| 4252 | /crtexlabel3d { |
|---|
| 4253 | pr@p@re3d |
|---|
| 4254 | crtexlabel |
|---|
| 4255 | end |
|---|
| 4256 | } def |
|---|
| 4257 | |
|---|
| 4258 | /dbtext3d { |
|---|
| 4259 | pr@p@re3d |
|---|
| 4260 | dbtext |
|---|
| 4261 | end |
|---|
| 4262 | } def |
|---|
| 4263 | |
|---|
| 4264 | /dbtexlabel3d { |
|---|
| 4265 | pr@p@re3d |
|---|
| 4266 | dbtexlabel |
|---|
| 4267 | end |
|---|
| 4268 | } def |
|---|
| 4269 | |
|---|
| 4270 | /dctext3d { |
|---|
| 4271 | pr@p@re3d |
|---|
| 4272 | dctext |
|---|
| 4273 | end |
|---|
| 4274 | } def |
|---|
| 4275 | |
|---|
| 4276 | /dctexlabel3d { |
|---|
| 4277 | pr@p@re3d |
|---|
| 4278 | dctexlabel |
|---|
| 4279 | end |
|---|
| 4280 | } def |
|---|
| 4281 | |
|---|
| 4282 | /dltext3d { |
|---|
| 4283 | pr@p@re3d |
|---|
| 4284 | dltext |
|---|
| 4285 | end |
|---|
| 4286 | } def |
|---|
| 4287 | |
|---|
| 4288 | /dltexlabel3d { |
|---|
| 4289 | pr@p@re3d |
|---|
| 4290 | dltexlabel |
|---|
| 4291 | end |
|---|
| 4292 | } def |
|---|
| 4293 | |
|---|
| 4294 | /drtext3d { |
|---|
| 4295 | pr@p@re3d |
|---|
| 4296 | drtext |
|---|
| 4297 | end |
|---|
| 4298 | } def |
|---|
| 4299 | |
|---|
| 4300 | /drtexlabel3d { |
|---|
| 4301 | pr@p@re3d |
|---|
| 4302 | drtexlabel |
|---|
| 4303 | end |
|---|
| 4304 | } def |
|---|
| 4305 | |
|---|
| 4306 | /ubtext3d { |
|---|
| 4307 | pr@p@re3d |
|---|
| 4308 | ubtext |
|---|
| 4309 | end |
|---|
| 4310 | } def |
|---|
| 4311 | |
|---|
| 4312 | /ubtexlabel3d { |
|---|
| 4313 | pr@p@re3d |
|---|
| 4314 | ubtexlabel |
|---|
| 4315 | end |
|---|
| 4316 | } def |
|---|
| 4317 | |
|---|
| 4318 | /uctext3d { |
|---|
| 4319 | pr@p@re3d |
|---|
| 4320 | uctext |
|---|
| 4321 | end |
|---|
| 4322 | } def |
|---|
| 4323 | |
|---|
| 4324 | /uctexlabel3d { |
|---|
| 4325 | pr@p@re3d |
|---|
| 4326 | uctexlabel |
|---|
| 4327 | end |
|---|
| 4328 | } def |
|---|
| 4329 | |
|---|
| 4330 | /ultext3d { |
|---|
| 4331 | pr@p@re3d |
|---|
| 4332 | ultext |
|---|
| 4333 | end |
|---|
| 4334 | } def |
|---|
| 4335 | |
|---|
| 4336 | /ultexlabel3d { |
|---|
| 4337 | pr@p@re3d |
|---|
| 4338 | ultexlabel |
|---|
| 4339 | end |
|---|
| 4340 | } def |
|---|
| 4341 | |
|---|
| 4342 | /urtext3d { |
|---|
| 4343 | pr@p@re3d |
|---|
| 4344 | urtext |
|---|
| 4345 | end |
|---|
| 4346 | } def |
|---|
| 4347 | |
|---|
| 4348 | /urtexlabel3d { |
|---|
| 4349 | pr@p@re3d |
|---|
| 4350 | urtexlabel |
|---|
| 4351 | end |
|---|
| 4352 | } def |
|---|
| 4353 | |
|---|
| 4354 | %%%%% ### fin insertion ### |
|---|
| 4355 | |
|---|
| 4356 | %% La macro provisoire de developpement (27/01/2009) |
|---|
| 4357 | %% syntaxe : solid table tablez --> - |
|---|
| 4358 | /solidcolorz { |
|---|
| 4359 | 10 dict begin |
|---|
| 4360 | %% les hauteurs |
|---|
| 4361 | /tablez exch def |
|---|
| 4362 | %% les couleurs |
|---|
| 4363 | /usertable exch def |
|---|
| 4364 | /solid exch def |
|---|
| 4365 | %% a-t-on des couleurs nommees ? |
|---|
| 4366 | usertable 0 get isstring { |
|---|
| 4367 | %% oui, et autant que d etages |
|---|
| 4368 | usertable length 1 sub tablez length eq { |
|---|
| 4369 | /table usertable def |
|---|
| 4370 | } { |
|---|
| 4371 | %% oui, mais moins que d etages |
|---|
| 4372 | %% ==> on definit les 2 premieres en RGB |
|---|
| 4373 | /a0 usertable 0 get def |
|---|
| 4374 | /a1 usertable 1 get def |
|---|
| 4375 | /lacouleurdepart { |
|---|
| 4376 | gsave |
|---|
| 4377 | [a0 cvx exec] length 0 eq { |
|---|
| 4378 | a0 cvx exec currentrgbcolor |
|---|
| 4379 | } { |
|---|
| 4380 | a0 cvx exec |
|---|
| 4381 | } ifelse |
|---|
| 4382 | grestore |
|---|
| 4383 | } def |
|---|
| 4384 | /lacouleurarrivee { |
|---|
| 4385 | gsave |
|---|
| 4386 | [a1 cvx exec] length 0 eq { |
|---|
| 4387 | a1 cvx exec currentrgbcolor |
|---|
| 4388 | } { |
|---|
| 4389 | a1 cvx exec |
|---|
| 4390 | } ifelse |
|---|
| 4391 | grestore |
|---|
| 4392 | } def |
|---|
| 4393 | /usertable [lacouleurdepart lacouleurarrivee] def |
|---|
| 4394 | } ifelse |
|---|
| 4395 | } if |
|---|
| 4396 | usertable 0 get isnum { |
|---|
| 4397 | %% c est un degrade : nb de couleurs a definir |
|---|
| 4398 | /n tablez length 1 add def |
|---|
| 4399 | % |
|---|
| 4400 | usertable length 4 eq { |
|---|
| 4401 | /a0 usertable 0 get def |
|---|
| 4402 | /a1 usertable 1 get def |
|---|
| 4403 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 4404 | /B usertable 2 get def |
|---|
| 4405 | /C usertable 3 get def |
|---|
| 4406 | /D {} def |
|---|
| 4407 | /espacedecouleurs (sethsbcolor) def |
|---|
| 4408 | } if |
|---|
| 4409 | % |
|---|
| 4410 | usertable length 6 eq { |
|---|
| 4411 | /a0 usertable 0 get def |
|---|
| 4412 | /b0 usertable 1 get def |
|---|
| 4413 | /c0 usertable 2 get def |
|---|
| 4414 | /a1 usertable 3 get def |
|---|
| 4415 | /b1 usertable 4 get def |
|---|
| 4416 | /c1 usertable 5 get def |
|---|
| 4417 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 4418 | /B {b0 i b1 b0 sub mul n 1 sub div add} def |
|---|
| 4419 | /C {c0 i c1 c0 sub mul n 1 sub div add} def |
|---|
| 4420 | /D {} def |
|---|
| 4421 | /espacedecouleurs (setrgbcolor) def |
|---|
| 4422 | } if |
|---|
| 4423 | % |
|---|
| 4424 | usertable length 7 eq { |
|---|
| 4425 | /a0 usertable 0 get def |
|---|
| 4426 | /b0 usertable 1 get def |
|---|
| 4427 | /c0 usertable 2 get def |
|---|
| 4428 | /a1 usertable 3 get def |
|---|
| 4429 | /b1 usertable 4 get def |
|---|
| 4430 | /c1 usertable 5 get def |
|---|
| 4431 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 4432 | /B {b0 i b1 b0 sub mul n 1 sub div add} def |
|---|
| 4433 | /C {c0 i c1 c0 sub mul n 1 sub div add} def |
|---|
| 4434 | /D {} def |
|---|
| 4435 | /espacedecouleurs (sethsbcolor) def |
|---|
| 4436 | } if |
|---|
| 4437 | % |
|---|
| 4438 | usertable length 8 eq { |
|---|
| 4439 | /a0 usertable 0 get def |
|---|
| 4440 | /b0 usertable 1 get def |
|---|
| 4441 | /c0 usertable 2 get def |
|---|
| 4442 | /d0 usertable 3 get def |
|---|
| 4443 | /a1 usertable 4 get def |
|---|
| 4444 | /b1 usertable 5 get def |
|---|
| 4445 | /c1 usertable 6 get def |
|---|
| 4446 | /d1 usertable 7 get def |
|---|
| 4447 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 4448 | /B {b0 i b1 b0 sub mul n 1 sub div add} def |
|---|
| 4449 | /C {c0 i c1 c0 sub mul n 1 sub div add} def |
|---|
| 4450 | /D {d0 i d1 d0 sub mul n 1 sub div add} def |
|---|
| 4451 | /espacedecouleurs (setcmykcolor) def |
|---|
| 4452 | } if |
|---|
| 4453 | % |
|---|
| 4454 | usertable length 2 eq { |
|---|
| 4455 | /a0 usertable 0 get def |
|---|
| 4456 | /a1 usertable 1 get def |
|---|
| 4457 | 0 1 n 1 sub { |
|---|
| 4458 | /i exch def |
|---|
| 4459 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 4460 | /B {1} def |
|---|
| 4461 | /C {1} def |
|---|
| 4462 | /D {} def |
|---|
| 4463 | /espacedecouleurs (sethsbcolor) def |
|---|
| 4464 | } for |
|---|
| 4465 | } if |
|---|
| 4466 | % |
|---|
| 4467 | %% on affecte la table des couleurs |
|---|
| 4468 | /table [ |
|---|
| 4469 | 0 1 n 1 sub { |
|---|
| 4470 | /i exch def |
|---|
| 4471 | [A B C D] espacedecouleurs astr2str |
|---|
| 4472 | } for |
|---|
| 4473 | ] def |
|---|
| 4474 | } if |
|---|
| 4475 | % |
|---|
| 4476 | /n solid solidnombrefaces def |
|---|
| 4477 | 0 1 n 1 sub { |
|---|
| 4478 | /i exch def |
|---|
| 4479 | solid i solidcentreface /z exch def pop pop |
|---|
| 4480 | /resultat 0 def |
|---|
| 4481 | 0 1 tablez length 1 sub { |
|---|
| 4482 | /j exch def |
|---|
| 4483 | /ztest tablez j get def |
|---|
| 4484 | z ztest le { |
|---|
| 4485 | /resultat j store |
|---|
| 4486 | exit |
|---|
| 4487 | } { |
|---|
| 4488 | /resultat j 1 add store |
|---|
| 4489 | } ifelse |
|---|
| 4490 | } for |
|---|
| 4491 | solid i table resultat get solidputfcolor |
|---|
| 4492 | } for |
|---|
| 4493 | end |
|---|
| 4494 | } def |
|---|
| 4495 | |
|---|
| 4496 | |
|---|
| 4497 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 4498 | %%%% bibliotheque sur les solides %%%% |
|---|
| 4499 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 4500 | |
|---|
| 4501 | %%%%% ### solide ### |
|---|
| 4502 | %% solid = [Sommets Faces Colors_Faces InOut_Table] |
|---|
| 4503 | /solidgetsommets { |
|---|
| 4504 | 0 get |
|---|
| 4505 | } def |
|---|
| 4506 | /solidgetpointstable {solidgetsommets} def |
|---|
| 4507 | |
|---|
| 4508 | /solidgetfaces { |
|---|
| 4509 | 1 get |
|---|
| 4510 | } def |
|---|
| 4511 | |
|---|
| 4512 | /solidgetface { |
|---|
| 4513 | 1 dict begin |
|---|
| 4514 | /i exch def |
|---|
| 4515 | solidgetfaces i get |
|---|
| 4516 | end |
|---|
| 4517 | } def |
|---|
| 4518 | |
|---|
| 4519 | /solidgetfcolors { |
|---|
| 4520 | 2 get |
|---|
| 4521 | } def |
|---|
| 4522 | |
|---|
| 4523 | %% syntaxe : solid i solidgetfcolor --> str |
|---|
| 4524 | /solidgetfcolor { |
|---|
| 4525 | 1 dict begin |
|---|
| 4526 | /i exch def |
|---|
| 4527 | solidgetfcolors i get |
|---|
| 4528 | end |
|---|
| 4529 | } def |
|---|
| 4530 | |
|---|
| 4531 | %% syntaxe : solid i str solidputfcolor --> - |
|---|
| 4532 | /solidputfcolor { |
|---|
| 4533 | 2 dict begin |
|---|
| 4534 | /str exch def |
|---|
| 4535 | /i exch def |
|---|
| 4536 | solidgetfcolors i str put |
|---|
| 4537 | end |
|---|
| 4538 | } def |
|---|
| 4539 | |
|---|
| 4540 | /solidgetinouttable { |
|---|
| 4541 | 3 get |
|---|
| 4542 | } def |
|---|
| 4543 | |
|---|
| 4544 | /solidputsommets { |
|---|
| 4545 | 0 exch put |
|---|
| 4546 | } def |
|---|
| 4547 | /solidputpointstable {solidputsommets} def |
|---|
| 4548 | |
|---|
| 4549 | /solidputfaces { |
|---|
| 4550 | 1 exch put |
|---|
| 4551 | } def |
|---|
| 4552 | |
|---|
| 4553 | %% syntaxe : solid solidfacesreverse -> - |
|---|
| 4554 | /solidfacesreverse { |
|---|
| 4555 | 5 dict begin |
|---|
| 4556 | /solid exch def |
|---|
| 4557 | /n solid solidnombrefaces def |
|---|
| 4558 | 0 1 n 1 sub { |
|---|
| 4559 | /i exch def |
|---|
| 4560 | /F solid i solidgetface reverse def |
|---|
| 4561 | /m F length def |
|---|
| 4562 | solid i [F aload pop m 0 roll ] solidputface |
|---|
| 4563 | } for |
|---|
| 4564 | end |
|---|
| 4565 | } def |
|---|
| 4566 | |
|---|
| 4567 | /solidputfcolors { |
|---|
| 4568 | 2 exch put |
|---|
| 4569 | } def |
|---|
| 4570 | |
|---|
| 4571 | /solidputinouttable { |
|---|
| 4572 | 3 exch put |
|---|
| 4573 | } def |
|---|
| 4574 | |
|---|
| 4575 | %% syntaxe : any issolid --> booleen, vrai si any est de type solid |
|---|
| 4576 | /issolid { |
|---|
| 4577 | 1 dict begin |
|---|
| 4578 | /candidat exch def |
|---|
| 4579 | candidat isarray { |
|---|
| 4580 | candidat length 4 eq { |
|---|
| 4581 | candidat 0 get isarray |
|---|
| 4582 | candidat 1 get isarray and |
|---|
| 4583 | candidat 2 get isarray and |
|---|
| 4584 | candidat 3 get isarray and { |
|---|
| 4585 | /IO candidat 3 get def |
|---|
| 4586 | IO length 4 eq |
|---|
| 4587 | IO 0 get isnum and |
|---|
| 4588 | IO 1 get isnum and |
|---|
| 4589 | IO 2 get isnum and |
|---|
| 4590 | IO 3 get isnum and |
|---|
| 4591 | } { |
|---|
| 4592 | false |
|---|
| 4593 | } ifelse |
|---|
| 4594 | } { |
|---|
| 4595 | false |
|---|
| 4596 | } ifelse |
|---|
| 4597 | } { |
|---|
| 4598 | false |
|---|
| 4599 | } ifelse |
|---|
| 4600 | end |
|---|
| 4601 | } def |
|---|
| 4602 | |
|---|
| 4603 | /dupsolid { |
|---|
| 4604 | 5 dict begin |
|---|
| 4605 | /solid exch def |
|---|
| 4606 | /S solid solidgetsommets def |
|---|
| 4607 | /F solid solidgetfaces def |
|---|
| 4608 | /FC solid solidgetfcolors def |
|---|
| 4609 | /IO solid solidgetinouttable def |
|---|
| 4610 | solid |
|---|
| 4611 | [ |
|---|
| 4612 | S duparray exch pop |
|---|
| 4613 | F duparray exch pop |
|---|
| 4614 | FC duparray exch pop |
|---|
| 4615 | IO duparray exch pop |
|---|
| 4616 | ] |
|---|
| 4617 | end |
|---|
| 4618 | } def |
|---|
| 4619 | |
|---|
| 4620 | %% syntaxe : solid array solidputinfaces --> - |
|---|
| 4621 | /solidputinfaces { |
|---|
| 4622 | 4 dict begin |
|---|
| 4623 | /facesinternes exch def |
|---|
| 4624 | /solid exch def |
|---|
| 4625 | /n2 facesinternes length def |
|---|
| 4626 | /IO solid solidgetinouttable def |
|---|
| 4627 | /facesexternes solid solidgetoutfaces def |
|---|
| 4628 | /n1 facesexternes length def |
|---|
| 4629 | solid |
|---|
| 4630 | [facesexternes aload pop facesinternes aload pop] |
|---|
| 4631 | solidputfaces |
|---|
| 4632 | IO 0 0 put |
|---|
| 4633 | IO 1 n1 1 sub put |
|---|
| 4634 | IO 2 n1 put |
|---|
| 4635 | IO 3 n1 n2 add 1 sub put |
|---|
| 4636 | end |
|---|
| 4637 | } def |
|---|
| 4638 | |
|---|
| 4639 | %% syntaxe : solid array solidputoutfaces --> - |
|---|
| 4640 | /solidputoutfaces { |
|---|
| 4641 | 4 dict begin |
|---|
| 4642 | /facesexternes exch def |
|---|
| 4643 | /solid exch def |
|---|
| 4644 | /n1 facesexternes length def |
|---|
| 4645 | /IO solid solidgetinouttable def |
|---|
| 4646 | /facesinternes solid solidgetinfaces def |
|---|
| 4647 | /n2 facesinternes length def |
|---|
| 4648 | solid |
|---|
| 4649 | [facesexternes aload pop facesinternes aload pop] |
|---|
| 4650 | solidputfaces |
|---|
| 4651 | IO 0 0 put |
|---|
| 4652 | IO 1 n1 1 sub put |
|---|
| 4653 | IO 2 n1 put |
|---|
| 4654 | IO 3 n1 n2 add 1 sub put |
|---|
| 4655 | end |
|---|
| 4656 | } def |
|---|
| 4657 | |
|---|
| 4658 | /solidnombreinfaces { |
|---|
| 4659 | 1 dict begin |
|---|
| 4660 | /solid exch def |
|---|
| 4661 | solid solidwithinfaces { |
|---|
| 4662 | /IO solid solidgetinouttable def |
|---|
| 4663 | IO 3 get IO 2 get sub 1 add |
|---|
| 4664 | } { |
|---|
| 4665 | 0 |
|---|
| 4666 | } ifelse |
|---|
| 4667 | end |
|---|
| 4668 | } def |
|---|
| 4669 | |
|---|
| 4670 | /solidnombreoutfaces { |
|---|
| 4671 | 1 dict begin |
|---|
| 4672 | /solid exch def |
|---|
| 4673 | /IO solid solidgetinouttable def |
|---|
| 4674 | IO 1 get IO 0 get sub 1 add |
|---|
| 4675 | end |
|---|
| 4676 | } def |
|---|
| 4677 | |
|---|
| 4678 | %% syntaxe : solid solidgetinfaces --> array |
|---|
| 4679 | /solidgetinfaces { |
|---|
| 4680 | 4 dict begin |
|---|
| 4681 | /solid exch def |
|---|
| 4682 | solid issolid not { |
|---|
| 4683 | (Error : mauvais type d argument dans solidgetinfaces) == |
|---|
| 4684 | quit |
|---|
| 4685 | } if |
|---|
| 4686 | solid solidwithinfaces { |
|---|
| 4687 | /IO solid solidgetinouttable def |
|---|
| 4688 | /F solid solidgetfaces def |
|---|
| 4689 | /n1 IO 2 get def |
|---|
| 4690 | /n2 IO 3 get def |
|---|
| 4691 | /n n2 n1 sub 1 add def |
|---|
| 4692 | F n1 n getinterval |
|---|
| 4693 | } { |
|---|
| 4694 | [] |
|---|
| 4695 | } ifelse |
|---|
| 4696 | end |
|---|
| 4697 | } def |
|---|
| 4698 | |
|---|
| 4699 | %% syntaxe : solid solidgetoutfaces --> array |
|---|
| 4700 | /solidgetoutfaces { |
|---|
| 4701 | 4 dict begin |
|---|
| 4702 | /solid exch def |
|---|
| 4703 | solid issolid not { |
|---|
| 4704 | (Error : mauvais type d argument dans solidgetoutfaces) == |
|---|
| 4705 | quit |
|---|
| 4706 | } if |
|---|
| 4707 | /IO solid solidgetinouttable def |
|---|
| 4708 | /F solid solidgetfaces def |
|---|
| 4709 | /n1 IO 0 get def |
|---|
| 4710 | /n2 IO 1 get def |
|---|
| 4711 | /n n2 n1 sub 1 add def |
|---|
| 4712 | F n1 n getinterval |
|---|
| 4713 | end |
|---|
| 4714 | } def |
|---|
| 4715 | |
|---|
| 4716 | %% /tracelignedeniveau? false def |
|---|
| 4717 | %% /hauteurlignedeniveau 1 def |
|---|
| 4718 | %% /couleurlignedeniveau {rouge} def |
|---|
| 4719 | %% /linewidthlignedeniveau 4 def |
|---|
| 4720 | |
|---|
| 4721 | /solidgridOn { |
|---|
| 4722 | /solidgrid true def |
|---|
| 4723 | } def |
|---|
| 4724 | /solidgridOff { |
|---|
| 4725 | /solidgrid false def |
|---|
| 4726 | } def |
|---|
| 4727 | |
|---|
| 4728 | %% syntaxe : solid i string solidputfcolor |
|---|
| 4729 | %% syntaxe : solid str outputcolors |
|---|
| 4730 | %% syntaxe : solid str1 str2 inoutputcolors |
|---|
| 4731 | %% syntaxe : solid string n solidputncolors |
|---|
| 4732 | %% syntaxe : solid array solidputincolors --> - |
|---|
| 4733 | %% syntaxe : solid array solidputoutcolors --> - |
|---|
| 4734 | %% syntaxe : solid solidgetincolors --> array |
|---|
| 4735 | %% syntaxe : solid solidgetoutcolors --> array |
|---|
| 4736 | |
|---|
| 4737 | %% syntaxe : solid array solidputinfaces --> - |
|---|
| 4738 | %% syntaxe : solid array solidputoutfaces --> - |
|---|
| 4739 | %% syntaxe : solid solidgetinfaces --> array |
|---|
| 4740 | %% syntaxe : solid solidgetoutfaces --> array |
|---|
| 4741 | |
|---|
| 4742 | %% syntaxe : solid1 solid2 solidfuz -> solid |
|---|
| 4743 | |
|---|
| 4744 | %% syntaxe : solid i solidgetsommetsface -> array |
|---|
| 4745 | %% array = tableau de points 3d |
|---|
| 4746 | /solidgetsommetsface { |
|---|
| 4747 | 1 dict begin |
|---|
| 4748 | /i exch def |
|---|
| 4749 | /solid exch def |
|---|
| 4750 | /F solid i solidgetface def |
|---|
| 4751 | [ |
|---|
| 4752 | 0 1 F length 1 sub { |
|---|
| 4753 | /k exch def |
|---|
| 4754 | solid F k get solidgetsommet |
|---|
| 4755 | } for |
|---|
| 4756 | ] |
|---|
| 4757 | end |
|---|
| 4758 | } def |
|---|
| 4759 | |
|---|
| 4760 | %% syntaxe : solid index table solidputface -> - |
|---|
| 4761 | /solidputface { |
|---|
| 4762 | 1 dict begin |
|---|
| 4763 | /table exch def |
|---|
| 4764 | /i exch def |
|---|
| 4765 | solidgetfaces i table put |
|---|
| 4766 | end |
|---|
| 4767 | } def |
|---|
| 4768 | |
|---|
| 4769 | %% syntaxe : solid table solidaddface -> - |
|---|
| 4770 | %% syntaxe : solid table (couleur) solidaddface -> - |
|---|
| 4771 | %% on ne se preoccupe pas des faces internes |
|---|
| 4772 | /solidaddface { |
|---|
| 4773 | 6 dict begin |
|---|
| 4774 | dup isstring { |
|---|
| 4775 | /lac@uleur exch def |
|---|
| 4776 | } { |
|---|
| 4777 | /lac@uleur () def |
|---|
| 4778 | } ifelse |
|---|
| 4779 | /table exch def |
|---|
| 4780 | /solid exch def |
|---|
| 4781 | /IO solid solidgetinouttable def |
|---|
| 4782 | /n2 IO 1 get def |
|---|
| 4783 | /FC solid solidgetoutcolors def |
|---|
| 4784 | IO 1 n2 1 add put |
|---|
| 4785 | solid [ solid solidgetfaces aload pop table ] solidputfaces |
|---|
| 4786 | solid IO solidputinouttable |
|---|
| 4787 | % solid solidnombrefaces |
|---|
| 4788 | solid [ |
|---|
| 4789 | FC aload pop lac@uleur |
|---|
| 4790 | ] solidputoutcolors |
|---|
| 4791 | end |
|---|
| 4792 | } def |
|---|
| 4793 | |
|---|
| 4794 | /solidnombrefaces { |
|---|
| 4795 | 1 dict begin |
|---|
| 4796 | /solid exch def |
|---|
| 4797 | solid solidnombreinfaces |
|---|
| 4798 | solid solidnombreoutfaces |
|---|
| 4799 | add |
|---|
| 4800 | end |
|---|
| 4801 | } def |
|---|
| 4802 | |
|---|
| 4803 | %% syntaxe : solid M solidaddsommetexterne -> - |
|---|
| 4804 | %% on ajoute le sommet sans se preoccuper de rien |
|---|
| 4805 | /solidaddsommetexterne { |
|---|
| 4806 | 2 dict begin |
|---|
| 4807 | /M defpoint3d |
|---|
| 4808 | /solid exch def |
|---|
| 4809 | solid |
|---|
| 4810 | [ solid solidgetsommets aload pop M ] |
|---|
| 4811 | solidputsommets |
|---|
| 4812 | end |
|---|
| 4813 | } def |
|---|
| 4814 | |
|---|
| 4815 | %% syntaxe : solid array solidaddsommets -> - |
|---|
| 4816 | /solidaddsommets { |
|---|
| 4817 | 2 dict begin |
|---|
| 4818 | /table exch def |
|---|
| 4819 | /solid exch def |
|---|
| 4820 | /n table length 3 idiv def |
|---|
| 4821 | 0 1 0 { |
|---|
| 4822 | /i exch def |
|---|
| 4823 | solid table i getp3d solidaddsommet pop |
|---|
| 4824 | } for |
|---|
| 4825 | end |
|---|
| 4826 | } def |
|---|
| 4827 | |
|---|
| 4828 | %% syntaxe : solid M solidaddsommet -> k |
|---|
| 4829 | %% on ajoute le sommet M. Si il est deja sur une arete, |
|---|
| 4830 | %% on l incorpore a la face concernee |
|---|
| 4831 | %% s il est deja present, on ne le rajoute pas. |
|---|
| 4832 | %% Renvoie l indice du sommet rajoute. |
|---|
| 4833 | /solidaddsommet { |
|---|
| 4834 | 10 dict begin |
|---|
| 4835 | /M defpoint3d |
|---|
| 4836 | /solid exch def |
|---|
| 4837 | /nbf solid solidnombrefaces def |
|---|
| 4838 | /N solid solidnombresommets def |
|---|
| 4839 | /sortie -1 def |
|---|
| 4840 | %% le sommet est-il deja dans la structure |
|---|
| 4841 | 0 1 N 1 sub { |
|---|
| 4842 | /i exch def |
|---|
| 4843 | %% (addsommet) == |
|---|
| 4844 | %% solid i solidgetsommet == == == |
|---|
| 4845 | %% M == == == |
|---|
| 4846 | %% solid i solidgetsommet M eqp3d == |
|---|
| 4847 | |
|---|
| 4848 | % solid i solidgetsommet M eqp3d { |
|---|
| 4849 | solid i solidgetsommet M distance3d 1e-5 le { |
|---|
| 4850 | %% oui => c est fini |
|---|
| 4851 | /sortie i store |
|---|
| 4852 | } if |
|---|
| 4853 | } for |
|---|
| 4854 | sortie 0 lt { |
|---|
| 4855 | %% non => on le rajoute |
|---|
| 4856 | /sortie N def |
|---|
| 4857 | solid M solidaddsommetexterne |
|---|
| 4858 | %% est il sur une arete deja codee |
|---|
| 4859 | 0 1 nbf 1 sub { |
|---|
| 4860 | %% face d indice i |
|---|
| 4861 | /i exch def |
|---|
| 4862 | solid i solidgetface /F exch def |
|---|
| 4863 | /nbsf F length def |
|---|
| 4864 | 0 1 nbsf 1 sub { |
|---|
| 4865 | /j exch def |
|---|
| 4866 | M |
|---|
| 4867 | solid j i solidgetsommetface |
|---|
| 4868 | solid j 1 add nbsf mod i solidgetsommetface |
|---|
| 4869 | point3dsursegment { |
|---|
| 4870 | %% il est sur l arete concernee |
|---|
| 4871 | solid i [ |
|---|
| 4872 | 0 1 j { |
|---|
| 4873 | /k exch def |
|---|
| 4874 | F k get |
|---|
| 4875 | } for |
|---|
| 4876 | N |
|---|
| 4877 | j 1 add nbsf mod dup 0 eq { |
|---|
| 4878 | pop |
|---|
| 4879 | } { |
|---|
| 4880 | 1 nbsf 1 sub { |
|---|
| 4881 | /k exch def |
|---|
| 4882 | F k get |
|---|
| 4883 | } for |
|---|
| 4884 | } ifelse |
|---|
| 4885 | ] solidputface |
|---|
| 4886 | exit |
|---|
| 4887 | } if |
|---|
| 4888 | } for |
|---|
| 4889 | } for |
|---|
| 4890 | } if |
|---|
| 4891 | sortie |
|---|
| 4892 | end |
|---|
| 4893 | } def |
|---|
| 4894 | |
|---|
| 4895 | %%%%% ### solidrmsommet ### |
|---|
| 4896 | %% syntaxe : solid i solidrmsommet -> - |
|---|
| 4897 | /solidrmsommet { |
|---|
| 4898 | 5 dict begin |
|---|
| 4899 | /i exch def |
|---|
| 4900 | /solid exch def |
|---|
| 4901 | solid issolid not { |
|---|
| 4902 | (Erreur : mauvais type d argument dans solidrmsommet) == |
|---|
| 4903 | quit |
|---|
| 4904 | } if |
|---|
| 4905 | solid i solidsommetsadjsommet length 0 gt { |
|---|
| 4906 | (Erreur : sommet non isole dans solidrmsommet) == |
|---|
| 4907 | quit |
|---|
| 4908 | } if |
|---|
| 4909 | |
|---|
| 4910 | %% on s occupe des sommets |
|---|
| 4911 | /n solid solidnombresommets def |
|---|
| 4912 | /S [ |
|---|
| 4913 | 0 1 n 1 sub { |
|---|
| 4914 | /j exch def |
|---|
| 4915 | j i ne { |
|---|
| 4916 | solid j solidgetsommet |
|---|
| 4917 | } if |
|---|
| 4918 | } for |
|---|
| 4919 | ] def |
|---|
| 4920 | solid S solidputsommets |
|---|
| 4921 | %% on s occupe des faces |
|---|
| 4922 | /n solid solidnombrefaces def |
|---|
| 4923 | /F [ |
|---|
| 4924 | 0 1 n 1 sub { |
|---|
| 4925 | %% face d indice j |
|---|
| 4926 | /j exch def |
|---|
| 4927 | /Fj solid j solidgetface def |
|---|
| 4928 | [0 1 Fj length 1 sub { |
|---|
| 4929 | %% sommet d indice k de la face Fj |
|---|
| 4930 | /k exch def |
|---|
| 4931 | Fj k get dup i gt { |
|---|
| 4932 | 1 sub |
|---|
| 4933 | } if |
|---|
| 4934 | } for] |
|---|
| 4935 | } for |
|---|
| 4936 | ] def |
|---|
| 4937 | solid F solidputfaces |
|---|
| 4938 | end |
|---|
| 4939 | } def |
|---|
| 4940 | |
|---|
| 4941 | %%%%% ### solidsommetsadjsommet ### |
|---|
| 4942 | %% syntaxe : solid i solidsommetsadjsommet --> array |
|---|
| 4943 | %% array est le tableau des indices des sommets adjacents au |
|---|
| 4944 | %% sommet d indice i |
|---|
| 4945 | /solidsommetsadjsommet { |
|---|
| 4946 | 6 dict begin |
|---|
| 4947 | /no exch def |
|---|
| 4948 | /solid exch def |
|---|
| 4949 | solid no solidfacesadjsommet /facesadj exch def |
|---|
| 4950 | /sommetsadj [] def |
|---|
| 4951 | /nbadj facesadj length def |
|---|
| 4952 | 0 1 nbadj 1 sub { |
|---|
| 4953 | /j exch def |
|---|
| 4954 | %% examen de la jieme face |
|---|
| 4955 | %/j 0 def |
|---|
| 4956 | /F solid facesadj j get solidgetface def |
|---|
| 4957 | /nbsommetsface F length def |
|---|
| 4958 | no F in { |
|---|
| 4959 | /index exch def |
|---|
| 4960 | /i1 F index 1 sub nbsommetsface modulo get def |
|---|
| 4961 | /i2 F index 1 add nbsommetsface mod get def |
|---|
| 4962 | %% si i1 n est pas deja note, on le rajoute |
|---|
| 4963 | i1 sommetsadj in { |
|---|
| 4964 | pop |
|---|
| 4965 | } { |
|---|
| 4966 | /sommetsadj [ sommetsadj aload pop i1 ] store |
|---|
| 4967 | } ifelse |
|---|
| 4968 | %% si i2 n est pas deja note, on le rajoute |
|---|
| 4969 | i2 sommetsadj in { |
|---|
| 4970 | pop |
|---|
| 4971 | } { |
|---|
| 4972 | /sommetsadj [ sommetsadj aload pop i2 ] store |
|---|
| 4973 | } ifelse |
|---|
| 4974 | } { |
|---|
| 4975 | (Error : bug dans solidsommetsadjsommet) == |
|---|
| 4976 | quit |
|---|
| 4977 | } ifelse |
|---|
| 4978 | } for |
|---|
| 4979 | sommetsadj |
|---|
| 4980 | end |
|---|
| 4981 | } def |
|---|
| 4982 | |
|---|
| 4983 | %%%%% ### solidfacesadjsommet ### |
|---|
| 4984 | %% syntaxe : solid i solidfacesadjsommet --> array |
|---|
| 4985 | %% array est le tableau des indices des faces adjacentes au |
|---|
| 4986 | %% sommet d indice i |
|---|
| 4987 | /solidfacesadjsommet { |
|---|
| 4988 | 6 dict begin |
|---|
| 4989 | /no exch def |
|---|
| 4990 | /solid exch def |
|---|
| 4991 | /n solid solidnombrefaces def |
|---|
| 4992 | /indicesfacesadj [] def |
|---|
| 4993 | 0 1 n 1 sub { |
|---|
| 4994 | /j exch def |
|---|
| 4995 | /F solid j solidgetface def |
|---|
| 4996 | no F in { |
|---|
| 4997 | pop |
|---|
| 4998 | /indicesfacesadj [ indicesfacesadj aload pop j ] store |
|---|
| 4999 | } if |
|---|
| 5000 | } for |
|---|
| 5001 | indicesfacesadj |
|---|
| 5002 | end |
|---|
| 5003 | } def |
|---|
| 5004 | |
|---|
| 5005 | %%%%% ### ordonnepoints3d ### |
|---|
| 5006 | %% syntaxe : array1 M ordonnepoints3d --> array2 |
|---|
| 5007 | %% array1 = tableau de points 3d coplanaires (plan P) |
|---|
| 5008 | %% M = point3d indiquant la direction de la normale a P |
|---|
| 5009 | %% array2 = les indices des points de depart, ranges dans le |
|---|
| 5010 | %% sens trigo par rapport a la normale |
|---|
| 5011 | /ordonnepoints3d { |
|---|
| 5012 | 5 dict begin |
|---|
| 5013 | /M defpoint3d |
|---|
| 5014 | /table exch def |
|---|
| 5015 | table isobarycentre3d /G defpoint3d |
|---|
| 5016 | %% calcul de la normale |
|---|
| 5017 | table 0 getp3d /ptref defpoint3d |
|---|
| 5018 | table 1 getp3d /A defpoint3d |
|---|
| 5019 | G ptref vecteur3d |
|---|
| 5020 | G A vecteur3d |
|---|
| 5021 | vectprod3d /vecteurnormal defpoint3d |
|---|
| 5022 | vecteurnormal G M vecteur3d scalprod3d 0 lt { |
|---|
| 5023 | vecteurnormal -1 mulv3d /vecteurnormal defpoint3d |
|---|
| 5024 | } if |
|---|
| 5025 | %% la table des angles |
|---|
| 5026 | table duparray exch pop |
|---|
| 5027 | {1 dict begin |
|---|
| 5028 | /M defpoint3d |
|---|
| 5029 | G ptref vecteur3d |
|---|
| 5030 | G M vecteur3d |
|---|
| 5031 | vecteurnormal angle3doriente |
|---|
| 5032 | end} papply3d |
|---|
| 5033 | % [0 1 table length 3 idiv 1 sub {} for] |
|---|
| 5034 | % exch |
|---|
| 5035 | doublebubblesort pop |
|---|
| 5036 | end |
|---|
| 5037 | } def |
|---|
| 5038 | |
|---|
| 5039 | %%%%% ### fin insertion ### |
|---|
| 5040 | |
|---|
| 5041 | %% /tracelignedeniveau? false def |
|---|
| 5042 | %% /hauteurlignedeniveau 1 def |
|---|
| 5043 | %% /couleurlignedeniveau {rouge} def |
|---|
| 5044 | %% /linewidthlignedeniveau 4 def |
|---|
| 5045 | %% |
|---|
| 5046 | %% /solidgrid true def |
|---|
| 5047 | %% /aretescachees true def |
|---|
| 5048 | %% /defaultsolidmode 2 def |
|---|
| 5049 | |
|---|
| 5050 | %% syntaxe : alpha beta r h newpie --> solid |
|---|
| 5051 | /newpie { |
|---|
| 5052 | 6 dict begin |
|---|
| 5053 | [[/resolution /nbetages] [8 1] [10 1] [12 1] [18 3] [36 5]] gestionsolidmode |
|---|
| 5054 | /h exch def |
|---|
| 5055 | /r exch def |
|---|
| 5056 | /beta exch def |
|---|
| 5057 | /alpha exch def |
|---|
| 5058 | [ |
|---|
| 5059 | 0 0 |
|---|
| 5060 | % alpha cos r mul alpha sin r mul |
|---|
| 5061 | alpha beta {1 dict begin /t exch def t cos r mul t sin r mul end} CourbeR2+ |
|---|
| 5062 | ] 0 h [nbetages] newprismedroit |
|---|
| 5063 | end |
|---|
| 5064 | } def |
|---|
| 5065 | |
|---|
| 5066 | %%%%% ### newsolid ### |
|---|
| 5067 | %% syntaxe : newsolid --> depose le solide nul sur la pile |
|---|
| 5068 | /newsolid { |
|---|
| 5069 | [] [] generesolid |
|---|
| 5070 | } def |
|---|
| 5071 | |
|---|
| 5072 | %%%%% ### generesolid ### |
|---|
| 5073 | /generesolid { |
|---|
| 5074 | 2 dict begin |
|---|
| 5075 | /F exch def |
|---|
| 5076 | /S exch def |
|---|
| 5077 | [S F [F length {()} repeat] [0 F length 1 sub -1 -1]] |
|---|
| 5078 | end |
|---|
| 5079 | } def |
|---|
| 5080 | |
|---|
| 5081 | %%%%% ### nullsolid ### |
|---|
| 5082 | %% syntaxe : solide nullsolid -> booleen, vrai si le solide est nul |
|---|
| 5083 | /nullsolid { |
|---|
| 5084 | 1 dict begin |
|---|
| 5085 | /candidat exch def |
|---|
| 5086 | candidat issolid not { |
|---|
| 5087 | (Error type argument dans "nullsolid") == |
|---|
| 5088 | quit |
|---|
| 5089 | } if |
|---|
| 5090 | candidat solidgetsommets length 0 eq { |
|---|
| 5091 | true |
|---|
| 5092 | } { |
|---|
| 5093 | false |
|---|
| 5094 | } ifelse |
|---|
| 5095 | end |
|---|
| 5096 | } def |
|---|
| 5097 | |
|---|
| 5098 | %%%%% ### solidnombreoutfaces ### |
|---|
| 5099 | /solidnombreoutfaces { |
|---|
| 5100 | 4 dict begin |
|---|
| 5101 | /solid exch def |
|---|
| 5102 | solid issolid not { |
|---|
| 5103 | (Error : mauvais type d argument dans solidnombreoutfaces) == |
|---|
| 5104 | quit |
|---|
| 5105 | } if |
|---|
| 5106 | solid nullsolid { |
|---|
| 5107 | 0 |
|---|
| 5108 | } { |
|---|
| 5109 | /IO solid solidgetinouttable def |
|---|
| 5110 | IO 1 get |
|---|
| 5111 | IO 0 get sub |
|---|
| 5112 | 1 add |
|---|
| 5113 | } ifelse |
|---|
| 5114 | end |
|---|
| 5115 | } def |
|---|
| 5116 | |
|---|
| 5117 | %%%%% ### solidnombreinfaces ### |
|---|
| 5118 | /solidnombreinfaces { |
|---|
| 5119 | 4 dict begin |
|---|
| 5120 | /solid exch def |
|---|
| 5121 | solid issolid not { |
|---|
| 5122 | (Error : mauvais type d argument dans solidnombreinfaces) == |
|---|
| 5123 | quit |
|---|
| 5124 | } if |
|---|
| 5125 | solid solidwithinfaces { |
|---|
| 5126 | /IO solid solidgetinouttable def |
|---|
| 5127 | IO 3 get |
|---|
| 5128 | IO 2 get sub |
|---|
| 5129 | 1 add |
|---|
| 5130 | } { |
|---|
| 5131 | 0 |
|---|
| 5132 | } ifelse |
|---|
| 5133 | end |
|---|
| 5134 | } def |
|---|
| 5135 | |
|---|
| 5136 | %%%%% ### solidtests ### |
|---|
| 5137 | %% syntaxe : solid solidwithinfaces --> bool, true si le solide est vide |
|---|
| 5138 | /solidwithinfaces { |
|---|
| 5139 | 2 dict begin |
|---|
| 5140 | /solid exch def |
|---|
| 5141 | solid issolid not { |
|---|
| 5142 | (Error : mauvais type d argument dans solidwithinfaces) == |
|---|
| 5143 | quit |
|---|
| 5144 | } if |
|---|
| 5145 | /table solid solidgetinouttable def |
|---|
| 5146 | table 2 get -1 ne { |
|---|
| 5147 | true |
|---|
| 5148 | } { |
|---|
| 5149 | false |
|---|
| 5150 | } ifelse |
|---|
| 5151 | end |
|---|
| 5152 | } def |
|---|
| 5153 | |
|---|
| 5154 | %%%%% ### solidgetsommet ### |
|---|
| 5155 | %% syntaxe : solid i j solidgetsommetface --> sommet i de la face j |
|---|
| 5156 | /solidgetsommetface { |
|---|
| 5157 | 6 dict begin |
|---|
| 5158 | /j exch def |
|---|
| 5159 | /i exch def |
|---|
| 5160 | /solid exch def |
|---|
| 5161 | solid issolid not { |
|---|
| 5162 | (Error : mauvais type d argument dans solidgetsommetface) == |
|---|
| 5163 | quit |
|---|
| 5164 | } if |
|---|
| 5165 | /table_faces solid solidgetfaces def |
|---|
| 5166 | /table_sommets solid solidgetsommets def |
|---|
| 5167 | /k table_faces j get i get def |
|---|
| 5168 | table_sommets k getp3d |
|---|
| 5169 | end |
|---|
| 5170 | } def |
|---|
| 5171 | |
|---|
| 5172 | %% syntaxe : solid i solidgetsommetsface --> array, tableau des |
|---|
| 5173 | %% sommets de la face i du solide |
|---|
| 5174 | /solidgetsommetsface { |
|---|
| 5175 | 6 dict begin |
|---|
| 5176 | /i exch def |
|---|
| 5177 | /solid exch def |
|---|
| 5178 | solid issolid not { |
|---|
| 5179 | (Error : mauvais type d argument dans solidgetsommetsface) == |
|---|
| 5180 | quit |
|---|
| 5181 | } if |
|---|
| 5182 | /table_faces solid solidgetfaces def |
|---|
| 5183 | /table_sommets solid solidgetsommets def |
|---|
| 5184 | /table_indices table_faces i get def |
|---|
| 5185 | [ |
|---|
| 5186 | 0 1 table_indices length 1 sub { |
|---|
| 5187 | /j exch def |
|---|
| 5188 | table_sommets table_indices j get getp3d |
|---|
| 5189 | } for |
|---|
| 5190 | ] |
|---|
| 5191 | end |
|---|
| 5192 | } def |
|---|
| 5193 | |
|---|
| 5194 | %% syntaxe : solid i solidgetsommet --> sommet i du solide |
|---|
| 5195 | /solidgetsommet { |
|---|
| 5196 | 3 dict begin |
|---|
| 5197 | /i exch def |
|---|
| 5198 | /solid exch def |
|---|
| 5199 | solid issolid not { |
|---|
| 5200 | (Error : mauvais type d argument dans solidgetsommet) == |
|---|
| 5201 | quit |
|---|
| 5202 | } if |
|---|
| 5203 | /table_sommets solid solidgetsommets def |
|---|
| 5204 | table_sommets i getp3d |
|---|
| 5205 | end |
|---|
| 5206 | } def |
|---|
| 5207 | |
|---|
| 5208 | %%%%% ### solidcentreface ### |
|---|
| 5209 | %% syntaxe : solid i solidcentreface --> M |
|---|
| 5210 | /solidcentreface { |
|---|
| 5211 | solidgetsommetsface isobarycentre3d |
|---|
| 5212 | } def |
|---|
| 5213 | |
|---|
| 5214 | %%%%% ### solidnombre ### |
|---|
| 5215 | /solidnombresommets { |
|---|
| 5216 | solidgetsommets length 3 idiv |
|---|
| 5217 | } def |
|---|
| 5218 | |
|---|
| 5219 | /solidfacenombresommets { |
|---|
| 5220 | solidgetface length |
|---|
| 5221 | } def |
|---|
| 5222 | |
|---|
| 5223 | /solidnombrefaces { |
|---|
| 5224 | solidgetfaces length |
|---|
| 5225 | } def |
|---|
| 5226 | |
|---|
| 5227 | %%%%% ### solidshowsommets ### |
|---|
| 5228 | /solidshowsommets { |
|---|
| 5229 | 8 dict begin |
|---|
| 5230 | dup issolid not { |
|---|
| 5231 | %% on a un argument |
|---|
| 5232 | /option exch def |
|---|
| 5233 | } if |
|---|
| 5234 | /sol exch def |
|---|
| 5235 | /n sol solidnombresommets def |
|---|
| 5236 | /m sol solidnombrefaces def |
|---|
| 5237 | currentdict /option known not { |
|---|
| 5238 | /option [0 1 n 1 sub {} for] def |
|---|
| 5239 | } if |
|---|
| 5240 | 0 1 option length 1 sub { |
|---|
| 5241 | /k exch def |
|---|
| 5242 | option k get /i exch def %% indice du sommet examine |
|---|
| 5243 | sol i solidgetsommet point3d |
|---|
| 5244 | } for |
|---|
| 5245 | end |
|---|
| 5246 | } def |
|---|
| 5247 | |
|---|
| 5248 | %%%%% ### solidnumsommets ### |
|---|
| 5249 | /solidnumsommets { |
|---|
| 5250 | 8 dict begin |
|---|
| 5251 | % Font findfont 10 scalefont setfont |
|---|
| 5252 | dup issolid not { |
|---|
| 5253 | %% on a un argument |
|---|
| 5254 | /option exch def |
|---|
| 5255 | } if |
|---|
| 5256 | /sol exch def |
|---|
| 5257 | /n sol solidnombresommets def |
|---|
| 5258 | /m sol solidnombrefaces def |
|---|
| 5259 | currentdict /option known not { |
|---|
| 5260 | /option [0 1 n 1 sub {} for] def |
|---|
| 5261 | } if |
|---|
| 5262 | /result [ |
|---|
| 5263 | n {false} repeat |
|---|
| 5264 | ] def |
|---|
| 5265 | 0 1 option length 1 sub { |
|---|
| 5266 | /k exch def |
|---|
| 5267 | option k get /i exch def %% indice du sommet examine |
|---|
| 5268 | 0 1 m 1 sub { |
|---|
| 5269 | /j exch def %% indice de la face examinee |
|---|
| 5270 | i sol j solidgetface in { |
|---|
| 5271 | %% le sommet i est dans la face j |
|---|
| 5272 | pop |
|---|
| 5273 | exit |
|---|
| 5274 | } if |
|---|
| 5275 | } for |
|---|
| 5276 | sol i solidgetsommet /S defpoint3d |
|---|
| 5277 | i ( ) cvs |
|---|
| 5278 | m 0 ne { |
|---|
| 5279 | %% le sommet i est dans la face j |
|---|
| 5280 | sol j solidcentreface /G defpoint3d |
|---|
| 5281 | G S vecteur3d normalize3d |
|---|
| 5282 | 15 dup ptojpoint pop |
|---|
| 5283 | mulv3d |
|---|
| 5284 | S addv3d |
|---|
| 5285 | 3dto2d cctext |
|---|
| 5286 | } { |
|---|
| 5287 | S 3dto2d uctext |
|---|
| 5288 | } ifelse |
|---|
| 5289 | } for |
|---|
| 5290 | end |
|---|
| 5291 | } def |
|---|
| 5292 | |
|---|
| 5293 | %%%%% ### gestionsolidmode ### |
|---|
| 5294 | %% table = [ [vars] [mode0] [mode1] [mode2] [mode3] [mode4] ] |
|---|
| 5295 | /gestionsolidmode { |
|---|
| 5296 | 5 dict begin |
|---|
| 5297 | /table exch def |
|---|
| 5298 | dup xcheck { |
|---|
| 5299 | /mode exch def |
|---|
| 5300 | } { |
|---|
| 5301 | dup isarray { |
|---|
| 5302 | /tableaffectation exch def |
|---|
| 5303 | /mode -1 def |
|---|
| 5304 | } { |
|---|
| 5305 | /mode defaultsolidmode def |
|---|
| 5306 | } ifelse |
|---|
| 5307 | } ifelse |
|---|
| 5308 | /vars table 0 get def |
|---|
| 5309 | /nbvars vars length def |
|---|
| 5310 | mode 0 ge { |
|---|
| 5311 | /tableaffectation table mode 1 add 5 min get def |
|---|
| 5312 | } if |
|---|
| 5313 | 0 1 nbvars 1 sub { |
|---|
| 5314 | /i exch def |
|---|
| 5315 | vars i get |
|---|
| 5316 | tableaffectation i get |
|---|
| 5317 | } for |
|---|
| 5318 | nbvars |
|---|
| 5319 | end |
|---|
| 5320 | {def} repeat |
|---|
| 5321 | } def |
|---|
| 5322 | |
|---|
| 5323 | %%%%% ### solidfuz ### |
|---|
| 5324 | %% syntaxe : solid1 solid2 solidfuz -> solid |
|---|
| 5325 | /solidfuz { |
|---|
| 5326 | 5 dict begin |
|---|
| 5327 | /solid2 exch def |
|---|
| 5328 | /solid1 exch def |
|---|
| 5329 | /S1 solid1 solidgetsommets def |
|---|
| 5330 | /S2 solid2 solidgetsommets def |
|---|
| 5331 | /n S1 length 3 idiv def |
|---|
| 5332 | |
|---|
| 5333 | %% les sommets |
|---|
| 5334 | /S S1 S2 append def |
|---|
| 5335 | |
|---|
| 5336 | %% les faces internes et leurs couleurs |
|---|
| 5337 | /FI1 solid1 solidgetinfaces def |
|---|
| 5338 | /FIC1 solid1 solidgetincolors def |
|---|
| 5339 | solid2 solidnombreinfaces 0 eq { |
|---|
| 5340 | /FI2 [] def |
|---|
| 5341 | /FIC2 [] def |
|---|
| 5342 | } { |
|---|
| 5343 | /FI2 solid2 solidgetinfaces {{n add} apply} apply def |
|---|
| 5344 | /FIC2 solid2 solidgetincolors def |
|---|
| 5345 | } ifelse |
|---|
| 5346 | /FI [FI1 aload pop FI2 aload pop] def |
|---|
| 5347 | /FIC [FIC1 aload pop FIC2 aload pop] def |
|---|
| 5348 | |
|---|
| 5349 | %% les faces externes et leurs couleurs |
|---|
| 5350 | /FO1 solid1 solidgetoutfaces def |
|---|
| 5351 | /FOC1 solid1 solidgetoutcolors def |
|---|
| 5352 | /FO2 solid2 solidgetoutfaces {{n add} apply} apply def |
|---|
| 5353 | /FOC2 solid2 solidgetoutcolors def |
|---|
| 5354 | /FO [FO1 aload pop FO2 aload pop] def |
|---|
| 5355 | /FOC [FOC1 aload pop FOC2 aload pop] def |
|---|
| 5356 | |
|---|
| 5357 | /F [FO aload pop FI aload pop] def |
|---|
| 5358 | /FC [FOC aload pop FIC aload pop] def |
|---|
| 5359 | /IO [ |
|---|
| 5360 | 0 FO length 1 sub |
|---|
| 5361 | FI length 0 gt { |
|---|
| 5362 | dup 1 add dup FI length add 1 sub |
|---|
| 5363 | } { |
|---|
| 5364 | -1 -1 |
|---|
| 5365 | } ifelse |
|---|
| 5366 | ] def |
|---|
| 5367 | |
|---|
| 5368 | S F generesolid |
|---|
| 5369 | dup FC solidputfcolors |
|---|
| 5370 | dup IO solidputinouttable |
|---|
| 5371 | end |
|---|
| 5372 | } def |
|---|
| 5373 | |
|---|
| 5374 | %%%%% ### solidnormaleface ### |
|---|
| 5375 | %% syntaxe : solid i solidnormaleface --> u, vecteur normale a la |
|---|
| 5376 | %% face d indice i du solide |
|---|
| 5377 | /solidnormaleface { |
|---|
| 5378 | 4 dict begin |
|---|
| 5379 | /i exch def |
|---|
| 5380 | /solid exch def |
|---|
| 5381 | solid issolid not { |
|---|
| 5382 | (Error : mauvais type d argument dans solidgetsommetface) == |
|---|
| 5383 | quit |
|---|
| 5384 | } if |
|---|
| 5385 | %% solid 0 i solidgetsommetface /G defpoint3d |
|---|
| 5386 | %% G |
|---|
| 5387 | %% solid 1 i solidgetsommetface |
|---|
| 5388 | %% vecteur3d |
|---|
| 5389 | %% G |
|---|
| 5390 | %% solid 2 i solidgetsommetface |
|---|
| 5391 | %% vecteur3d |
|---|
| 5392 | |
|---|
| 5393 | /n solid i solidfacenombresommets def |
|---|
| 5394 | solid i solidcentreface /G defpoint3d |
|---|
| 5395 | %% debug %% G 3dto2d point |
|---|
| 5396 | G |
|---|
| 5397 | solid 0 i solidgetsommetface |
|---|
| 5398 | /A defpoint3d |
|---|
| 5399 | % gsave bleu A point3d grestore |
|---|
| 5400 | A |
|---|
| 5401 | vecteur3d normalize3d |
|---|
| 5402 | G |
|---|
| 5403 | solid 1 i solidgetsommetface |
|---|
| 5404 | /A defpoint3d |
|---|
| 5405 | % gsave orange A point3d grestore |
|---|
| 5406 | A |
|---|
| 5407 | vecteur3d normalize3d |
|---|
| 5408 | vectprod3d |
|---|
| 5409 | /resultat defpoint3d |
|---|
| 5410 | resultat normalize3d |
|---|
| 5411 | end |
|---|
| 5412 | } def |
|---|
| 5413 | |
|---|
| 5414 | %%%%% ### solidtransform ### |
|---|
| 5415 | %% syntaxe : solid1 {f} solidtransform --> solid2, solid2 est le |
|---|
| 5416 | %% transforme de solid1 par la transformation f : R^3 -> R^3 |
|---|
| 5417 | /solidtransform { |
|---|
| 5418 | 3 dict begin |
|---|
| 5419 | /@f exch def |
|---|
| 5420 | /solid exch def |
|---|
| 5421 | solid issolid not { |
|---|
| 5422 | (Error : mauvais type d argument dans solidtransform) == |
|---|
| 5423 | quit |
|---|
| 5424 | } if |
|---|
| 5425 | /les_sommets |
|---|
| 5426 | solid solidgetsommets {@f} papply3d |
|---|
| 5427 | def |
|---|
| 5428 | solid les_sommets solidputsommets |
|---|
| 5429 | solid |
|---|
| 5430 | end |
|---|
| 5431 | } def |
|---|
| 5432 | |
|---|
| 5433 | %%%%% ### solidputcolor ### |
|---|
| 5434 | %% syntaxe : solid i string solidputfcolor |
|---|
| 5435 | /solidputfcolor { |
|---|
| 5436 | 3 dict begin |
|---|
| 5437 | /str exch def |
|---|
| 5438 | /i exch def |
|---|
| 5439 | /solid exch def |
|---|
| 5440 | /FC solid solidgetfcolors def |
|---|
| 5441 | i FC length lt { |
|---|
| 5442 | FC i str put |
|---|
| 5443 | } if |
|---|
| 5444 | end |
|---|
| 5445 | } def |
|---|
| 5446 | |
|---|
| 5447 | %% syntaxe : solid solidgetincolors --> array |
|---|
| 5448 | /solidgetincolors { |
|---|
| 5449 | 3 dict begin |
|---|
| 5450 | /solid exch def |
|---|
| 5451 | solid issolid not { |
|---|
| 5452 | (Error : mauvais type d argument dans solidgetincolors) == |
|---|
| 5453 | quit |
|---|
| 5454 | } if |
|---|
| 5455 | solid solidwithinfaces { |
|---|
| 5456 | /fcol solid solidgetfcolors def |
|---|
| 5457 | /IO solid solidgetinouttable def |
|---|
| 5458 | /n1 IO 2 get def |
|---|
| 5459 | /n2 IO 3 get def |
|---|
| 5460 | /n n2 n1 sub 1 add def |
|---|
| 5461 | fcol n1 n getinterval |
|---|
| 5462 | } { |
|---|
| 5463 | [] |
|---|
| 5464 | } ifelse |
|---|
| 5465 | end |
|---|
| 5466 | } def |
|---|
| 5467 | |
|---|
| 5468 | %% syntaxe : solid solidgetoutcolors --> array |
|---|
| 5469 | /solidgetoutcolors { |
|---|
| 5470 | 3 dict begin |
|---|
| 5471 | /solid exch def |
|---|
| 5472 | solid issolid not { |
|---|
| 5473 | (Error : mauvais type d argument dans solidgetoutcolors) == |
|---|
| 5474 | quit |
|---|
| 5475 | } if |
|---|
| 5476 | /fcol solid solidgetfcolors def |
|---|
| 5477 | /IO solid solidgetinouttable def |
|---|
| 5478 | /n1 IO 0 get def |
|---|
| 5479 | /n2 IO 1 get def |
|---|
| 5480 | /n n2 n1 sub 1 add def |
|---|
| 5481 | fcol n1 n getinterval |
|---|
| 5482 | end |
|---|
| 5483 | } def |
|---|
| 5484 | |
|---|
| 5485 | %% syntaxe : solid array solidputincolors --> - |
|---|
| 5486 | /solidputincolors { |
|---|
| 5487 | 4 dict begin |
|---|
| 5488 | /newcolorstable exch def |
|---|
| 5489 | /solid exch def |
|---|
| 5490 | solid issolid not { |
|---|
| 5491 | (Error : mauvais type d argument dans solidputincolors) == |
|---|
| 5492 | quit |
|---|
| 5493 | } if |
|---|
| 5494 | /n newcolorstable length def |
|---|
| 5495 | n solid solidnombreinfaces ne { |
|---|
| 5496 | (Error : mauvaise longueur de tableau dans solidputincolors) == |
|---|
| 5497 | quit |
|---|
| 5498 | } if |
|---|
| 5499 | n 0 ne { |
|---|
| 5500 | /FC solid solidgetfcolors def |
|---|
| 5501 | /IO solid solidgetinouttable def |
|---|
| 5502 | /n1 IO 2 get def |
|---|
| 5503 | FC n1 newcolorstable putinterval |
|---|
| 5504 | } if |
|---|
| 5505 | end |
|---|
| 5506 | } def |
|---|
| 5507 | |
|---|
| 5508 | %% syntaxe : solid array solidputoutcolors --> - |
|---|
| 5509 | /solidputoutcolors { |
|---|
| 5510 | 4 dict begin |
|---|
| 5511 | /newcolorstable exch def |
|---|
| 5512 | /solid exch def |
|---|
| 5513 | solid issolid not { |
|---|
| 5514 | (Error : mauvais type d argument dans solidputoutcolors) == |
|---|
| 5515 | quit |
|---|
| 5516 | } if |
|---|
| 5517 | /n newcolorstable length def |
|---|
| 5518 | n solid solidnombreoutfaces ne { |
|---|
| 5519 | (Error : mauvaise longueur de tableau dans solidputoutcolors) == |
|---|
| 5520 | quit |
|---|
| 5521 | } if |
|---|
| 5522 | n 0 ne { |
|---|
| 5523 | /FC solid solidgetfcolors def |
|---|
| 5524 | /IO solid solidgetinouttable def |
|---|
| 5525 | /n1 IO 0 get def |
|---|
| 5526 | FC n1 newcolorstable putinterval |
|---|
| 5527 | } if |
|---|
| 5528 | end |
|---|
| 5529 | } def |
|---|
| 5530 | |
|---|
| 5531 | %% syntaxe : solid str outputcolors |
|---|
| 5532 | /outputcolors { |
|---|
| 5533 | 5 dict begin |
|---|
| 5534 | /color exch def |
|---|
| 5535 | /solid exch def |
|---|
| 5536 | solid issolid not { |
|---|
| 5537 | (Error : mauvais type d argument dans inoutputcolors) == |
|---|
| 5538 | quit |
|---|
| 5539 | } if |
|---|
| 5540 | /n solid solidnombreoutfaces def |
|---|
| 5541 | solid [ n {color} repeat ] solidputoutcolors |
|---|
| 5542 | end |
|---|
| 5543 | } def |
|---|
| 5544 | |
|---|
| 5545 | %% syntaxe : solid str inputcolors |
|---|
| 5546 | /inputcolors { |
|---|
| 5547 | 5 dict begin |
|---|
| 5548 | /color exch def |
|---|
| 5549 | /solid exch def |
|---|
| 5550 | solid issolid not { |
|---|
| 5551 | (Error : mauvais type d argument dans inoutputcolors) == |
|---|
| 5552 | quit |
|---|
| 5553 | } if |
|---|
| 5554 | /n solid solidnombreinfaces def |
|---|
| 5555 | solid [ n {color} repeat ] solidputincolors |
|---|
| 5556 | end |
|---|
| 5557 | } def |
|---|
| 5558 | |
|---|
| 5559 | %% syntaxe : solid str1 str2 inoutputcolors |
|---|
| 5560 | /inoutputcolors { |
|---|
| 5561 | 5 dict begin |
|---|
| 5562 | /colout exch def |
|---|
| 5563 | /colin exch def |
|---|
| 5564 | /solid exch def |
|---|
| 5565 | solid colin inputcolors |
|---|
| 5566 | solid colout outputcolors |
|---|
| 5567 | end |
|---|
| 5568 | } def |
|---|
| 5569 | |
|---|
| 5570 | %% syntaxe : solid array solidputoutcolors --> - |
|---|
| 5571 | /solidputoutcolors { |
|---|
| 5572 | 4 dict begin |
|---|
| 5573 | /newcolorstable exch def |
|---|
| 5574 | /solid exch def |
|---|
| 5575 | solid issolid not { |
|---|
| 5576 | (Error : mauvais type d argument dans solidputoutcolors) == |
|---|
| 5577 | quit |
|---|
| 5578 | } if |
|---|
| 5579 | /n newcolorstable length def |
|---|
| 5580 | n solid solidnombreoutfaces ne { |
|---|
| 5581 | (Error : mauvaise longueur de tableau dans solidputoutcolors) == |
|---|
| 5582 | quit |
|---|
| 5583 | } if |
|---|
| 5584 | n 0 ne { |
|---|
| 5585 | /FC solid solidgetfcolors def |
|---|
| 5586 | /IO solid solidgetinouttable def |
|---|
| 5587 | /n1 IO 0 get def |
|---|
| 5588 | FC length n n1 add lt { |
|---|
| 5589 | solid newcolorstable solidputfcolors |
|---|
| 5590 | } { |
|---|
| 5591 | FC n1 newcolorstable putinterval |
|---|
| 5592 | } ifelse |
|---|
| 5593 | } if |
|---|
| 5594 | end |
|---|
| 5595 | } def |
|---|
| 5596 | |
|---|
| 5597 | /solidputcolors { |
|---|
| 5598 | 3 dict begin |
|---|
| 5599 | 2 copy pop |
|---|
| 5600 | isstring { |
|---|
| 5601 | inoutputcolors |
|---|
| 5602 | } { |
|---|
| 5603 | outputcolors |
|---|
| 5604 | } ifelse |
|---|
| 5605 | end |
|---|
| 5606 | } def |
|---|
| 5607 | |
|---|
| 5608 | %%%%% ### solidputhuecolors ### |
|---|
| 5609 | %% syntaxe : solid table solidputhuecolors --> - |
|---|
| 5610 | /solidputhuecolors { |
|---|
| 5611 | 1 dict begin |
|---|
| 5612 | 2 copy pop |
|---|
| 5613 | solidgetinouttable /IO exch def |
|---|
| 5614 | IO 0 get |
|---|
| 5615 | IO 1 get |
|---|
| 5616 | s@lidputhuec@l@rs |
|---|
| 5617 | end |
|---|
| 5618 | } def |
|---|
| 5619 | |
|---|
| 5620 | /solidputinhuecolors { |
|---|
| 5621 | 2 dict begin |
|---|
| 5622 | /table exch def |
|---|
| 5623 | /solid exch def |
|---|
| 5624 | solid solidgetinouttable /IO exch def |
|---|
| 5625 | solid solidwithinfaces { |
|---|
| 5626 | solid table |
|---|
| 5627 | IO 2 get |
|---|
| 5628 | IO 3 get |
|---|
| 5629 | s@lidputhuec@l@rs |
|---|
| 5630 | } if |
|---|
| 5631 | end |
|---|
| 5632 | } def |
|---|
| 5633 | |
|---|
| 5634 | /solidputinouthuecolors { |
|---|
| 5635 | 1 dict begin |
|---|
| 5636 | 2 copy pop |
|---|
| 5637 | solidgetinouttable /IO exch def |
|---|
| 5638 | IO 0 get |
|---|
| 5639 | IO 3 get IO 1 get max |
|---|
| 5640 | s@lidputhuec@l@rs |
|---|
| 5641 | end |
|---|
| 5642 | } def |
|---|
| 5643 | |
|---|
| 5644 | %% syntaxe : solid table n1 n2 s@lidputhuec@l@rs --> - |
|---|
| 5645 | %% affecte les couleurs des faces d indice n1 a n2 du solid solid, par |
|---|
| 5646 | %% un degrade defini par la table. |
|---|
| 5647 | /s@lidputhuec@l@rs { |
|---|
| 5648 | 9 dict begin |
|---|
| 5649 | /n2 exch def |
|---|
| 5650 | /n1 exch def |
|---|
| 5651 | /table exch def |
|---|
| 5652 | /solid exch def |
|---|
| 5653 | /n n2 n1 sub def |
|---|
| 5654 | |
|---|
| 5655 | table length 2 eq { |
|---|
| 5656 | /a0 table 0 get def |
|---|
| 5657 | /a1 table 1 get def |
|---|
| 5658 | a1 isstring { |
|---|
| 5659 | /lacouleurdepart { |
|---|
| 5660 | gsave |
|---|
| 5661 | [a0 cvx exec] length 0 eq { |
|---|
| 5662 | a0 cvx exec currentrgbcolor |
|---|
| 5663 | } { |
|---|
| 5664 | a0 cvx exec |
|---|
| 5665 | } ifelse |
|---|
| 5666 | grestore |
|---|
| 5667 | } def |
|---|
| 5668 | /lacouleurarrivee { |
|---|
| 5669 | gsave |
|---|
| 5670 | [a1 cvx exec] length 0 eq { |
|---|
| 5671 | a1 cvx exec currentrgbcolor |
|---|
| 5672 | } { |
|---|
| 5673 | a1 cvx exec |
|---|
| 5674 | } ifelse |
|---|
| 5675 | grestore |
|---|
| 5676 | } def |
|---|
| 5677 | /table [lacouleurdepart lacouleurarrivee] def |
|---|
| 5678 | } { |
|---|
| 5679 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 5680 | /B {1} def |
|---|
| 5681 | /C {1} def |
|---|
| 5682 | /D {} def |
|---|
| 5683 | /espacedecouleurs (sethsbcolor) def |
|---|
| 5684 | } ifelse |
|---|
| 5685 | } if |
|---|
| 5686 | |
|---|
| 5687 | table length 4 eq { |
|---|
| 5688 | /a0 table 0 get def |
|---|
| 5689 | /a1 table 1 get def |
|---|
| 5690 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 5691 | /B table 2 get def |
|---|
| 5692 | /C table 3 get def |
|---|
| 5693 | /D {} def |
|---|
| 5694 | /espacedecouleurs (sethsbcolor) def |
|---|
| 5695 | } if |
|---|
| 5696 | |
|---|
| 5697 | table length 6 eq { |
|---|
| 5698 | /a0 table 0 get def |
|---|
| 5699 | /b0 table 1 get def |
|---|
| 5700 | /c0 table 2 get def |
|---|
| 5701 | /a1 table 3 get def |
|---|
| 5702 | /b1 table 4 get def |
|---|
| 5703 | /c1 table 5 get def |
|---|
| 5704 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 5705 | /B {b0 i b1 b0 sub mul n 1 sub div add} def |
|---|
| 5706 | /C {c0 i c1 c0 sub mul n 1 sub div add} def |
|---|
| 5707 | /D {} def |
|---|
| 5708 | /espacedecouleurs (setrgbcolor) def |
|---|
| 5709 | } if |
|---|
| 5710 | |
|---|
| 5711 | table length 7 eq { |
|---|
| 5712 | /a0 table 0 get def |
|---|
| 5713 | /b0 table 1 get def |
|---|
| 5714 | /c0 table 2 get def |
|---|
| 5715 | /a1 table 3 get def |
|---|
| 5716 | /b1 table 4 get def |
|---|
| 5717 | /c1 table 5 get def |
|---|
| 5718 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 5719 | /B {b0 i b1 b0 sub mul n 1 sub div add} def |
|---|
| 5720 | /C {c0 i c1 c0 sub mul n 1 sub div add} def |
|---|
| 5721 | /D {} def |
|---|
| 5722 | /espacedecouleurs (sethsbcolor) def |
|---|
| 5723 | } if |
|---|
| 5724 | |
|---|
| 5725 | table length 8 eq { |
|---|
| 5726 | /a0 table 0 get def |
|---|
| 5727 | /b0 table 1 get def |
|---|
| 5728 | /c0 table 2 get def |
|---|
| 5729 | /d0 table 3 get def |
|---|
| 5730 | /a1 table 4 get def |
|---|
| 5731 | /b1 table 5 get def |
|---|
| 5732 | /c1 table 6 get def |
|---|
| 5733 | /d1 table 7 get def |
|---|
| 5734 | /A {a0 i a1 a0 sub mul n 1 sub div add} def |
|---|
| 5735 | /B {b0 i b1 b0 sub mul n 1 sub div add} def |
|---|
| 5736 | /C {c0 i c1 c0 sub mul n 1 sub div add} def |
|---|
| 5737 | /D {d0 i d1 d0 sub mul n 1 sub div add} def |
|---|
| 5738 | /espacedecouleurs (setcmykcolor) def |
|---|
| 5739 | } if |
|---|
| 5740 | |
|---|
| 5741 | n1 1 n2 { |
|---|
| 5742 | /i exch def |
|---|
| 5743 | solid i |
|---|
| 5744 | [A B C D] espacedecouleurs astr2str |
|---|
| 5745 | solidputfcolor |
|---|
| 5746 | } for |
|---|
| 5747 | |
|---|
| 5748 | end |
|---|
| 5749 | } def |
|---|
| 5750 | |
|---|
| 5751 | %%%%% ### solidrmface ### |
|---|
| 5752 | %% syntaxe : solid i solidrmface -> - |
|---|
| 5753 | /solidrmface { |
|---|
| 5754 | 5 dict begin |
|---|
| 5755 | /i exch def |
|---|
| 5756 | /solid exch def |
|---|
| 5757 | solid issolid not { |
|---|
| 5758 | (Error : mauvais type d argument dans solidrmface) == |
|---|
| 5759 | quit |
|---|
| 5760 | } if |
|---|
| 5761 | %% on enleve la face |
|---|
| 5762 | /F solid solidgetfaces def |
|---|
| 5763 | F length 1 sub i lt { |
|---|
| 5764 | (Error : indice trop grand dans solidrmface) == |
|---|
| 5765 | quit |
|---|
| 5766 | } if |
|---|
| 5767 | [ |
|---|
| 5768 | 0 1 F length 1 sub { |
|---|
| 5769 | /j exch def |
|---|
| 5770 | i j ne { |
|---|
| 5771 | F j get |
|---|
| 5772 | } if |
|---|
| 5773 | } for |
|---|
| 5774 | ] |
|---|
| 5775 | /NF exch def |
|---|
| 5776 | solid NF solidputfaces |
|---|
| 5777 | %% on enleve la couleur correspondante |
|---|
| 5778 | /FC solid solidgetfcolors def |
|---|
| 5779 | [ |
|---|
| 5780 | 0 1 FC length 1 sub { |
|---|
| 5781 | /j exch def |
|---|
| 5782 | i j ne { |
|---|
| 5783 | FC j get |
|---|
| 5784 | } if |
|---|
| 5785 | } for |
|---|
| 5786 | ] |
|---|
| 5787 | /NFC exch def |
|---|
| 5788 | solid NFC solidputfcolors |
|---|
| 5789 | %% on ajuste la table inout |
|---|
| 5790 | /IO solid solidgetinouttable def |
|---|
| 5791 | solid i solidisoutface { |
|---|
| 5792 | IO 1 IO 1 get 1 sub put |
|---|
| 5793 | solid solidwithinfaces { |
|---|
| 5794 | IO 2 IO 2 get 1 sub put |
|---|
| 5795 | IO 3 IO 3 get 1 sub put |
|---|
| 5796 | } if |
|---|
| 5797 | } if |
|---|
| 5798 | solid i solidisinface { |
|---|
| 5799 | IO 1 IO 1 get 1 sub put |
|---|
| 5800 | IO 2 IO 2 get 1 sub put |
|---|
| 5801 | IO 3 IO 3 get 1 sub put |
|---|
| 5802 | } if |
|---|
| 5803 | solid IO solidputinouttable |
|---|
| 5804 | end |
|---|
| 5805 | } def |
|---|
| 5806 | |
|---|
| 5807 | %% syntaxe : solid table solidrmfaces --> - |
|---|
| 5808 | /solidrmfaces { |
|---|
| 5809 | 2 dict begin |
|---|
| 5810 | /table exch bubblesort reverse def |
|---|
| 5811 | /solid exch def |
|---|
| 5812 | table {solid exch solidrmface} apply |
|---|
| 5813 | end |
|---|
| 5814 | } def |
|---|
| 5815 | |
|---|
| 5816 | %%%%% ### videsolid ### |
|---|
| 5817 | %% syntaxe : solid videsolid -> - |
|---|
| 5818 | /videsolid { |
|---|
| 5819 | 5 dict begin |
|---|
| 5820 | /solid exch def |
|---|
| 5821 | solid issolid not { |
|---|
| 5822 | (Error : mauvais type d argument dans videsolid) == |
|---|
| 5823 | quit |
|---|
| 5824 | } if |
|---|
| 5825 | solid solidwithinfaces not { |
|---|
| 5826 | /IO solid solidgetinouttable def |
|---|
| 5827 | /FE solid solidgetfaces def |
|---|
| 5828 | /n FE length def |
|---|
| 5829 | IO 2 n put |
|---|
| 5830 | IO 3 2 n mul 1 sub put |
|---|
| 5831 | solid IO solidputinouttable |
|---|
| 5832 | %% on inverse chaque face |
|---|
| 5833 | /FI FE {reverse} apply def |
|---|
| 5834 | solid FE FI append solidputfaces |
|---|
| 5835 | %% et on rajoute autant de couleurs vides que de faces |
|---|
| 5836 | /FEC solid solidgetfcolors def |
|---|
| 5837 | % /FIC [FI length {()} repeat] def |
|---|
| 5838 | % solid FEC FIC append solidputfcolors |
|---|
| 5839 | solid FEC duparray append solidputfcolors |
|---|
| 5840 | } if |
|---|
| 5841 | end |
|---|
| 5842 | } def |
|---|
| 5843 | |
|---|
| 5844 | %%%%% ### solidnumfaces ### |
|---|
| 5845 | %% syntaxe : solid array solidnumfaces |
|---|
| 5846 | %% syntaxe : solid array bool solidnumfaces |
|---|
| 5847 | %% array, le tableau des indices des faces a numeroter, est optionnel |
|---|
| 5848 | %% si bool=true, on ne numerote que les faces visibles |
|---|
| 5849 | /solidnumfaces { |
|---|
| 5850 | 5 dict begin |
|---|
| 5851 | dup isbool { |
|---|
| 5852 | /bool exch def |
|---|
| 5853 | } { |
|---|
| 5854 | /bool true def |
|---|
| 5855 | } ifelse |
|---|
| 5856 | % setTimes |
|---|
| 5857 | dup issolid not { |
|---|
| 5858 | %% on a un argument |
|---|
| 5859 | /option exch def |
|---|
| 5860 | } if |
|---|
| 5861 | /sol exch def |
|---|
| 5862 | /n sol solidnombrefaces def |
|---|
| 5863 | currentdict /option known not { |
|---|
| 5864 | /option [0 1 n 1 sub {} for] def |
|---|
| 5865 | } if |
|---|
| 5866 | |
|---|
| 5867 | 0 1 option length 1 sub { |
|---|
| 5868 | /i exch def |
|---|
| 5869 | /j option i get def |
|---|
| 5870 | j ( ) cvs sol j bool cctextp3d |
|---|
| 5871 | } for |
|---|
| 5872 | end |
|---|
| 5873 | } def |
|---|
| 5874 | |
|---|
| 5875 | %%%%% ### creusesolid ### |
|---|
| 5876 | %% syntaxe : solid creusesolid -> - |
|---|
| 5877 | /creusesolid { |
|---|
| 5878 | 5 dict begin |
|---|
| 5879 | /solid exch def |
|---|
| 5880 | solid issolid not { |
|---|
| 5881 | (Error : mauvais type d argument dans creusesolid) == |
|---|
| 5882 | quit |
|---|
| 5883 | } if |
|---|
| 5884 | %% on enleve le fond et le chapeau |
|---|
| 5885 | solid 1 solidrmface |
|---|
| 5886 | solid 0 solidrmface |
|---|
| 5887 | %% on inverse chaque face |
|---|
| 5888 | solid videsolid |
|---|
| 5889 | end |
|---|
| 5890 | } def |
|---|
| 5891 | |
|---|
| 5892 | %%%%% ### fin insertion ### |
|---|
| 5893 | |
|---|
| 5894 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 5895 | %%%% dessin des solides %%%% |
|---|
| 5896 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 5897 | |
|---|
| 5898 | %%%%% ### solidisinface ### |
|---|
| 5899 | %% syntaxe : solid i solidisinface --> bool |
|---|
| 5900 | %% true si i est l indice d une face interne, false sinon |
|---|
| 5901 | /solidisinface { |
|---|
| 5902 | 4 dict begin |
|---|
| 5903 | /i exch def |
|---|
| 5904 | solidgetinouttable /IO exch def |
|---|
| 5905 | /n1 IO 2 get def |
|---|
| 5906 | /n2 IO 3 get def |
|---|
| 5907 | n1 i le |
|---|
| 5908 | i n2 le and |
|---|
| 5909 | end |
|---|
| 5910 | } def |
|---|
| 5911 | |
|---|
| 5912 | %%%%% ### solidisoutface ### |
|---|
| 5913 | %% syntaxe : solid i solidisoutface --> bool |
|---|
| 5914 | %% true si i est l indice d une face externe, false sinon |
|---|
| 5915 | /solidisoutface { |
|---|
| 5916 | 4 dict begin |
|---|
| 5917 | /i exch def |
|---|
| 5918 | solidgetinouttable /IO exch def |
|---|
| 5919 | /n1 IO 0 get def |
|---|
| 5920 | /n2 IO 1 get def |
|---|
| 5921 | n1 i le |
|---|
| 5922 | i n2 le and |
|---|
| 5923 | end |
|---|
| 5924 | } def |
|---|
| 5925 | |
|---|
| 5926 | %%%%% ### planvisible ### |
|---|
| 5927 | %% syntaxe : A k planvisible? --> true si le plan est visible |
|---|
| 5928 | /planvisible? { |
|---|
| 5929 | 4 dict begin |
|---|
| 5930 | /normale_plan defpoint3d |
|---|
| 5931 | /origine defpoint3d |
|---|
| 5932 | /ligne_de_vue { |
|---|
| 5933 | origine |
|---|
| 5934 | GetCamPos |
|---|
| 5935 | vecteur3d |
|---|
| 5936 | } def |
|---|
| 5937 | ligne_de_vue normale_plan scalprod3d 0 gt |
|---|
| 5938 | end |
|---|
| 5939 | } def |
|---|
| 5940 | |
|---|
| 5941 | %%%%% ### solidlight ### |
|---|
| 5942 | /setlightintensity { |
|---|
| 5943 | /lightintensity exch def |
|---|
| 5944 | } def |
|---|
| 5945 | |
|---|
| 5946 | /setlightsrc { |
|---|
| 5947 | /lightsrc defpoint3d |
|---|
| 5948 | } def |
|---|
| 5949 | |
|---|
| 5950 | /setlight { |
|---|
| 5951 | 1 dict begin |
|---|
| 5952 | gsave |
|---|
| 5953 | exec |
|---|
| 5954 | [ currentrgbcolor ] /lightcolor exch |
|---|
| 5955 | grestore |
|---|
| 5956 | end |
|---|
| 5957 | def |
|---|
| 5958 | } def |
|---|
| 5959 | |
|---|
| 5960 | %%%%% ### drawsolid ### |
|---|
| 5961 | /solidlightOn { |
|---|
| 5962 | /s@lidlight true def |
|---|
| 5963 | } def |
|---|
| 5964 | /solidlightOff { |
|---|
| 5965 | /s@lidlight false def |
|---|
| 5966 | } def |
|---|
| 5967 | solidlightOff |
|---|
| 5968 | |
|---|
| 5969 | %% syntaxe : solid i solidfacevisible? --> true si la face est visible |
|---|
| 5970 | /solidfacevisible? { |
|---|
| 5971 | 4 dict begin |
|---|
| 5972 | /i exch def |
|---|
| 5973 | /solid exch def |
|---|
| 5974 | solid issolid not { |
|---|
| 5975 | (Error : mauvais type d argument dans solidgetsommetface) == |
|---|
| 5976 | quit |
|---|
| 5977 | } if |
|---|
| 5978 | solid i solidgetface length 2 le { |
|---|
| 5979 | true |
|---|
| 5980 | } { |
|---|
| 5981 | /ligne_de_vue { |
|---|
| 5982 | solid i solidcentreface |
|---|
| 5983 | GetCamPos |
|---|
| 5984 | vecteur3d |
|---|
| 5985 | } def |
|---|
| 5986 | |
|---|
| 5987 | /normale_face { |
|---|
| 5988 | solid i solidnormaleface |
|---|
| 5989 | } def |
|---|
| 5990 | ligne_de_vue normale_face scalprod3d 0 gt |
|---|
| 5991 | } ifelse |
|---|
| 5992 | end |
|---|
| 5993 | } def |
|---|
| 5994 | |
|---|
| 5995 | %% syntaxe : solid i affectecouleursolid_facei --> si la couleur de |
|---|
| 5996 | %% la face i est definie, affecte fillstyle a cette couleur |
|---|
| 5997 | /affectecouleursolid_facei { |
|---|
| 5998 | 3 dict begin |
|---|
| 5999 | /i exch def |
|---|
| 6000 | /solid exch def |
|---|
| 6001 | solid solidgetfcolors /FC exch def |
|---|
| 6002 | FC length 1 sub i ge { |
|---|
| 6003 | FC i get length 1 ge { |
|---|
| 6004 | /fillstyle FC i get ( Fill) append cvx |
|---|
| 6005 | solidgrid not { |
|---|
| 6006 | FC i get cvx exec |
|---|
| 6007 | } if |
|---|
| 6008 | true |
|---|
| 6009 | } { |
|---|
| 6010 | false |
|---|
| 6011 | } ifelse |
|---|
| 6012 | } { |
|---|
| 6013 | false |
|---|
| 6014 | } ifelse |
|---|
| 6015 | end |
|---|
| 6016 | {def} if |
|---|
| 6017 | } def |
|---|
| 6018 | |
|---|
| 6019 | %% syntaxe : solid i dessinefacecachee |
|---|
| 6020 | /dessinefacecachee { |
|---|
| 6021 | 11 dict begin |
|---|
| 6022 | /i exch def |
|---|
| 6023 | /solid exch def |
|---|
| 6024 | solid issolid not { |
|---|
| 6025 | (Error : mauvais type d argument dans dessinefacecachee) == |
|---|
| 6026 | quit |
|---|
| 6027 | } if |
|---|
| 6028 | |
|---|
| 6029 | /F solid solidgetfaces def |
|---|
| 6030 | /S solid solidgetsommets def |
|---|
| 6031 | |
|---|
| 6032 | %% face cachee => on prend chacune des aretes de la face et on |
|---|
| 6033 | %% la dessine |
|---|
| 6034 | 4 dict begin |
|---|
| 6035 | /n F i get length def %% nb de sommets de la face |
|---|
| 6036 | 0 1 n 1 sub { |
|---|
| 6037 | /k exch def |
|---|
| 6038 | /k1 F i k get_ij def %% indice sommet1 |
|---|
| 6039 | /k2 F i k 1 add n mod get_ij def %% indice sommet2 |
|---|
| 6040 | gsave |
|---|
| 6041 | currentlinewidth .5 mul setlinewidth |
|---|
| 6042 | pointilles |
|---|
| 6043 | [S k1 getp3d |
|---|
| 6044 | S k2 getp3d sortp3d] ligne3d |
|---|
| 6045 | grestore |
|---|
| 6046 | } for |
|---|
| 6047 | |
|---|
| 6048 | %% trace de la ligne de niveau |
|---|
| 6049 | solidintersectiontype 0 ge { |
|---|
| 6050 | /face_a_dessiner [ %% face visible : F [i] |
|---|
| 6051 | 0 1 n 1 sub { |
|---|
| 6052 | /j exch def |
|---|
| 6053 | solid j i solidgetsommetface |
|---|
| 6054 | } for |
|---|
| 6055 | ] def |
|---|
| 6056 | 0 1 solidintersectionplan length 1 sub { |
|---|
| 6057 | /k exch def |
|---|
| 6058 | /lignedeniveau [] def |
|---|
| 6059 | gsave |
|---|
| 6060 | solidintersectiontype 0 eq { |
|---|
| 6061 | pointilles |
|---|
| 6062 | } { |
|---|
| 6063 | continu |
|---|
| 6064 | } ifelse |
|---|
| 6065 | k solidintersectionlinewidth length lt { |
|---|
| 6066 | solidintersectionlinewidth k get setlinewidth |
|---|
| 6067 | } { |
|---|
| 6068 | solidintersectionlinewidth 0 get setlinewidth |
|---|
| 6069 | } ifelse |
|---|
| 6070 | k solidintersectioncolor length lt { |
|---|
| 6071 | solidintersectioncolor k get cvx exec |
|---|
| 6072 | } { |
|---|
| 6073 | solidintersectioncolor 0 get cvx exec |
|---|
| 6074 | } ifelse |
|---|
| 6075 | 0 1 n 1 sub { |
|---|
| 6076 | /j exch def |
|---|
| 6077 | face_a_dessiner j getp3d |
|---|
| 6078 | face_a_dessiner j 1 add n mod getp3d |
|---|
| 6079 | solidintersectionplan k get |
|---|
| 6080 | dup isarray { |
|---|
| 6081 | segment_inter_plan |
|---|
| 6082 | } { |
|---|
| 6083 | segment_inter_planz |
|---|
| 6084 | } ifelse { |
|---|
| 6085 | 1 dict begin |
|---|
| 6086 | /table exch def |
|---|
| 6087 | table length 6 eq { |
|---|
| 6088 | /lignedeniveau table store |
|---|
| 6089 | exit |
|---|
| 6090 | } { |
|---|
| 6091 | /lignedeniveau [ |
|---|
| 6092 | lignedeniveau aload pop |
|---|
| 6093 | table 0 getp3d |
|---|
| 6094 | ] store |
|---|
| 6095 | } ifelse |
|---|
| 6096 | end |
|---|
| 6097 | } if |
|---|
| 6098 | } for |
|---|
| 6099 | |
|---|
| 6100 | %% dessin de la ligne |
|---|
| 6101 | lignedeniveau length 4 ge { |
|---|
| 6102 | [lignedeniveau aload pop sortp3d] ligne3d |
|---|
| 6103 | } if |
|---|
| 6104 | grestore |
|---|
| 6105 | } for |
|---|
| 6106 | } if |
|---|
| 6107 | |
|---|
| 6108 | end |
|---|
| 6109 | end |
|---|
| 6110 | } def |
|---|
| 6111 | |
|---|
| 6112 | %% syntaxe : solid i dessinefacevisible |
|---|
| 6113 | /dessinefacevisible { |
|---|
| 6114 | 8 dict begin |
|---|
| 6115 | /i exch def |
|---|
| 6116 | /solid exch def |
|---|
| 6117 | solid issolid not { |
|---|
| 6118 | (Error : mauvais type d argument dans dessinefacevisible) == |
|---|
| 6119 | quit |
|---|
| 6120 | } if |
|---|
| 6121 | /F solid solidgetfaces def |
|---|
| 6122 | /S solid solidgetsommets def |
|---|
| 6123 | |
|---|
| 6124 | /n F i get length def %% nb de sommets de la face |
|---|
| 6125 | |
|---|
| 6126 | startest { |
|---|
| 6127 | s@lidlight { |
|---|
| 6128 | /coeff |
|---|
| 6129 | lightintensity |
|---|
| 6130 | solid i solidnormaleface normalize3d |
|---|
| 6131 | solid i solidcentreface lightsrc vecteur3d normalize3d |
|---|
| 6132 | scalprod3d mul |
|---|
| 6133 | 0 max 1 min |
|---|
| 6134 | def |
|---|
| 6135 | /lightcolor where { |
|---|
| 6136 | pop |
|---|
| 6137 | /lacouleur lightcolor def |
|---|
| 6138 | } { |
|---|
| 6139 | /lacouleur [ |
|---|
| 6140 | gsave |
|---|
| 6141 | solid solidgetfcolors i get cvx exec currentrgbcolor |
|---|
| 6142 | grestore |
|---|
| 6143 | ] def |
|---|
| 6144 | } ifelse |
|---|
| 6145 | /fillstyle { |
|---|
| 6146 | lacouleur {coeff mul} apply setcolor Fill |
|---|
| 6147 | } def |
|---|
| 6148 | solidgrid not { |
|---|
| 6149 | lacouleur {coeff mul} apply setcolor |
|---|
| 6150 | } if |
|---|
| 6151 | } { |
|---|
| 6152 | n 2 eq { |
|---|
| 6153 | 1 dict begin |
|---|
| 6154 | solidgridOff |
|---|
| 6155 | solid i affectecouleursolid_facei |
|---|
| 6156 | end |
|---|
| 6157 | } { |
|---|
| 6158 | solid i affectecouleursolid_facei |
|---|
| 6159 | } ifelse |
|---|
| 6160 | } ifelse |
|---|
| 6161 | } if |
|---|
| 6162 | |
|---|
| 6163 | /face_a_dessiner [ %% face visible : F [i] |
|---|
| 6164 | 0 1 n 1 sub { |
|---|
| 6165 | /j exch def |
|---|
| 6166 | solid j i solidgetsommetface |
|---|
| 6167 | } for |
|---|
| 6168 | ] def |
|---|
| 6169 | face_a_dessiner polygone3d |
|---|
| 6170 | |
|---|
| 6171 | %% trace de la ligne de niveau |
|---|
| 6172 | solidintersectiontype 0 ge { |
|---|
| 6173 | 0 1 solidintersectionplan length 1 sub { |
|---|
| 6174 | /k exch def |
|---|
| 6175 | /lignedeniveau [] def |
|---|
| 6176 | gsave |
|---|
| 6177 | k solidintersectionlinewidth length lt { |
|---|
| 6178 | solidintersectionlinewidth k get setlinewidth |
|---|
| 6179 | } { |
|---|
| 6180 | solidintersectionlinewidth 0 get setlinewidth |
|---|
| 6181 | } ifelse |
|---|
| 6182 | k solidintersectioncolor length lt { |
|---|
| 6183 | solidintersectioncolor k get cvx exec |
|---|
| 6184 | } { |
|---|
| 6185 | solidintersectioncolor 0 get cvx exec |
|---|
| 6186 | } ifelse |
|---|
| 6187 | 0 1 n 1 sub { |
|---|
| 6188 | /j exch def |
|---|
| 6189 | face_a_dessiner j getp3d |
|---|
| 6190 | face_a_dessiner j 1 add n mod getp3d |
|---|
| 6191 | solidintersectionplan k get |
|---|
| 6192 | dup isarray { |
|---|
| 6193 | segment_inter_plan |
|---|
| 6194 | } { |
|---|
| 6195 | segment_inter_planz |
|---|
| 6196 | } ifelse { |
|---|
| 6197 | 1 dict begin |
|---|
| 6198 | /table exch def |
|---|
| 6199 | /lignedeniveau [ |
|---|
| 6200 | lignedeniveau aload pop |
|---|
| 6201 | table 0 getp3d |
|---|
| 6202 | table length 4 ge { |
|---|
| 6203 | table 1 getp3d |
|---|
| 6204 | } if |
|---|
| 6205 | ] store |
|---|
| 6206 | end |
|---|
| 6207 | } if |
|---|
| 6208 | } for |
|---|
| 6209 | |
|---|
| 6210 | %% dessin de la ligne |
|---|
| 6211 | lignedeniveau length 4 ge { |
|---|
| 6212 | solid i solidisinface solidintersectiontype 0 eq and { |
|---|
| 6213 | pointilles |
|---|
| 6214 | } if |
|---|
| 6215 | lignedeniveau ligne3d |
|---|
| 6216 | } if |
|---|
| 6217 | grestore |
|---|
| 6218 | } for |
|---|
| 6219 | } if |
|---|
| 6220 | |
|---|
| 6221 | end |
|---|
| 6222 | } def |
|---|
| 6223 | |
|---|
| 6224 | /drawsolid* { |
|---|
| 6225 | 1 dict begin |
|---|
| 6226 | /startest {true} def |
|---|
| 6227 | drawsolid |
|---|
| 6228 | end |
|---|
| 6229 | } def |
|---|
| 6230 | |
|---|
| 6231 | /peintrealgorithme false def |
|---|
| 6232 | |
|---|
| 6233 | /drawsolid** { |
|---|
| 6234 | 2 dict begin |
|---|
| 6235 | /aretescachees false def |
|---|
| 6236 | /peintrealgorithme true def |
|---|
| 6237 | drawsolid* |
|---|
| 6238 | end |
|---|
| 6239 | } def |
|---|
| 6240 | |
|---|
| 6241 | %% syntaxe : solid array drawsolid |
|---|
| 6242 | %% array est en option, il indique les faces triees |
|---|
| 6243 | /drawsolid { |
|---|
| 6244 | 8 dict begin |
|---|
| 6245 | dup issolid not { |
|---|
| 6246 | /ordre exch def |
|---|
| 6247 | } if |
|---|
| 6248 | /solid exch def |
|---|
| 6249 | solid issolid not { |
|---|
| 6250 | (Error : mauvais type d argument dans drawsolid) == |
|---|
| 6251 | quit |
|---|
| 6252 | } if |
|---|
| 6253 | solid nullsolid not { |
|---|
| 6254 | solid solidgetfaces |
|---|
| 6255 | /F exch def |
|---|
| 6256 | solid solidgetsommets |
|---|
| 6257 | /S exch def |
|---|
| 6258 | /n S length 3 idiv def |
|---|
| 6259 | |
|---|
| 6260 | currentdict /ordre known not { |
|---|
| 6261 | peintrealgorithme { |
|---|
| 6262 | %% tri des indices des faces par distance decroissante |
|---|
| 6263 | [ |
|---|
| 6264 | 0 1 F length 1 sub { |
|---|
| 6265 | /i exch def |
|---|
| 6266 | solid i solidcentreface |
|---|
| 6267 | GetCamPos |
|---|
| 6268 | distance3d |
|---|
| 6269 | } for |
|---|
| 6270 | ] doublequicksort pop reverse |
|---|
| 6271 | } { |
|---|
| 6272 | [ |
|---|
| 6273 | 0 1 F length 1 sub { |
|---|
| 6274 | } for |
|---|
| 6275 | ] |
|---|
| 6276 | } ifelse |
|---|
| 6277 | /ordre exch def |
|---|
| 6278 | } if |
|---|
| 6279 | |
|---|
| 6280 | 0 1 F length 1 sub { |
|---|
| 6281 | /k exch def |
|---|
| 6282 | /i ordre k get def |
|---|
| 6283 | gsave |
|---|
| 6284 | solid i solidfacevisible? { |
|---|
| 6285 | solid i dessinefacevisible |
|---|
| 6286 | } if |
|---|
| 6287 | grestore |
|---|
| 6288 | } for |
|---|
| 6289 | aretescachees { |
|---|
| 6290 | 0 1 F length 1 sub { |
|---|
| 6291 | /k exch def |
|---|
| 6292 | /i ordre k get def |
|---|
| 6293 | gsave |
|---|
| 6294 | solid i solidfacevisible? not { |
|---|
| 6295 | solid i dessinefacecachee |
|---|
| 6296 | } if |
|---|
| 6297 | grestore |
|---|
| 6298 | } for |
|---|
| 6299 | } if |
|---|
| 6300 | |
|---|
| 6301 | %% %% si on veut repasser les traits des faces visibles |
|---|
| 6302 | %% 0 1 F length 1 sub { |
|---|
| 6303 | %% /k exch def |
|---|
| 6304 | %% /i ordre k get def |
|---|
| 6305 | %% gsave |
|---|
| 6306 | %% 1 dict begin |
|---|
| 6307 | %% /startest false def |
|---|
| 6308 | %% solid i solidfacevisible? { |
|---|
| 6309 | %% solid i dessinefacevisible |
|---|
| 6310 | %% } if |
|---|
| 6311 | %% end |
|---|
| 6312 | %% grestore |
|---|
| 6313 | %% } for |
|---|
| 6314 | } if |
|---|
| 6315 | end |
|---|
| 6316 | } def |
|---|
| 6317 | |
|---|
| 6318 | %%%%% ### segment_inter_planz ### |
|---|
| 6319 | %% syntaxe : A B k segment_inter_planz --> array true ou false |
|---|
| 6320 | /segment_inter_planz { |
|---|
| 6321 | 4 dict begin |
|---|
| 6322 | /k exch def |
|---|
| 6323 | /B defpoint3d |
|---|
| 6324 | /A defpoint3d |
|---|
| 6325 | A /zA exch def pop pop |
|---|
| 6326 | B /zB exch def pop pop |
|---|
| 6327 | zA k sub zB k sub mul dup 0 gt { |
|---|
| 6328 | %% pas d intersection |
|---|
| 6329 | pop |
|---|
| 6330 | false |
|---|
| 6331 | } { |
|---|
| 6332 | 0 eq { |
|---|
| 6333 | %% intersection en A ou en B |
|---|
| 6334 | [ |
|---|
| 6335 | zA k eq {A} if |
|---|
| 6336 | zB k eq {B} if |
|---|
| 6337 | ] true |
|---|
| 6338 | } { |
|---|
| 6339 | %% intersection entre A et B |
|---|
| 6340 | [ |
|---|
| 6341 | A B vecteur3d |
|---|
| 6342 | k zA sub zB zA sub div mulv3d |
|---|
| 6343 | A addv3d |
|---|
| 6344 | ] true |
|---|
| 6345 | } ifelse |
|---|
| 6346 | } ifelse |
|---|
| 6347 | end |
|---|
| 6348 | } def |
|---|
| 6349 | |
|---|
| 6350 | %%%%% ### fin insertion ### |
|---|
| 6351 | |
|---|
| 6352 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 6353 | %%%% plans affines %%%% |
|---|
| 6354 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 6355 | |
|---|
| 6356 | %%%%% ### planaffine ### |
|---|
| 6357 | %% plan : origine, base, range, ngrid |
|---|
| 6358 | %% [0 0 0 [1 0 0 0 1 0] [-3 3 -2 2] [1. 1.] ] |
|---|
| 6359 | |
|---|
| 6360 | /explan [0 0 0 [1 0 0 0 1 0 0 0 1] [-3 3 -2 2] [1. 1.] ] def |
|---|
| 6361 | |
|---|
| 6362 | %% syntaxe : any isplan --> bool |
|---|
| 6363 | /isplan { |
|---|
| 6364 | 1 dict begin |
|---|
| 6365 | /candidat exch def |
|---|
| 6366 | candidat isarray { |
|---|
| 6367 | candidat length 6 eq { |
|---|
| 6368 | candidat 3 get isarray { |
|---|
| 6369 | candidat 4 get isarray { |
|---|
| 6370 | candidat 5 get isarray |
|---|
| 6371 | } { |
|---|
| 6372 | false |
|---|
| 6373 | } ifelse |
|---|
| 6374 | } { |
|---|
| 6375 | false |
|---|
| 6376 | } ifelse |
|---|
| 6377 | } { |
|---|
| 6378 | false |
|---|
| 6379 | } ifelse |
|---|
| 6380 | } { |
|---|
| 6381 | false |
|---|
| 6382 | } ifelse |
|---|
| 6383 | end |
|---|
| 6384 | } def |
|---|
| 6385 | |
|---|
| 6386 | /newplanaffine { |
|---|
| 6387 | [0 0 0 [1 0 0 0 1 0] [-3 3 -2 2] [1 1]] |
|---|
| 6388 | } def |
|---|
| 6389 | |
|---|
| 6390 | /dupplan { |
|---|
| 6391 | 4 dict begin |
|---|
| 6392 | /leplan exch def |
|---|
| 6393 | /result newplanaffine def |
|---|
| 6394 | result leplan plangetorigine planputorigine |
|---|
| 6395 | result leplan plangetbase planputbase |
|---|
| 6396 | result leplan plangetrange planputrange |
|---|
| 6397 | result leplan plangetngrid planputngrid |
|---|
| 6398 | result |
|---|
| 6399 | end |
|---|
| 6400 | } def |
|---|
| 6401 | |
|---|
| 6402 | %% syntaxe : plantype getorigine --> x y z |
|---|
| 6403 | /plangetorigine { |
|---|
| 6404 | 1 dict begin |
|---|
| 6405 | /plan exch def |
|---|
| 6406 | plan isplan not { |
|---|
| 6407 | (Erreur : mauvais type d argument dans plangetorigine) == |
|---|
| 6408 | Error |
|---|
| 6409 | } if |
|---|
| 6410 | plan 0 get |
|---|
| 6411 | plan 1 get |
|---|
| 6412 | plan 2 get |
|---|
| 6413 | end |
|---|
| 6414 | } def |
|---|
| 6415 | |
|---|
| 6416 | %% syntaxe : plantype getbase --> [u v] |
|---|
| 6417 | %% ou u, v et w vecteurs de R^3 |
|---|
| 6418 | /plangetbase { |
|---|
| 6419 | 1 dict begin |
|---|
| 6420 | /plan exch def |
|---|
| 6421 | plan isplan not { |
|---|
| 6422 | (Erreur : mauvais type d argument dans plangetbase) == |
|---|
| 6423 | Error |
|---|
| 6424 | } if |
|---|
| 6425 | plan 3 get |
|---|
| 6426 | end |
|---|
| 6427 | } def |
|---|
| 6428 | |
|---|
| 6429 | %% syntaxe : plantype getrange --> array |
|---|
| 6430 | %% ou array = [xmin xmax ymin ymax] |
|---|
| 6431 | /plangetrange { |
|---|
| 6432 | 1 dict begin |
|---|
| 6433 | /plan exch def |
|---|
| 6434 | plan isplan not { |
|---|
| 6435 | (Erreur : mauvais type d argument dans plangetrange) == |
|---|
| 6436 | Error |
|---|
| 6437 | } if |
|---|
| 6438 | plan 4 get |
|---|
| 6439 | end |
|---|
| 6440 | } def |
|---|
| 6441 | |
|---|
| 6442 | %% syntaxe : plantype getngrid --> array |
|---|
| 6443 | %% ou array = [n1 n2] |
|---|
| 6444 | /plangetngrid { |
|---|
| 6445 | 1 dict begin |
|---|
| 6446 | /plan exch def |
|---|
| 6447 | plan isplan not { |
|---|
| 6448 | (Erreur : mauvais type d argument dans plangetngrid) == |
|---|
| 6449 | Error |
|---|
| 6450 | } if |
|---|
| 6451 | plan 5 get |
|---|
| 6452 | end |
|---|
| 6453 | } def |
|---|
| 6454 | |
|---|
| 6455 | %% =================== |
|---|
| 6456 | |
|---|
| 6457 | %% syntaxe : plantype x y z putorigine --> - |
|---|
| 6458 | /planputorigine { |
|---|
| 6459 | 4 dict begin |
|---|
| 6460 | /z exch def |
|---|
| 6461 | /y exch def |
|---|
| 6462 | /x exch def |
|---|
| 6463 | /plan exch def |
|---|
| 6464 | plan isplan not { |
|---|
| 6465 | (Erreur : mauvais type d argument dans planputorigine) == |
|---|
| 6466 | Error |
|---|
| 6467 | } if |
|---|
| 6468 | plan 0 x put |
|---|
| 6469 | plan 1 y put |
|---|
| 6470 | plan 2 z put |
|---|
| 6471 | end |
|---|
| 6472 | } def |
|---|
| 6473 | |
|---|
| 6474 | %% syntaxe : plantype [u v w] putbase --> - |
|---|
| 6475 | %% ou u, v et w vecteurs de R^3 |
|---|
| 6476 | /planputbase { |
|---|
| 6477 | 2 dict begin |
|---|
| 6478 | /base exch def |
|---|
| 6479 | /plan exch def |
|---|
| 6480 | plan isplan not { |
|---|
| 6481 | (Erreur : mauvais type d argument dans planputbase) == |
|---|
| 6482 | Error |
|---|
| 6483 | } if |
|---|
| 6484 | plan 3 base put |
|---|
| 6485 | end |
|---|
| 6486 | } def |
|---|
| 6487 | |
|---|
| 6488 | %% syntaxe : plantype array putrange --> - |
|---|
| 6489 | %% ou array = [xmin xmax ymin ymax] |
|---|
| 6490 | /planputrange { |
|---|
| 6491 | 2 dict begin |
|---|
| 6492 | /table exch def |
|---|
| 6493 | /plan exch def |
|---|
| 6494 | plan isplan not { |
|---|
| 6495 | (Erreur : mauvais type d argument dans planputrange) == |
|---|
| 6496 | Error |
|---|
| 6497 | } if |
|---|
| 6498 | plan 4 table put |
|---|
| 6499 | end |
|---|
| 6500 | } def |
|---|
| 6501 | |
|---|
| 6502 | %% syntaxe : plantype array putngrid --> - |
|---|
| 6503 | %% ou array = [n1 n2] |
|---|
| 6504 | /planputngrid { |
|---|
| 6505 | 2 dict begin |
|---|
| 6506 | /table exch def |
|---|
| 6507 | /plan exch def |
|---|
| 6508 | plan isplan not { |
|---|
| 6509 | (Erreur : mauvais type d argument dans planputngrid) == |
|---|
| 6510 | quit |
|---|
| 6511 | } if |
|---|
| 6512 | plan 5 table put |
|---|
| 6513 | end |
|---|
| 6514 | } def |
|---|
| 6515 | |
|---|
| 6516 | %% -3 3 -2 2 1. 1. newgrille |
|---|
| 6517 | %% drawsolid |
|---|
| 6518 | |
|---|
| 6519 | %orange |
|---|
| 6520 | |
|---|
| 6521 | %% plan : origine, base, range, ngrid |
|---|
| 6522 | |
|---|
| 6523 | %% syntaxe : plantype drawplanaffine --> - |
|---|
| 6524 | /drawplanaffine { |
|---|
| 6525 | 5 dict begin |
|---|
| 6526 | /plan exch def |
|---|
| 6527 | plan plangetbase |
|---|
| 6528 | aload pop |
|---|
| 6529 | /imK defpoint3d |
|---|
| 6530 | /imJ defpoint3d |
|---|
| 6531 | /imI defpoint3d |
|---|
| 6532 | newpath |
|---|
| 6533 | plan plangetrange plan plangetngrid aload pop quadrillagexOy_ |
|---|
| 6534 | plan plangetorigine [imI imK] false planprojpath |
|---|
| 6535 | Stroke |
|---|
| 6536 | end |
|---|
| 6537 | } def |
|---|
| 6538 | |
|---|
| 6539 | |
|---|
| 6540 | %% %% syntaxe : [a b c d] (x0 y0 z0) alpha defeqplanaffine --> plantype |
|---|
| 6541 | %% %% plan defini par l equation ax+by+cz+d=0, |
|---|
| 6542 | %% %% rotation de alpha autour de la normale (alpha est optionnel) |
|---|
| 6543 | %% %% origine (x0, y0, z0). l origine est optionnelle |
|---|
| 6544 | %% /defeqplanaffine { |
|---|
| 6545 | %% 5 dict begin |
|---|
| 6546 | %% dup isarray { |
|---|
| 6547 | %% /alpha 0 def |
|---|
| 6548 | %% } { |
|---|
| 6549 | %% dup isstring { |
|---|
| 6550 | %% /alpha 0 def |
|---|
| 6551 | %% } { |
|---|
| 6552 | %% /alpha exch def |
|---|
| 6553 | %% } ifelse |
|---|
| 6554 | %% } ifelse |
|---|
| 6555 | %% dup isstring { |
|---|
| 6556 | %% cvx /origine exch def |
|---|
| 6557 | %% } if |
|---|
| 6558 | %% /table exch def |
|---|
| 6559 | %% table length 4 ne { |
|---|
| 6560 | %% (Erreur : mauvais type d argument dans defeqplanaffine) == |
|---|
| 6561 | %% Error |
|---|
| 6562 | %% } if |
|---|
| 6563 | %% table 0 get /a exch def |
|---|
| 6564 | %% table 1 get /b exch def |
|---|
| 6565 | %% table 2 get /c exch def |
|---|
| 6566 | %% table 3 get /d exch def |
|---|
| 6567 | %% /resultat newplanaffine def |
|---|
| 6568 | %% [a b c alpha] normalvect_to_orthobase |
|---|
| 6569 | %% /imK defpoint3d |
|---|
| 6570 | %% /imJ defpoint3d |
|---|
| 6571 | %% /imI defpoint3d |
|---|
| 6572 | %% resultat [imI imJ imK] planputbase |
|---|
| 6573 | %% currentdict /origine known { |
|---|
| 6574 | %% origine /z exch def /y exch def /x exch def |
|---|
| 6575 | %% a x mul b y mul add c z mul add d add 0 ne { |
|---|
| 6576 | %% (Erreur : mauvaise origine dans defeqplanaffine) == |
|---|
| 6577 | %% Error |
|---|
| 6578 | %% } if |
|---|
| 6579 | %% resultat origine planputorigine |
|---|
| 6580 | %% } { |
|---|
| 6581 | %% c 0 ne { |
|---|
| 6582 | %% resultat 0 0 d neg c div planputorigine |
|---|
| 6583 | %% } { |
|---|
| 6584 | %% a 0 ne { |
|---|
| 6585 | %% resultat d neg a div 0 0 planputorigine |
|---|
| 6586 | %% } { |
|---|
| 6587 | %% resultat 0 d neg b div 0 planputorigine |
|---|
| 6588 | %% } ifelse |
|---|
| 6589 | %% } ifelse |
|---|
| 6590 | %% } ifelse |
|---|
| 6591 | %% resultat |
|---|
| 6592 | %% end |
|---|
| 6593 | %% } def |
|---|
| 6594 | |
|---|
| 6595 | %% /explan [0 0 0 [1 0 0 0 1 0 0 0 1] [-3 3 -2 2] [1 1] ] def |
|---|
| 6596 | %% explan drawplanaffine |
|---|
| 6597 | %% noir |
|---|
| 6598 | %% /explan [0 0 2 [1 0 0 0 1 0 0 0 1] [-3 3 -2 2] [1 .5] ] def |
|---|
| 6599 | %% explan drawplanaffine |
|---|
| 6600 | |
|---|
| 6601 | %% orange |
|---|
| 6602 | %% [0 0 1 -2] defeqplanaffine |
|---|
| 6603 | %% drawplanaffine |
|---|
| 6604 | %% noir |
|---|
| 6605 | %% [0 0 1 0] defeqplanaffine |
|---|
| 6606 | %% drawplanaffine |
|---|
| 6607 | %% bleu |
|---|
| 6608 | %% [1 1 1 0] (1 -1 0) defeqplanaffine |
|---|
| 6609 | %% drawplanaffine |
|---|
| 6610 | %% |
|---|
| 6611 | |
|---|
| 6612 | /dessinebase { |
|---|
| 6613 | 4 dict begin |
|---|
| 6614 | gsave |
|---|
| 6615 | /V3 defpoint3d |
|---|
| 6616 | /V2 defpoint3d |
|---|
| 6617 | /V1 defpoint3d |
|---|
| 6618 | /M0 defpoint3d |
|---|
| 6619 | rouge |
|---|
| 6620 | V3 newvecteur |
|---|
| 6621 | {M0 translatepoint3d} solidtransform |
|---|
| 6622 | drawsolid** |
|---|
| 6623 | bleu |
|---|
| 6624 | V2 newvecteur |
|---|
| 6625 | {M0 translatepoint3d} solidtransform |
|---|
| 6626 | drawsolid** |
|---|
| 6627 | orange |
|---|
| 6628 | V1 newvecteur |
|---|
| 6629 | {M0 translatepoint3d} solidtransform |
|---|
| 6630 | drawsolid** |
|---|
| 6631 | grestore |
|---|
| 6632 | end |
|---|
| 6633 | } def |
|---|
| 6634 | |
|---|
| 6635 | %% syntaxe : solid i solidface2eqplan --> [a b c d] |
|---|
| 6636 | %% equation cartesienne de la face d'indice i du solide solid |
|---|
| 6637 | /solidface2eqplan { |
|---|
| 6638 | 8 dict begin |
|---|
| 6639 | /i exch def |
|---|
| 6640 | /solid exch def |
|---|
| 6641 | solid i solidnormaleface |
|---|
| 6642 | /c exch def |
|---|
| 6643 | /b exch def |
|---|
| 6644 | /a exch def |
|---|
| 6645 | solid 0 i solidgetsommetface |
|---|
| 6646 | /z exch def |
|---|
| 6647 | /y exch def |
|---|
| 6648 | /x exch def |
|---|
| 6649 | [a b c a x mul b y mul add c z mul add neg] |
|---|
| 6650 | end |
|---|
| 6651 | } def |
|---|
| 6652 | |
|---|
| 6653 | |
|---|
| 6654 | %% syntaxe : plantype newplan --> solid |
|---|
| 6655 | /newplan { |
|---|
| 6656 | 5 dict begin |
|---|
| 6657 | /lepl@n exch def |
|---|
| 6658 | lepl@n plangetbase /@base exch def |
|---|
| 6659 | @base 0 getp3d /@U defpoint3d |
|---|
| 6660 | @base 1 getp3d /@V defpoint3d |
|---|
| 6661 | lepl@n plangetorigine /@M defpoint3d |
|---|
| 6662 | lepl@n plangetrange /@range exch def |
|---|
| 6663 | lepl@n plangetngrid /@ngrid exch def |
|---|
| 6664 | /@F { |
|---|
| 6665 | 2 dict begin |
|---|
| 6666 | /@y exch def |
|---|
| 6667 | /@x exch def |
|---|
| 6668 | @U @x mulv3d |
|---|
| 6669 | @V @y mulv3d |
|---|
| 6670 | addv3d |
|---|
| 6671 | @M addv3d |
|---|
| 6672 | end |
|---|
| 6673 | } def |
|---|
| 6674 | @range aload pop @ngrid {@F} newsurfaceparametree |
|---|
| 6675 | end |
|---|
| 6676 | } def |
|---|
| 6677 | |
|---|
| 6678 | %% syntaxe : M eqplan --> real |
|---|
| 6679 | %% image de M par la fonction definie par l equation eqplan |
|---|
| 6680 | /pointeqplan { |
|---|
| 6681 | 8 dict begin |
|---|
| 6682 | /eqplan exch def |
|---|
| 6683 | /@z exch def |
|---|
| 6684 | /@y exch def |
|---|
| 6685 | /@x exch def |
|---|
| 6686 | /@a eqplan 0 get def |
|---|
| 6687 | /@b eqplan 1 get def |
|---|
| 6688 | /@c eqplan 2 get def |
|---|
| 6689 | /@d eqplan 3 get def |
|---|
| 6690 | @a @x mul @b @y mul add @c @z mul add @d add |
|---|
| 6691 | end |
|---|
| 6692 | } def |
|---|
| 6693 | |
|---|
| 6694 | /plan2eq { |
|---|
| 6695 | 6 dict begin |
|---|
| 6696 | /leplan exch def |
|---|
| 6697 | leplan plangetbase aload pop vectprod3d |
|---|
| 6698 | /c exch def |
|---|
| 6699 | /b exch def |
|---|
| 6700 | /a exch def |
|---|
| 6701 | leplan plangetorigine |
|---|
| 6702 | /z0 exch def |
|---|
| 6703 | /y0 exch def |
|---|
| 6704 | /x0 exch def |
|---|
| 6705 | [a b c a x0 mul b y0 mul add c z0 mul add neg] |
|---|
| 6706 | end |
|---|
| 6707 | } def |
|---|
| 6708 | |
|---|
| 6709 | %% syntaxe : [a b c d] (x0 y0 z0) alpha defeqplanaffine --> plantype |
|---|
| 6710 | %% plan defini par l equation ax+by+cz+d=0, |
|---|
| 6711 | %% rotation de alpha autour de la normale (alpha est optionnel) |
|---|
| 6712 | %% origine (x0, y0, z0). l origine est optionnelle |
|---|
| 6713 | /eq2plan { |
|---|
| 6714 | 5 dict begin |
|---|
| 6715 | dup isarray { |
|---|
| 6716 | /alpha 0 def |
|---|
| 6717 | } { |
|---|
| 6718 | dup isstring { |
|---|
| 6719 | /alpha 0 def |
|---|
| 6720 | } { |
|---|
| 6721 | /alpha exch def |
|---|
| 6722 | } ifelse |
|---|
| 6723 | } ifelse |
|---|
| 6724 | dup isstring { |
|---|
| 6725 | cvx /origine exch def |
|---|
| 6726 | } if |
|---|
| 6727 | /table exch def |
|---|
| 6728 | table length 4 ne { |
|---|
| 6729 | (Erreur : mauvais type d argument dans eq2plan) == |
|---|
| 6730 | quit |
|---|
| 6731 | } if |
|---|
| 6732 | table 0 get /a exch def |
|---|
| 6733 | table 1 get /b exch def |
|---|
| 6734 | table 2 get /c exch def |
|---|
| 6735 | table 3 get /d exch def |
|---|
| 6736 | /resultat newplanaffine def |
|---|
| 6737 | [a b c alpha] normalvect_to_orthobase |
|---|
| 6738 | /imK defpoint3d |
|---|
| 6739 | /imJ defpoint3d |
|---|
| 6740 | /imI defpoint3d |
|---|
| 6741 | resultat [imI imJ] planputbase |
|---|
| 6742 | currentdict /origine known { |
|---|
| 6743 | origine /z exch def /y exch def /x exch def |
|---|
| 6744 | a x mul b y mul add c z mul add d add 0 ne { |
|---|
| 6745 | (Erreur : mauvaise origine dans eq2plan) == |
|---|
| 6746 | quit |
|---|
| 6747 | } if |
|---|
| 6748 | resultat origine planputorigine |
|---|
| 6749 | } { |
|---|
| 6750 | c 0 ne { |
|---|
| 6751 | resultat 0 0 d neg c div planputorigine |
|---|
| 6752 | } { |
|---|
| 6753 | a 0 ne { |
|---|
| 6754 | resultat d neg a div 0 0 planputorigine |
|---|
| 6755 | } { |
|---|
| 6756 | b 0 ne { |
|---|
| 6757 | resultat 0 d neg b div 0 planputorigine |
|---|
| 6758 | } { |
|---|
| 6759 | (Error dans eq2plan : (a,b,c) = (0,0,0)) == |
|---|
| 6760 | } ifelse |
|---|
| 6761 | } ifelse |
|---|
| 6762 | } ifelse |
|---|
| 6763 | } ifelse |
|---|
| 6764 | resultat |
|---|
| 6765 | end |
|---|
| 6766 | } def |
|---|
| 6767 | |
|---|
| 6768 | /points2eqplan { |
|---|
| 6769 | 10 dict begin |
|---|
| 6770 | /C defpoint3d |
|---|
| 6771 | /B defpoint3d |
|---|
| 6772 | /A defpoint3d |
|---|
| 6773 | A B vecteur3d |
|---|
| 6774 | A C vecteur3d |
|---|
| 6775 | vectprod3d |
|---|
| 6776 | normalize3d |
|---|
| 6777 | /c exch def |
|---|
| 6778 | /b exch def |
|---|
| 6779 | /a exch def |
|---|
| 6780 | A |
|---|
| 6781 | /zA exch def |
|---|
| 6782 | /yA exch def |
|---|
| 6783 | /xA exch def |
|---|
| 6784 | [a b c a xA mul b yA mul add c zA mul add neg] |
|---|
| 6785 | end |
|---|
| 6786 | } def |
|---|
| 6787 | |
|---|
| 6788 | %% /monplan |
|---|
| 6789 | %% %[0 0 -2 [1 0 0 0 1 0 0 0 1] [-3 3 -2 2] [1. 1.]] |
|---|
| 6790 | %% [0 0 1 1] 30 eq2plan |
|---|
| 6791 | %% def |
|---|
| 6792 | %% |
|---|
| 6793 | %% [0 0 1 -2] eq2plan newplan |
|---|
| 6794 | %% dup (blanc) outputcolors |
|---|
| 6795 | %% monplan newplan |
|---|
| 6796 | %% dup (blanc) outputcolors |
|---|
| 6797 | %% solidfuz |
|---|
| 6798 | %% drawsolid** |
|---|
| 6799 | %% monplan plangetorigine |
|---|
| 6800 | %% monplan plangetbase aload pop dessinebase |
|---|
| 6801 | |
|---|
| 6802 | %% syntaxe : x0 y0 z0 [normalvect] norm2plan |
|---|
| 6803 | /norm2plan { |
|---|
| 6804 | 9 dict begin |
|---|
| 6805 | normalvect_to_orthobase |
|---|
| 6806 | /imK defpoint3d |
|---|
| 6807 | /imJ defpoint3d |
|---|
| 6808 | /imI defpoint3d |
|---|
| 6809 | imK |
|---|
| 6810 | /c exch def |
|---|
| 6811 | /b exch def |
|---|
| 6812 | /a exch def |
|---|
| 6813 | /z0 exch def |
|---|
| 6814 | /y0 exch def |
|---|
| 6815 | /x0 exch def |
|---|
| 6816 | [a b c a x0 mul b y0 mul add c z0 mul add neg] eq2plan |
|---|
| 6817 | dup x0 y0 z0 planputorigine |
|---|
| 6818 | dup [imI imJ] planputbase |
|---|
| 6819 | end |
|---|
| 6820 | } def |
|---|
| 6821 | |
|---|
| 6822 | %% syntaxe : plantype planxmarks |
|---|
| 6823 | /planxmarks { |
|---|
| 6824 | 5 dict begin |
|---|
| 6825 | dup isbool { |
|---|
| 6826 | /mybool exch def |
|---|
| 6827 | } { |
|---|
| 6828 | /mybool true def |
|---|
| 6829 | } ifelse |
|---|
| 6830 | /leplan exch def |
|---|
| 6831 | leplan plangetrange aload pop |
|---|
| 6832 | /ymax exch def |
|---|
| 6833 | /ymin exch def |
|---|
| 6834 | /xmax exch def |
|---|
| 6835 | /xmin exch def |
|---|
| 6836 | newpath |
|---|
| 6837 | xmin truncate cvi 0 smoveto |
|---|
| 6838 | xmax truncate cvi 0 slineto |
|---|
| 6839 | leplan mybool projpath |
|---|
| 6840 | Stroke |
|---|
| 6841 | xmin truncate cvi xmkstep xmax truncate cvi { |
|---|
| 6842 | dup 0 ne { |
|---|
| 6843 | /x exch def |
|---|
| 6844 | x |
|---|
| 6845 | x x truncate eq { |
|---|
| 6846 | cvi |
|---|
| 6847 | } if |
|---|
| 6848 | dup chaine cvs exch 0 leplan mybool dctextp3d |
|---|
| 6849 | newpath |
|---|
| 6850 | x 0 smoveto |
|---|
| 6851 | 0 2.5 rmoveto |
|---|
| 6852 | 0 -5 rlineto |
|---|
| 6853 | leplan mybool projpath |
|---|
| 6854 | Stroke |
|---|
| 6855 | } { |
|---|
| 6856 | pop (0) 0 0 leplan mybool dltextp3d |
|---|
| 6857 | } ifelse |
|---|
| 6858 | } for |
|---|
| 6859 | end |
|---|
| 6860 | } def |
|---|
| 6861 | |
|---|
| 6862 | %% syntaxe : plantype planymarks |
|---|
| 6863 | /planymarks { |
|---|
| 6864 | 5 dict begin |
|---|
| 6865 | dup isbool { |
|---|
| 6866 | /mybool exch def |
|---|
| 6867 | } { |
|---|
| 6868 | /mybool true def |
|---|
| 6869 | } ifelse |
|---|
| 6870 | /leplan exch def |
|---|
| 6871 | leplan plangetrange aload pop |
|---|
| 6872 | /ymax exch def |
|---|
| 6873 | /ymin exch def |
|---|
| 6874 | /xmax exch def |
|---|
| 6875 | /xmin exch def |
|---|
| 6876 | newpath |
|---|
| 6877 | 0 ymin truncate cvi smoveto |
|---|
| 6878 | 0 ymax truncate cvi slineto |
|---|
| 6879 | leplan mybool projpath |
|---|
| 6880 | Stroke |
|---|
| 6881 | ymin truncate cvi ymkstep ymax truncate cvi { |
|---|
| 6882 | dup 0 ne { |
|---|
| 6883 | /y exch def |
|---|
| 6884 | y |
|---|
| 6885 | y y truncate eq { |
|---|
| 6886 | cvi |
|---|
| 6887 | } if |
|---|
| 6888 | dup chaine cvs exch 0 exch leplan mybool cltextp3d |
|---|
| 6889 | newpath |
|---|
| 6890 | 0 y smoveto |
|---|
| 6891 | 2.5 0 rmoveto |
|---|
| 6892 | -5 0 rlineto |
|---|
| 6893 | leplan mybool projpath |
|---|
| 6894 | Stroke |
|---|
| 6895 | } { |
|---|
| 6896 | pop (0) 0 0 leplan mybool dltextp3d |
|---|
| 6897 | } ifelse |
|---|
| 6898 | } for |
|---|
| 6899 | end |
|---|
| 6900 | } def |
|---|
| 6901 | |
|---|
| 6902 | %% syntaxe : plantype planmarks |
|---|
| 6903 | /planmarks { |
|---|
| 6904 | 1 dict begin |
|---|
| 6905 | dup isbool { |
|---|
| 6906 | /mybool exch def |
|---|
| 6907 | } { |
|---|
| 6908 | /mybool true def |
|---|
| 6909 | } ifelse |
|---|
| 6910 | dup mybool planxmarks mybool planymarks |
|---|
| 6911 | end |
|---|
| 6912 | } def |
|---|
| 6913 | |
|---|
| 6914 | %% bleu |
|---|
| 6915 | %% [-3 3 -2 2] quadrillagexOy_ |
|---|
| 6916 | %% Stroke |
|---|
| 6917 | %% noir |
|---|
| 6918 | |
|---|
| 6919 | %% syntaxe : [xmin xmax ymin ymax] dx dy quadrillagexOy_ |
|---|
| 6920 | /quadrillagexOy_ { |
|---|
| 6921 | 4 dict begin |
|---|
| 6922 | dup isarray { |
|---|
| 6923 | /dx 1 def |
|---|
| 6924 | /dy 1 def |
|---|
| 6925 | } { |
|---|
| 6926 | /dy exch def |
|---|
| 6927 | dup isarray { |
|---|
| 6928 | /dx dy def |
|---|
| 6929 | } { |
|---|
| 6930 | /dx exch def |
|---|
| 6931 | } ifelse |
|---|
| 6932 | } ifelse |
|---|
| 6933 | /table exch def |
|---|
| 6934 | table 0 get /xmin exch def |
|---|
| 6935 | table 1 get /xmax exch def |
|---|
| 6936 | table 2 get /ymin exch def |
|---|
| 6937 | table 3 get /ymax exch def |
|---|
| 6938 | ymin dy ymax { |
|---|
| 6939 | /y exch def |
|---|
| 6940 | xmin y smoveto |
|---|
| 6941 | xmax y slineto |
|---|
| 6942 | } for |
|---|
| 6943 | xmin dx xmax { |
|---|
| 6944 | /x exch def |
|---|
| 6945 | x ymin smoveto |
|---|
| 6946 | x ymax slineto |
|---|
| 6947 | } for |
|---|
| 6948 | end |
|---|
| 6949 | } def |
|---|
| 6950 | |
|---|
| 6951 | %% syntaxe : plan [ngrid] planquadrillage |
|---|
| 6952 | /planquadrillage { |
|---|
| 6953 | 4 dict begin |
|---|
| 6954 | dup isbool { |
|---|
| 6955 | /mybool exch def |
|---|
| 6956 | } { |
|---|
| 6957 | /mybool true def |
|---|
| 6958 | } ifelse |
|---|
| 6959 | dup isplan { |
|---|
| 6960 | /ngrid [1 1] def |
|---|
| 6961 | } { |
|---|
| 6962 | /ngrid exch def |
|---|
| 6963 | } ifelse |
|---|
| 6964 | /leplan exch def |
|---|
| 6965 | /dx ngrid 0 get def |
|---|
| 6966 | /dy ngrid 1 get def |
|---|
| 6967 | /table leplan plangetrange def |
|---|
| 6968 | table 0 get cvi truncate /xmin exch def |
|---|
| 6969 | table 1 get cvi truncate /xmax exch def |
|---|
| 6970 | table 2 get cvi truncate /ymin exch def |
|---|
| 6971 | table 3 get cvi truncate /ymax exch def |
|---|
| 6972 | newpath |
|---|
| 6973 | ymin dy ymax { |
|---|
| 6974 | /y exch def |
|---|
| 6975 | xmin y smoveto |
|---|
| 6976 | xmax y slineto |
|---|
| 6977 | } for |
|---|
| 6978 | xmin dx xmax { |
|---|
| 6979 | /x exch def |
|---|
| 6980 | x ymin smoveto |
|---|
| 6981 | x ymax slineto |
|---|
| 6982 | } for |
|---|
| 6983 | leplan mybool projpath |
|---|
| 6984 | Stroke |
|---|
| 6985 | end |
|---|
| 6986 | } def |
|---|
| 6987 | |
|---|
| 6988 | %% syntaxe : plantype str1 str2 planshowbase -> - |
|---|
| 6989 | %% syntaxe : plantype str2 planshowbase -> - |
|---|
| 6990 | %% syntaxe : plantype planshowbase -> - |
|---|
| 6991 | /planshowbase { |
|---|
| 6992 | 3 dict begin |
|---|
| 6993 | dup isbool { |
|---|
| 6994 | /mybool exch def |
|---|
| 6995 | } { |
|---|
| 6996 | /mybool true def |
|---|
| 6997 | } ifelse |
|---|
| 6998 | dup isstring { |
|---|
| 6999 | /couleur2 exch def |
|---|
| 7000 | dup isstring { |
|---|
| 7001 | /couleur1 exch def |
|---|
| 7002 | } { |
|---|
| 7003 | /couleur1 (rouge) def |
|---|
| 7004 | } ifelse |
|---|
| 7005 | } { |
|---|
| 7006 | /couleur1 (rouge) def |
|---|
| 7007 | /couleur2 (vert) def |
|---|
| 7008 | } ifelse |
|---|
| 7009 | mybool bprojscene |
|---|
| 7010 | couleur1 cvx exec |
|---|
| 7011 | newpath |
|---|
| 7012 | 0 0 smoveto |
|---|
| 7013 | 1 0 slineto |
|---|
| 7014 | Stroke |
|---|
| 7015 | 0 0 1 0 oldarrow |
|---|
| 7016 | couleur2 cvx exec |
|---|
| 7017 | newpath |
|---|
| 7018 | 0 0 smoveto |
|---|
| 7019 | 0 1 slineto |
|---|
| 7020 | Stroke |
|---|
| 7021 | 0 0 0 1 oldarrow |
|---|
| 7022 | eprojscene |
|---|
| 7023 | end |
|---|
| 7024 | } def |
|---|
| 7025 | |
|---|
| 7026 | %% syntaxe : plantype str1 str2 str3 planshowbase3d -> - |
|---|
| 7027 | %% syntaxe : plantype str2 str3 planshowbase3d -> - |
|---|
| 7028 | %% syntaxe : plantype str3 planshowbase3d -> - |
|---|
| 7029 | %% syntaxe : plantype planshowbase3d -> - |
|---|
| 7030 | %% syntaxe : plantype str1 str2 str3 array planshowbase3d -> - |
|---|
| 7031 | %% syntaxe : plantype str2 str3 array planshowbase3d -> - |
|---|
| 7032 | %% syntaxe : plantype str3 array planshowbase3d -> - |
|---|
| 7033 | %% syntaxe : plantype array planshowbase3d -> - |
|---|
| 7034 | /planshowbase3d { |
|---|
| 7035 | 7 dict begin |
|---|
| 7036 | dup isbool { |
|---|
| 7037 | /mybool exch def |
|---|
| 7038 | } { |
|---|
| 7039 | /mybool true def |
|---|
| 7040 | } ifelse |
|---|
| 7041 | dup dup isarray exch isplan not and { |
|---|
| 7042 | /table exch def |
|---|
| 7043 | } { |
|---|
| 7044 | /table {} def |
|---|
| 7045 | } ifelse |
|---|
| 7046 | dup isstring { |
|---|
| 7047 | /couleur3 exch def |
|---|
| 7048 | dup isstring { |
|---|
| 7049 | /couleur2 exch def |
|---|
| 7050 | dup isstring { |
|---|
| 7051 | /couleur1 exch def |
|---|
| 7052 | } { |
|---|
| 7053 | /couleur1 (rouge) def |
|---|
| 7054 | } ifelse |
|---|
| 7055 | } { |
|---|
| 7056 | /couleur2 (vert) def |
|---|
| 7057 | /couleur1 (rouge) def |
|---|
| 7058 | } ifelse |
|---|
| 7059 | } { |
|---|
| 7060 | /couleur1 (rouge) def |
|---|
| 7061 | /couleur2 (vert) def |
|---|
| 7062 | /couleur3 (bleu) def |
|---|
| 7063 | } ifelse |
|---|
| 7064 | /plan exch def |
|---|
| 7065 | plan couleur1 couleur2 mybool planshowbase |
|---|
| 7066 | plan plangetorigine /I defpoint3d |
|---|
| 7067 | plan plangetbase |
|---|
| 7068 | dup 0 getp3d /u defpoint3d |
|---|
| 7069 | 1 getp3d /v defpoint3d |
|---|
| 7070 | u v vectprod3d table newvecteur |
|---|
| 7071 | {I addv3d} solidtransform |
|---|
| 7072 | dup couleur3 solidputcolors |
|---|
| 7073 | solidgridOff |
|---|
| 7074 | drawsolid** |
|---|
| 7075 | end |
|---|
| 7076 | } def |
|---|
| 7077 | |
|---|
| 7078 | %% syntaxe : plantype x y z plantranslate --> - |
|---|
| 7079 | /plantranslate { |
|---|
| 7080 | 4 dict begin |
|---|
| 7081 | /M defpoint3d |
|---|
| 7082 | /plan exch def |
|---|
| 7083 | plan isplan not { |
|---|
| 7084 | (Erreur : mauvais type d argument dans plantranslate) == |
|---|
| 7085 | quit |
|---|
| 7086 | } if |
|---|
| 7087 | plan plan plangetorigine M addv3d planputorigine |
|---|
| 7088 | end |
|---|
| 7089 | } def |
|---|
| 7090 | |
|---|
| 7091 | % syntaxe : alpha_x alpha_y alpha_z rotateOpplan --> - |
|---|
| 7092 | /rotateOplan { |
|---|
| 7093 | 4 dict begin |
|---|
| 7094 | /Rxyz defpoint3d |
|---|
| 7095 | /plan exch def |
|---|
| 7096 | plan isplan not { |
|---|
| 7097 | (Erreur : mauvais type d argument dans rotateOplan) == |
|---|
| 7098 | quit |
|---|
| 7099 | } if |
|---|
| 7100 | plan plan plangetorigine Rxyz rotateOpoint3d planputorigine |
|---|
| 7101 | |
|---|
| 7102 | plan plangetbase 0 getp3d /U defpoint3d |
|---|
| 7103 | plan plangetbase 1 getp3d /V defpoint3d |
|---|
| 7104 | plan [ |
|---|
| 7105 | U Rxyz rotateOpoint3d |
|---|
| 7106 | V Rxyz rotateOpoint3d |
|---|
| 7107 | ] planputbase |
|---|
| 7108 | end |
|---|
| 7109 | } def |
|---|
| 7110 | |
|---|
| 7111 | %% syntaxe : plantype phi rotateplan --> - |
|---|
| 7112 | /rotateplan { |
|---|
| 7113 | 5 dict begin |
|---|
| 7114 | /phi exch def |
|---|
| 7115 | /leplan exch def |
|---|
| 7116 | leplan plangetbase 0 getp3d /U defpoint3d |
|---|
| 7117 | leplan plangetbase 1 getp3d /V defpoint3d |
|---|
| 7118 | U phi cos mulv3d |
|---|
| 7119 | V phi sin mulv3d addv3d /U0 defpoint3d |
|---|
| 7120 | U phi sin neg mulv3d |
|---|
| 7121 | V phi cos mulv3d addv3d /V0 defpoint3d |
|---|
| 7122 | leplan [U0 V0] planputbase |
|---|
| 7123 | end |
|---|
| 7124 | } def |
|---|
| 7125 | |
|---|
| 7126 | %% syntaxe : solid i solidface2plan --> plantype |
|---|
| 7127 | %% syntaxe : solid i I solidface2plan --> plantype |
|---|
| 7128 | /solidface2plan { |
|---|
| 7129 | 5 dict begin |
|---|
| 7130 | 2 copy pop issolid { |
|---|
| 7131 | /i exch def |
|---|
| 7132 | /solid exch def |
|---|
| 7133 | solid i solidcentreface /I defpoint3d |
|---|
| 7134 | } { |
|---|
| 7135 | /I defpoint3d |
|---|
| 7136 | /i exch def |
|---|
| 7137 | /solid exch def |
|---|
| 7138 | } ifelse |
|---|
| 7139 | /result newplanaffine def |
|---|
| 7140 | solid i solidcentreface /G defpoint3d |
|---|
| 7141 | solid i solidnormaleface /K defpoint3d |
|---|
| 7142 | solid 0 i solidgetsommetface |
|---|
| 7143 | solid 1 i solidgetsommetface |
|---|
| 7144 | milieu3d /A defpoint3d |
|---|
| 7145 | G A vecteur3d normalize3d /U defpoint3d |
|---|
| 7146 | K U vectprod3d /V defpoint3d |
|---|
| 7147 | result [U V] planputbase |
|---|
| 7148 | result I planputorigine |
|---|
| 7149 | result |
|---|
| 7150 | end |
|---|
| 7151 | } def |
|---|
| 7152 | |
|---|
| 7153 | %%%%% ### fin insertion ### |
|---|
| 7154 | %% syntaxe : x y plantype pointplan --> X Y Z |
|---|
| 7155 | /pointplan { |
|---|
| 7156 | 5 dict begin |
|---|
| 7157 | /leplan exch def |
|---|
| 7158 | /y exch def |
|---|
| 7159 | /x exch def |
|---|
| 7160 | leplan plangetbase 0 getp3d /U defpoint3d |
|---|
| 7161 | leplan plangetbase 1 getp3d /V defpoint3d |
|---|
| 7162 | U x mulv3d V y mulv3d addv3d |
|---|
| 7163 | end |
|---|
| 7164 | } def |
|---|
| 7165 | |
|---|
| 7166 | %%%%% ### fin insertion ### |
|---|
| 7167 | |
|---|
| 7168 | |
|---|
| 7169 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 7170 | %%%% operations sur des solides particuliers %%%% |
|---|
| 7171 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 7172 | |
|---|
| 7173 | /piedist { |
|---|
| 7174 | 4 dict begin |
|---|
| 7175 | /mypie exch def |
|---|
| 7176 | mypie 0 solidgetface length /n exch def |
|---|
| 7177 | mypie n 2 idiv solidgetsommet /A defpoint3d |
|---|
| 7178 | mypie n 2 idiv 1 add solidgetsommet /B defpoint3d |
|---|
| 7179 | A B milieu3d GetCamPos distance3d |
|---|
| 7180 | end |
|---|
| 7181 | } def |
|---|
| 7182 | |
|---|
| 7183 | /sortpieset { |
|---|
| 7184 | 5 dict begin |
|---|
| 7185 | dup issolid { |
|---|
| 7186 | ] |
|---|
| 7187 | } if |
|---|
| 7188 | /table exch def |
|---|
| 7189 | [ |
|---|
| 7190 | 0 1 table length 1 sub { |
|---|
| 7191 | /i exch def |
|---|
| 7192 | table i get piedist |
|---|
| 7193 | } for |
|---|
| 7194 | ] |
|---|
| 7195 | doublequicksort pop reverse |
|---|
| 7196 | /result exch def |
|---|
| 7197 | [ |
|---|
| 7198 | 0 1 result length 1 sub { |
|---|
| 7199 | /i exch def |
|---|
| 7200 | table result i get get |
|---|
| 7201 | } for |
|---|
| 7202 | ] |
|---|
| 7203 | end |
|---|
| 7204 | } def |
|---|
| 7205 | |
|---|
| 7206 | /drawpieset { |
|---|
| 7207 | 1 dict begin |
|---|
| 7208 | /startest true def |
|---|
| 7209 | sortpieset dup {drawsolid**} apply {0 dessinefacevisible} apply |
|---|
| 7210 | end |
|---|
| 7211 | } def |
|---|
| 7212 | |
|---|
| 7213 | %%%%% ### solidchanfreine ### |
|---|
| 7214 | %% syntaxe : solid coeff solidchanfreine --> solid |
|---|
| 7215 | /solidchanfreine { |
|---|
| 7216 | 10 dict begin |
|---|
| 7217 | /coeff exch def |
|---|
| 7218 | /solid exch def |
|---|
| 7219 | /result newsolid def |
|---|
| 7220 | solid issolid not { |
|---|
| 7221 | (Erreur : mauvais type d argument dans solidchanfreine) == |
|---|
| 7222 | quit |
|---|
| 7223 | } if |
|---|
| 7224 | /n solid solidnombresommets def |
|---|
| 7225 | /nf solid solidnombrefaces def |
|---|
| 7226 | |
|---|
| 7227 | %% ajout des faces reduites |
|---|
| 7228 | 0 1 nf 1 sub { |
|---|
| 7229 | /i exch def |
|---|
| 7230 | /Fsommets solid i solidgetsommetsface def |
|---|
| 7231 | /Findex solid i solidgetface def |
|---|
| 7232 | /ns Fsommets length 3 idiv def |
|---|
| 7233 | /couleurfaceorigine solid i solidgetfcolor def |
|---|
| 7234 | Fsommets isobarycentre3d /G defpoint3d |
|---|
| 7235 | %% on ajoute les nouveaux sommets |
|---|
| 7236 | /Sindex [] def |
|---|
| 7237 | 0 1 ns 1 sub { |
|---|
| 7238 | /j exch def |
|---|
| 7239 | /Sindex [ Sindex aload pop |
|---|
| 7240 | Fsommets j getp3d /M defpoint3d |
|---|
| 7241 | result M G coeff hompoint3d solidaddsommet |
|---|
| 7242 | ] store |
|---|
| 7243 | } for |
|---|
| 7244 | %% Sindex contient les indices des nouveaux sommets |
|---|
| 7245 | result Sindex couleurfaceorigine solidaddface |
|---|
| 7246 | } for |
|---|
| 7247 | |
|---|
| 7248 | %% ajout des faces rectangulaires entre faces d'origines adjacentes |
|---|
| 7249 | %% pour chaque face de depart |
|---|
| 7250 | 0 1 nf 2 sub { |
|---|
| 7251 | /i exch def |
|---|
| 7252 | /F solid i solidgetface def |
|---|
| 7253 | /couleurfaceorigine solid i solidgetfcolor def |
|---|
| 7254 | /Fres result i solidgetface def |
|---|
| 7255 | %% pour chaque arete de la face |
|---|
| 7256 | 0 1 F length 1 sub { |
|---|
| 7257 | /j exch def |
|---|
| 7258 | /trouve false def |
|---|
| 7259 | /indice1 F j get def |
|---|
| 7260 | /indice2 F j 1 add F length mod get def |
|---|
| 7261 | /a1 j def |
|---|
| 7262 | /a2 j 1 add F length mod def |
|---|
| 7263 | %% on regarde toutes les autres faces |
|---|
| 7264 | i 1 add 1 nf 1 sub { |
|---|
| 7265 | /k exch def |
|---|
| 7266 | /Ftest solid k solidgetface def |
|---|
| 7267 | indice1 Ftest in {pop true} {false} ifelse |
|---|
| 7268 | indice2 Ftest in {pop true} {false} ifelse |
|---|
| 7269 | and { |
|---|
| 7270 | /indiceFadj k def |
|---|
| 7271 | indice1 Ftest in pop /k1 exch def |
|---|
| 7272 | indice2 Ftest in pop /k2 exch def |
|---|
| 7273 | /trouve true def |
|---|
| 7274 | exit |
|---|
| 7275 | } if |
|---|
| 7276 | } for |
|---|
| 7277 | trouve { |
|---|
| 7278 | /Fadj solid indiceFadj solidgetface def |
|---|
| 7279 | result [ |
|---|
| 7280 | Fres a1 get |
|---|
| 7281 | result indiceFadj solidgetface k1 get |
|---|
| 7282 | result indiceFadj solidgetface k2 get |
|---|
| 7283 | Fres a2 get |
|---|
| 7284 | ] couleurfaceorigine solidaddface |
|---|
| 7285 | } if |
|---|
| 7286 | } for |
|---|
| 7287 | } for |
|---|
| 7288 | |
|---|
| 7289 | %% pour chaque face |
|---|
| 7290 | 0 1 nf 2 sub { |
|---|
| 7291 | /i exch def |
|---|
| 7292 | /F solid i solidgetface def |
|---|
| 7293 | /couleurfaceorigine solid i solidgetfcolor def |
|---|
| 7294 | %% et pour chaque sommet de cette face |
|---|
| 7295 | 0 1 F length 1 sub { |
|---|
| 7296 | /j exch def |
|---|
| 7297 | /k F j get def |
|---|
| 7298 | solid k solidfacesadjsommet /adj exch def |
|---|
| 7299 | %% adj est le tableau des indices des faces adjacentes |
|---|
| 7300 | %% au sommet d'indice k |
|---|
| 7301 | %% rque : toutes les faces d'indice strict inferieur a i |
|---|
| 7302 | %% sont deja traitees |
|---|
| 7303 | %% Pour chaque face adjacente, on repere l'indice du sommet concerne dans |
|---|
| 7304 | %% la face |
|---|
| 7305 | adj min i lt not { |
|---|
| 7306 | /indadj [] def |
|---|
| 7307 | 0 1 adj length 1 sub { |
|---|
| 7308 | /m exch def |
|---|
| 7309 | k solid adj m get solidgetface in { |
|---|
| 7310 | /ok exch def |
|---|
| 7311 | /indadj [indadj aload pop ok] store |
|---|
| 7312 | } if |
|---|
| 7313 | } for |
|---|
| 7314 | |
|---|
| 7315 | /aajouter [ |
|---|
| 7316 | 0 1 adj length 1 sub { |
|---|
| 7317 | /m exch def |
|---|
| 7318 | result adj m get solidgetface indadj m get get |
|---|
| 7319 | } for |
|---|
| 7320 | ] def |
|---|
| 7321 | |
|---|
| 7322 | %% la table des sommets |
|---|
| 7323 | [0 1 aajouter length 1 sub { |
|---|
| 7324 | /m exch def |
|---|
| 7325 | result aajouter m get solidgetsommet |
|---|
| 7326 | } for] |
|---|
| 7327 | solid k solidgetsommet %% le point indiquant la direction de la normale |
|---|
| 7328 | ordonnepoints3d |
|---|
| 7329 | /indicestries exch def |
|---|
| 7330 | |
|---|
| 7331 | result [ |
|---|
| 7332 | 0 1 indicestries length 1 sub { |
|---|
| 7333 | /m exch def |
|---|
| 7334 | aajouter indicestries m get get |
|---|
| 7335 | } for |
|---|
| 7336 | ] couleurfaceorigine solidaddface |
|---|
| 7337 | } if |
|---|
| 7338 | } for |
|---|
| 7339 | } for |
|---|
| 7340 | |
|---|
| 7341 | result |
|---|
| 7342 | end |
|---|
| 7343 | } def |
|---|
| 7344 | |
|---|
| 7345 | %%%%% ### solidplansection ### |
|---|
| 7346 | %% syntaxe : M eqplan --> real |
|---|
| 7347 | %% image de M par la fonction definie par l equation eqplan |
|---|
| 7348 | /pointeqplan { |
|---|
| 7349 | 8 dict begin |
|---|
| 7350 | /@qplan exch def |
|---|
| 7351 | /@z exch def |
|---|
| 7352 | /@y exch def |
|---|
| 7353 | /@x exch def |
|---|
| 7354 | /@a @qplan 0 get def |
|---|
| 7355 | /@b @qplan 1 get def |
|---|
| 7356 | /@c @qplan 2 get def |
|---|
| 7357 | /@d @qplan 3 get def |
|---|
| 7358 | @a @x mul @b @y mul add @c @z mul add @d add |
|---|
| 7359 | end |
|---|
| 7360 | } def |
|---|
| 7361 | |
|---|
| 7362 | %% syntaxe : A B eqplan segment_inter_plan --> array true ou false |
|---|
| 7363 | %% array contient 1 point M si [AB] inter plan = {M} |
|---|
| 7364 | %% array contient les 2 points A et B si [AB] inter plan = [AB] |
|---|
| 7365 | /segment_inter_plan { |
|---|
| 7366 | 4 dict begin |
|---|
| 7367 | dup isplan {plan2eq} if |
|---|
| 7368 | /plan exch def |
|---|
| 7369 | plan aload pop |
|---|
| 7370 | /d exch def |
|---|
| 7371 | /c exch def |
|---|
| 7372 | /b exch def |
|---|
| 7373 | /a exch def |
|---|
| 7374 | /B defpoint3d |
|---|
| 7375 | /A defpoint3d |
|---|
| 7376 | A |
|---|
| 7377 | /zA exch def |
|---|
| 7378 | /yA exch def |
|---|
| 7379 | /xA exch def |
|---|
| 7380 | B |
|---|
| 7381 | /zB exch def |
|---|
| 7382 | /yB exch def |
|---|
| 7383 | /xB exch def |
|---|
| 7384 | /imA a xA mul b yA mul add c zA mul add d add def |
|---|
| 7385 | /imB a xB mul b yB mul add c zB mul add d add def |
|---|
| 7386 | imA imB mul dup 0 gt { |
|---|
| 7387 | %% pas d intersection |
|---|
| 7388 | pop |
|---|
| 7389 | false |
|---|
| 7390 | } { |
|---|
| 7391 | 0 eq { |
|---|
| 7392 | %% intersection en A ou en B |
|---|
| 7393 | [ |
|---|
| 7394 | imA 0 eq {A} if |
|---|
| 7395 | imB 0 eq {B} if |
|---|
| 7396 | ] true |
|---|
| 7397 | } { |
|---|
| 7398 | %% intersection entre A et B |
|---|
| 7399 | /k |
|---|
| 7400 | imA neg |
|---|
| 7401 | xB xA sub a mul |
|---|
| 7402 | yB yA sub b mul add |
|---|
| 7403 | zB zA sub c mul add |
|---|
| 7404 | dup 0 eq { |
|---|
| 7405 | (Error dans segment_inter_plan) == |
|---|
| 7406 | quit |
|---|
| 7407 | } if |
|---|
| 7408 | div |
|---|
| 7409 | def |
|---|
| 7410 | [ |
|---|
| 7411 | A B vecteur3d |
|---|
| 7412 | k mulv3d |
|---|
| 7413 | A addv3d |
|---|
| 7414 | ] true |
|---|
| 7415 | } ifelse |
|---|
| 7416 | } ifelse |
|---|
| 7417 | end |
|---|
| 7418 | } def |
|---|
| 7419 | |
|---|
| 7420 | %% syntaxe : solid i solidface2eqplan --> [a b c d] |
|---|
| 7421 | %% equation cartesienne de la face d'indice i du solide solid |
|---|
| 7422 | /solidface2eqplan { |
|---|
| 7423 | 8 dict begin |
|---|
| 7424 | /i exch def |
|---|
| 7425 | /solid exch def |
|---|
| 7426 | solid i solidnormaleface |
|---|
| 7427 | /c exch def |
|---|
| 7428 | /b exch def |
|---|
| 7429 | /a exch def |
|---|
| 7430 | solid 0 i solidgetsommetface |
|---|
| 7431 | /z exch def |
|---|
| 7432 | /y exch def |
|---|
| 7433 | /x exch def |
|---|
| 7434 | [a b c a x mul b y mul add c z mul add neg] |
|---|
| 7435 | end |
|---|
| 7436 | } def |
|---|
| 7437 | |
|---|
| 7438 | %% syntaxe : array1 arrayrmdouble --> array2 |
|---|
| 7439 | %% remplace 2 elts identiques consecutifs par 1 elt |
|---|
| 7440 | /arrayrmdouble { |
|---|
| 7441 | 5 dict begin |
|---|
| 7442 | /table exch def |
|---|
| 7443 | /result [table 0 get] def |
|---|
| 7444 | /j 0 def |
|---|
| 7445 | 1 1 table length 1 sub { |
|---|
| 7446 | /i exch def |
|---|
| 7447 | table i get |
|---|
| 7448 | result j get |
|---|
| 7449 | eq not { |
|---|
| 7450 | /result [result aload pop table i get] store |
|---|
| 7451 | /j j 1 add store |
|---|
| 7452 | } if |
|---|
| 7453 | } for |
|---|
| 7454 | result |
|---|
| 7455 | end |
|---|
| 7456 | } def |
|---|
| 7457 | |
|---|
| 7458 | %% syntaxe : solid eqplan/plantype solidplansection --> solid2 |
|---|
| 7459 | /solidplansection { |
|---|
| 7460 | 10 dict begin |
|---|
| 7461 | dup isbool { |
|---|
| 7462 | /tr@nsmit exch def |
|---|
| 7463 | } { |
|---|
| 7464 | /tr@nsmit false def |
|---|
| 7465 | } ifelse |
|---|
| 7466 | dup isplan { |
|---|
| 7467 | plan2eqplan |
|---|
| 7468 | /eqplan exch def |
|---|
| 7469 | } { |
|---|
| 7470 | /eqplan exch def |
|---|
| 7471 | } ifelse |
|---|
| 7472 | dupsolid /result exch def |
|---|
| 7473 | /solid exch def |
|---|
| 7474 | /aenlever [] def |
|---|
| 7475 | /indnouveauxsommets [] def |
|---|
| 7476 | /nouvellesaretes [] def |
|---|
| 7477 | |
|---|
| 7478 | %% pour chaque face d'indice i |
|---|
| 7479 | 0 1 solid solidnombrefaces 1 sub { |
|---|
| 7480 | /i exch def |
|---|
| 7481 | /lacouleur solid i solidgetfcolor def |
|---|
| 7482 | /F solid i solidgetface def %% table des indices des sommets |
|---|
| 7483 | /n F length def %% nb d'aretes |
|---|
| 7484 | /k1 -1 def |
|---|
| 7485 | /k2 -1 def |
|---|
| 7486 | /k3 -1 def |
|---|
| 7487 | /k4 -1 def |
|---|
| 7488 | /k3a -3 def |
|---|
| 7489 | /k4a -3 def |
|---|
| 7490 | %% pour chaque arete [AB] |
|---|
| 7491 | 0 1 n 1 sub { |
|---|
| 7492 | /j exch def |
|---|
| 7493 | %% arete testee : [j, j+1 mod n] (indices relatifs a la face i) |
|---|
| 7494 | solid j i solidgetsommetface /A defpoint3d |
|---|
| 7495 | solid j 1 add n mod i solidgetsommetface /B defpoint3d |
|---|
| 7496 | %% y a-t-il intersection |
|---|
| 7497 | A B eqplan segment_inter_plan { |
|---|
| 7498 | %% il y a intersection |
|---|
| 7499 | dup length 6 eq { |
|---|
| 7500 | %% l'intersection, c'est [AB] |
|---|
| 7501 | /k1 -1 def |
|---|
| 7502 | /k2 -1 def |
|---|
| 7503 | /k3 -1 def |
|---|
| 7504 | /k4 -1 def |
|---|
| 7505 | /k3a -1 def |
|---|
| 7506 | /k4a -1 def |
|---|
| 7507 | dup 0 getp3d /A defpoint3d |
|---|
| 7508 | 1 getp3d /B defpoint3d |
|---|
| 7509 | result A solidaddsommet /a1 exch def |
|---|
| 7510 | result B solidaddsommet /a2 exch def |
|---|
| 7511 | /indnouveauxsommets [ |
|---|
| 7512 | indnouveauxsommets aload pop a1 a2 |
|---|
| 7513 | ] store |
|---|
| 7514 | /nouvellesaretes [ |
|---|
| 7515 | [a1 a2] |
|---|
| 7516 | nouvellesaretes aload pop |
|---|
| 7517 | ] store |
|---|
| 7518 | exit %% c est deja scinde |
|---|
| 7519 | } if |
|---|
| 7520 | %% il y a intersection <> [AB] |
|---|
| 7521 | k1 0 lt { |
|---|
| 7522 | %% 1ere intersection de la face |
|---|
| 7523 | /k1 j def %% sommet precedent intersection 1 |
|---|
| 7524 | result exch aload pop solidaddsommet |
|---|
| 7525 | /k1a exch def %% sommet intersection 1 |
|---|
| 7526 | } { |
|---|
| 7527 | k2 0 lt { |
|---|
| 7528 | %% 2eme intersection de la face |
|---|
| 7529 | /k2 j def %% sommet precedent intersection 2 |
|---|
| 7530 | result exch aload pop solidaddsommet |
|---|
| 7531 | /k2a exch def %% sommet intersection 2 |
|---|
| 7532 | } { |
|---|
| 7533 | k3 0 lt { |
|---|
| 7534 | %% 3eme intersection de la face |
|---|
| 7535 | /k3 j def %% sommet precedent intersection 3 |
|---|
| 7536 | result exch aload pop solidaddsommet |
|---|
| 7537 | /k3a exch def %% sommet intersection 3 |
|---|
| 7538 | } { |
|---|
| 7539 | %% 4eme intersection de la face |
|---|
| 7540 | /k4 j def %% sommet precedent intersection 4 |
|---|
| 7541 | result exch aload pop solidaddsommet |
|---|
| 7542 | /k4a exch def %% sommet intersection 4 |
|---|
| 7543 | } ifelse |
|---|
| 7544 | } ifelse |
|---|
| 7545 | } ifelse |
|---|
| 7546 | } if |
|---|
| 7547 | } for |
|---|
| 7548 | |
|---|
| 7549 | %% y a-t-il eu une coupe ? |
|---|
| 7550 | %% si oui, il faut scinder la face d'indice i en cours |
|---|
| 7551 | k1 0 ge { |
|---|
| 7552 | %% (coupe) == |
|---|
| 7553 | %% (n) == n == |
|---|
| 7554 | %% k1 == k2 == k3 == k4 == |
|---|
| 7555 | %% (a) == |
|---|
| 7556 | %% k1a == k2a == k3a == k4a == |
|---|
| 7557 | k1a k2a eq k3 0 lt and { |
|---|
| 7558 | %% 1 pt d'intersection |
|---|
| 7559 | } { |
|---|
| 7560 | %% il y a coupe, on cherche a eliminer les |
|---|
| 7561 | %% doublons dans {k1a, k2a, k3a, k4a} |
|---|
| 7562 | k1a k2a eq k3 0 ge and { |
|---|
| 7563 | %% 2 pts d'intersection |
|---|
| 7564 | /k2a k3a def |
|---|
| 7565 | /k2 k3 def |
|---|
| 7566 | } if |
|---|
| 7567 | k1a k3a eq k4 0 ge and { |
|---|
| 7568 | %% 2 pts d'intersection |
|---|
| 7569 | /k2a k4a def |
|---|
| 7570 | /k2 k4 def |
|---|
| 7571 | } if |
|---|
| 7572 | /nouvellesaretes [ |
|---|
| 7573 | [k1a k2a] |
|---|
| 7574 | nouvellesaretes aload pop |
|---|
| 7575 | ] store |
|---|
| 7576 | [ |
|---|
| 7577 | k1a F k1 1 add n mod get ne { |
|---|
| 7578 | k1a |
|---|
| 7579 | } if |
|---|
| 7580 | k1 1 add n mod 1 k2 {F exch get} for |
|---|
| 7581 | k2a F k2 get ne { |
|---|
| 7582 | k2a |
|---|
| 7583 | } if |
|---|
| 7584 | ] |
|---|
| 7585 | result exch lacouleur solidaddface |
|---|
| 7586 | /indnouveauxsommets [indnouveauxsommets aload pop k1a k2a] store |
|---|
| 7587 | [ |
|---|
| 7588 | k2a F k2 1 add n mod get ne { |
|---|
| 7589 | k2a |
|---|
| 7590 | } if |
|---|
| 7591 | k2 1 add n ne { |
|---|
| 7592 | k2 1 add n mod 1 n 1 sub {F exch get} for |
|---|
| 7593 | } if |
|---|
| 7594 | 0 1 k1 {F exch get} for |
|---|
| 7595 | k1a F k1 get ne { |
|---|
| 7596 | k1a |
|---|
| 7597 | } if |
|---|
| 7598 | ] |
|---|
| 7599 | result exch lacouleur solidaddface |
|---|
| 7600 | /aenlever [aenlever aload pop i] store |
|---|
| 7601 | } ifelse |
|---|
| 7602 | } if |
|---|
| 7603 | } for |
|---|
| 7604 | result aenlever solidrmfaces |
|---|
| 7605 | |
|---|
| 7606 | nouvellesaretes separe_composantes |
|---|
| 7607 | /composantes exch def |
|---|
| 7608 | |
|---|
| 7609 | %% pour chacune des composantes |
|---|
| 7610 | 0 1 composantes length 1 sub { |
|---|
| 7611 | %% on oriente et on ajoute la face |
|---|
| 7612 | /icomp exch def |
|---|
| 7613 | %indnouveauxsommets bubblesort arrayrmdouble |
|---|
| 7614 | /indnouveauxsommets composantes icomp get def |
|---|
| 7615 | %% maintenant, on ajoute la face de plan de coupe |
|---|
| 7616 | /nouveauxsommets [ |
|---|
| 7617 | 0 1 indnouveauxsommets length 1 sub { |
|---|
| 7618 | /i exch def |
|---|
| 7619 | result indnouveauxsommets i get solidgetsommet |
|---|
| 7620 | } for |
|---|
| 7621 | ] def |
|---|
| 7622 | |
|---|
| 7623 | 0 0 0 eqplan pointeqplan 0 eq { |
|---|
| 7624 | /ptref {0 1 1} def |
|---|
| 7625 | } { |
|---|
| 7626 | /ptref {0 0 0} def |
|---|
| 7627 | } ifelse |
|---|
| 7628 | |
|---|
| 7629 | %% restera a traiter le cas limite ou la nouvelle face existe deja |
|---|
| 7630 | %% tester si max(indicestries) < nb sommets avant section |
|---|
| 7631 | nouveauxsommets ptref ordonnepoints3d |
|---|
| 7632 | /indicestries exch def |
|---|
| 7633 | /nvelleface [ |
|---|
| 7634 | 0 1 indicestries length 1 sub { |
|---|
| 7635 | /m exch def |
|---|
| 7636 | indnouveauxsommets indicestries m get get |
|---|
| 7637 | } for |
|---|
| 7638 | ] def |
|---|
| 7639 | /F result solidgetfaces def |
|---|
| 7640 | /FC result solidgetfcolors def |
|---|
| 7641 | /IO result solidgetinouttable def |
|---|
| 7642 | /n1 IO 1 get def |
|---|
| 7643 | IO 1 n1 1 add put |
|---|
| 7644 | result IO solidputinouttable |
|---|
| 7645 | result [nvelleface F aload pop] solidputfaces |
|---|
| 7646 | result [lacouleur FC aload pop] solidputfcolors |
|---|
| 7647 | } for |
|---|
| 7648 | result |
|---|
| 7649 | tr@nsmit { |
|---|
| 7650 | composantes length |
|---|
| 7651 | } if |
|---|
| 7652 | end |
|---|
| 7653 | } def |
|---|
| 7654 | |
|---|
| 7655 | %% syntaxe : elt array compteoccurences |
|---|
| 7656 | %% ou array est un tableau du type [ [a1 a2] [b1 b2] [c1 c2] ... ] |
|---|
| 7657 | /compteoccurences { |
|---|
| 7658 | 5 dict begin |
|---|
| 7659 | /table exch def |
|---|
| 7660 | /elt exch def |
|---|
| 7661 | /n 0 def |
|---|
| 7662 | 0 1 table length 1 sub { |
|---|
| 7663 | /i exch def |
|---|
| 7664 | elt table i get in { |
|---|
| 7665 | pop |
|---|
| 7666 | /n n 1 add store |
|---|
| 7667 | } if |
|---|
| 7668 | } for |
|---|
| 7669 | n |
|---|
| 7670 | end |
|---|
| 7671 | } def |
|---|
| 7672 | |
|---|
| 7673 | /separe_composantes { |
|---|
| 7674 | 10 dict begin |
|---|
| 7675 | /result [] def %% les composantes deja faites |
|---|
| 7676 | /table exch def %% ce qui reste a faire |
|---|
| 7677 | |
|---|
| 7678 | % (recu) == table {==} apply |
|---|
| 7679 | { |
|---|
| 7680 | /ext1 table 0 get 1 get def |
|---|
| 7681 | /ext0 table 0 get 0 get def |
|---|
| 7682 | /composante [] def |
|---|
| 7683 | |
|---|
| 7684 | { %% maintenant on suit les extremites et on epluche une composante |
|---|
| 7685 | /change false def |
|---|
| 7686 | /aenlever [] def |
|---|
| 7687 | 0 1 table length 1 sub { |
|---|
| 7688 | /i exch def |
|---|
| 7689 | ext1 table i get In |
|---|
| 7690 | ext0 table i get In or { |
|---|
| 7691 | /aenlever [aenlever aload pop i] store |
|---|
| 7692 | /change true store |
|---|
| 7693 | %% l'arete i contient l'extremite ext0 ou ext1 |
|---|
| 7694 | ext0 table i get in { |
|---|
| 7695 | %% index = 0 ou 1 |
|---|
| 7696 | neg 1 add table i get exch get |
|---|
| 7697 | /ext0 exch store |
|---|
| 7698 | ext0 composante In not { |
|---|
| 7699 | /composante [composante aload pop ext0] store |
|---|
| 7700 | } if |
|---|
| 7701 | %% on verifie que ext0 est legitime |
|---|
| 7702 | ext0 table compteoccurences 2 gt { |
|---|
| 7703 | /ext0 -1 store |
|---|
| 7704 | } if |
|---|
| 7705 | } if |
|---|
| 7706 | ext1 table i get in { |
|---|
| 7707 | %% index = 0 ou 1 |
|---|
| 7708 | neg 1 add table i get exch get |
|---|
| 7709 | /ext1 exch store |
|---|
| 7710 | ext1 composante In not { |
|---|
| 7711 | /composante [composante aload pop ext1] store |
|---|
| 7712 | } if |
|---|
| 7713 | %% on verifie que ext1 est legitime |
|---|
| 7714 | ext1 table compteoccurences 2 gt { |
|---|
| 7715 | /ext1 -1 store |
|---|
| 7716 | } if |
|---|
| 7717 | } if |
|---|
| 7718 | } if |
|---|
| 7719 | } for |
|---|
| 7720 | %% il faut reconstruire table |
|---|
| 7721 | /table [ |
|---|
| 7722 | 0 1 table length 1 sub { |
|---|
| 7723 | /i exch def |
|---|
| 7724 | i aenlever in { |
|---|
| 7725 | pop |
|---|
| 7726 | } { |
|---|
| 7727 | table i get |
|---|
| 7728 | } ifelse |
|---|
| 7729 | } for |
|---|
| 7730 | ] store |
|---|
| 7731 | change not {exit} if |
|---|
| 7732 | } loop |
|---|
| 7733 | %% on vient de finir une composante |
|---|
| 7734 | /result [result aload pop composante] store |
|---|
| 7735 | %% (nouvelle comp) == composante {==} apply |
|---|
| 7736 | table length 0 eq {exit} if |
|---|
| 7737 | } loop |
|---|
| 7738 | result |
|---|
| 7739 | % (renvoie) == result {==} apply |
|---|
| 7740 | end |
|---|
| 7741 | } def |
|---|
| 7742 | |
|---|
| 7743 | /solideqplansepare {solidplansepare} def |
|---|
| 7744 | |
|---|
| 7745 | %% syntaxe : solid eqplan/plantype solidplansepare --> solid1 solid2 |
|---|
| 7746 | /solidplansepare { |
|---|
| 7747 | 10 dict begin |
|---|
| 7748 | dup isplan { |
|---|
| 7749 | plan2eq |
|---|
| 7750 | /eqplan exch def |
|---|
| 7751 | } { |
|---|
| 7752 | /eqplan exch def |
|---|
| 7753 | } ifelse |
|---|
| 7754 | eqplan true solidplansection |
|---|
| 7755 | /nbcomposantes exch def |
|---|
| 7756 | /solid exch def |
|---|
| 7757 | /n solid solidnombrefaces def |
|---|
| 7758 | |
|---|
| 7759 | /F [] def |
|---|
| 7760 | /FC [] def |
|---|
| 7761 | %% on retire les faces de coupe |
|---|
| 7762 | 0 1 nbcomposantes 1 sub { |
|---|
| 7763 | /i exch def |
|---|
| 7764 | /F [F aload pop solid i solidgetface] store |
|---|
| 7765 | /FC [FC aload pop solid i solidgetfcolor] store |
|---|
| 7766 | } for |
|---|
| 7767 | solid [0 1 nbcomposantes 1 sub {} for] solidrmfaces |
|---|
| 7768 | /n n nbcomposantes sub store |
|---|
| 7769 | |
|---|
| 7770 | %% on separe les autres faces en 2 parties |
|---|
| 7771 | /lesneg [] def %% indices des faces "positives" |
|---|
| 7772 | /lespos [] def %% indices des faces negatives" |
|---|
| 7773 | 0 1 n 1 sub { |
|---|
| 7774 | /i exch def |
|---|
| 7775 | solid i solidcentreface /G defpoint3d |
|---|
| 7776 | G eqplan pointeqplan dup 0 gt { |
|---|
| 7777 | pop |
|---|
| 7778 | /lespos [lespos aload pop i] store |
|---|
| 7779 | } { |
|---|
| 7780 | 0 lt { |
|---|
| 7781 | /lesneg [lesneg aload pop i] store |
|---|
| 7782 | } { |
|---|
| 7783 | % /lesneg [lesneg aload pop i] store |
|---|
| 7784 | % /lespos [lespos aload pop i] store |
|---|
| 7785 | } ifelse |
|---|
| 7786 | } ifelse |
|---|
| 7787 | } for |
|---|
| 7788 | solid |
|---|
| 7789 | dupsolid dup lesneg solidrmfaces |
|---|
| 7790 | /result1 exch def |
|---|
| 7791 | dupsolid dup lespos solidrmfaces |
|---|
| 7792 | /result2 exch def |
|---|
| 7793 | pop |
|---|
| 7794 | |
|---|
| 7795 | 0 1 nbcomposantes 1 sub { |
|---|
| 7796 | /i exch def |
|---|
| 7797 | /facecoupe F i get def |
|---|
| 7798 | /couleurfacecoupe FC i get def |
|---|
| 7799 | /lesfaces1 result1 solidgetfaces def |
|---|
| 7800 | /lescouleurs1 result1 solidgetfcolors def |
|---|
| 7801 | /IO1 result1 solidgetinouttable def |
|---|
| 7802 | /lesfaces2 result2 solidgetfaces def |
|---|
| 7803 | /lescouleurs2 result2 solidgetfcolors def |
|---|
| 7804 | /IO2 result2 solidgetinouttable def |
|---|
| 7805 | %% on rajoute maintenant la face du plan de coupe |
|---|
| 7806 | % result1 facecoupe couleurfacecoupe solidaddface |
|---|
| 7807 | result1 [facecoupe lesfaces1 aload pop] solidputfaces |
|---|
| 7808 | result1 [couleurfacecoupe lescouleurs1 aload pop] solidputfcolors |
|---|
| 7809 | result1 IO1 dup dup 1 get 1 add 1 exch put solidputinouttable |
|---|
| 7810 | %% et on verifie l'orientation |
|---|
| 7811 | % result1 dup solidnombrefaces 1 sub solidnormaleface |
|---|
| 7812 | % result1 dup solidnombrefaces 1 sub solidcentreface addv3d |
|---|
| 7813 | result1 0 solidnormaleface |
|---|
| 7814 | result1 0 solidcentreface addv3d |
|---|
| 7815 | eqplan pointeqplan 0 gt { |
|---|
| 7816 | %% l'orientation est mauvaise |
|---|
| 7817 | result1 0 solidrmface |
|---|
| 7818 | result2 [facecoupe lesfaces2 aload pop] solidputfaces |
|---|
| 7819 | result2 [couleurfacecoupe lescouleurs2 aload pop] solidputfcolors |
|---|
| 7820 | result2 IO2 dup dup 1 get 1 add 1 exch put solidputinouttable |
|---|
| 7821 | result1 [facecoupe reverse lesfaces1 aload pop] solidputfaces |
|---|
| 7822 | result1 [couleurfacecoupe lescouleurs1 aload pop] solidputfcolors |
|---|
| 7823 | result1 dup solidgetinouttable dup dup 1 get 1 add 1 exch put solidputinouttable |
|---|
| 7824 | } { |
|---|
| 7825 | %% l'orientation est ok |
|---|
| 7826 | result2 IO2 dup dup 1 get 1 add 1 exch put solidputinouttable |
|---|
| 7827 | result2 [facecoupe reverse lesfaces2 aload pop] solidputfaces |
|---|
| 7828 | result2 [couleurfacecoupe lescouleurs2 aload pop] solidputfcolors |
|---|
| 7829 | } ifelse |
|---|
| 7830 | } for |
|---|
| 7831 | |
|---|
| 7832 | %% maintenant on enleve les sommets isoles |
|---|
| 7833 | /sommetspos [] def |
|---|
| 7834 | /sommetsneg [] def |
|---|
| 7835 | %% pour chaque face du cote negatif |
|---|
| 7836 | 0 1 lesneg length 1 sub { |
|---|
| 7837 | lesneg exch get /i exch def |
|---|
| 7838 | /F solid i solidgetface def |
|---|
| 7839 | %% pour chaque sommet de cette face |
|---|
| 7840 | 0 1 F length 1 sub { |
|---|
| 7841 | /j exch def |
|---|
| 7842 | /sommet F j get def |
|---|
| 7843 | %% si le sommet n'est pas encore note |
|---|
| 7844 | sommet sommetsneg in not { |
|---|
| 7845 | %% et s'il est isole, on peut l'enlever |
|---|
| 7846 | result1 sommet solidsommetsadjsommet length 0 eq { |
|---|
| 7847 | /sommetsneg [sommetsneg aload pop sommet] store |
|---|
| 7848 | } if |
|---|
| 7849 | } { |
|---|
| 7850 | pop |
|---|
| 7851 | } ifelse |
|---|
| 7852 | } for |
|---|
| 7853 | } for |
|---|
| 7854 | sommetsneg bubblesort reverse {result1 exch solidrmsommet} apply |
|---|
| 7855 | |
|---|
| 7856 | %% pour chaque face du cote positif |
|---|
| 7857 | 0 1 lespos length 1 sub { |
|---|
| 7858 | lespos exch get /i exch def |
|---|
| 7859 | /F solid i solidgetface def |
|---|
| 7860 | %% pour chaque sommet de cette face |
|---|
| 7861 | 0 1 F length 1 sub { |
|---|
| 7862 | /j exch def |
|---|
| 7863 | /sommet F j get def |
|---|
| 7864 | %% si le sommet n'est pas encore note |
|---|
| 7865 | sommet sommetspos in not { |
|---|
| 7866 | %% et s'il est isole, on peut l'enlever |
|---|
| 7867 | result2 sommet solidsommetsadjsommet length 0 eq { |
|---|
| 7868 | /sommetspos [sommetspos aload pop sommet] store |
|---|
| 7869 | } if |
|---|
| 7870 | } { |
|---|
| 7871 | pop |
|---|
| 7872 | } ifelse |
|---|
| 7873 | } for |
|---|
| 7874 | } for |
|---|
| 7875 | sommetspos bubblesort reverse {result2 exch solidrmsommet} apply |
|---|
| 7876 | |
|---|
| 7877 | result1 result2 |
|---|
| 7878 | end |
|---|
| 7879 | } def |
|---|
| 7880 | |
|---|
| 7881 | %%%%% ### solidaffine ### |
|---|
| 7882 | %% syntaxe : solid coeff i solidaffine -> - |
|---|
| 7883 | %% syntaxe : solid coeff array solidaffine -> - |
|---|
| 7884 | %% syntaxe : solid coeff solidaffine -> - |
|---|
| 7885 | %% syntaxe : solid coeff str solidaffine -> - |
|---|
| 7886 | %% syntaxe : solid coeff bool solidaffine -> - |
|---|
| 7887 | /solidaffine { |
|---|
| 7888 | 10 dict begin |
|---|
| 7889 | dup isbool { |
|---|
| 7890 | /rmfacecentrale exch def |
|---|
| 7891 | } { |
|---|
| 7892 | /rmfacecentrale true def |
|---|
| 7893 | } ifelse |
|---|
| 7894 | dup isstring { |
|---|
| 7895 | /couleurface exch def |
|---|
| 7896 | } if |
|---|
| 7897 | 2 copy pop issolid { |
|---|
| 7898 | %% 2 arguments --> on affine tout |
|---|
| 7899 | 2 copy pop solidnombrefaces /n exch def |
|---|
| 7900 | /table [n 1 sub -1 0 {} for] def |
|---|
| 7901 | } { |
|---|
| 7902 | %% 1 tableau --> il donne les faces a enlever |
|---|
| 7903 | dup isarray { |
|---|
| 7904 | /table exch bubblesort reverse def |
|---|
| 7905 | } { |
|---|
| 7906 | %% 1 seule face a enlever |
|---|
| 7907 | [ exch ] /table exch def |
|---|
| 7908 | } ifelse |
|---|
| 7909 | } ifelse |
|---|
| 7910 | /coeff exch def |
|---|
| 7911 | /solid exch def |
|---|
| 7912 | 0 1 table length 1 sub { |
|---|
| 7913 | /i exch def |
|---|
| 7914 | solid coeff table i get |
|---|
| 7915 | currentdict /couleurface known { |
|---|
| 7916 | couleurface |
|---|
| 7917 | } if |
|---|
| 7918 | rmfacecentrale s@lidaffineface |
|---|
| 7919 | } for |
|---|
| 7920 | end |
|---|
| 7921 | } def |
|---|
| 7922 | |
|---|
| 7923 | %% syntaxe : solid coeff i s@lidaffineface |
|---|
| 7924 | /s@lidaffineface { |
|---|
| 7925 | 10 dict begin |
|---|
| 7926 | /rmfacecentrale exch def |
|---|
| 7927 | dup isstring { |
|---|
| 7928 | /couleurface exch def |
|---|
| 7929 | } if |
|---|
| 7930 | /indice_a_chamfreiner exch def |
|---|
| 7931 | /i indice_a_chamfreiner def |
|---|
| 7932 | /coeff exch def |
|---|
| 7933 | /solid exch def |
|---|
| 7934 | solid issolid not { |
|---|
| 7935 | (Erreur : mauvais type d argument dans affine) == |
|---|
| 7936 | quit |
|---|
| 7937 | } if |
|---|
| 7938 | /n solid solidnombresommets def |
|---|
| 7939 | /F solid i solidgetsommetsface def |
|---|
| 7940 | /Findex solid i solidgetface def |
|---|
| 7941 | /ni F length 3 idiv def |
|---|
| 7942 | /couleurfaceorigine solid i solidgetfcolor def |
|---|
| 7943 | F isobarycentre3d /G defpoint3d |
|---|
| 7944 | %% on ajoute les nouveaux sommets |
|---|
| 7945 | /Sindex [] def |
|---|
| 7946 | 0 1 ni 1 sub { |
|---|
| 7947 | /j exch def |
|---|
| 7948 | /Sindex [ Sindex aload pop |
|---|
| 7949 | solid G F j getp3d vecteur3d coeff mulv3d G addv3d solidaddsommet |
|---|
| 7950 | ] store |
|---|
| 7951 | } for |
|---|
| 7952 | %% Sindex contient les indices des nouveaux sommets |
|---|
| 7953 | %% on prepare les faces a ajouter |
|---|
| 7954 | /facestoadd [] def |
|---|
| 7955 | /facestoadd [facestoadd aload pop |
|---|
| 7956 | 0 1 ni 1 sub { |
|---|
| 7957 | /j exch def |
|---|
| 7958 | [Findex j get |
|---|
| 7959 | Findex j 1 add ni mod get |
|---|
| 7960 | Sindex j 1 add ni mod get |
|---|
| 7961 | Sindex j get] |
|---|
| 7962 | } for |
|---|
| 7963 | ] store |
|---|
| 7964 | 0 1 ni 1 sub { |
|---|
| 7965 | /i exch def |
|---|
| 7966 | solid facestoadd i get solidaddface |
|---|
| 7967 | } for |
|---|
| 7968 | %% on enleve la face d origine |
|---|
| 7969 | solid indice_a_chamfreiner solidrmface |
|---|
| 7970 | %% on ajuste les couleurs des nouvelles faces |
|---|
| 7971 | /N solid solidnombrefaces def |
|---|
| 7972 | 0 1 ni 1 sub { |
|---|
| 7973 | /i exch def |
|---|
| 7974 | solid N 1 sub i sub couleurfaceorigine solidputfcolor |
|---|
| 7975 | } for |
|---|
| 7976 | %% puis on ajoute eventuellement la face centrale |
|---|
| 7977 | rmfacecentrale not { |
|---|
| 7978 | solid |
|---|
| 7979 | [0 1 ni 1 sub { |
|---|
| 7980 | /j exch def |
|---|
| 7981 | Sindex j get |
|---|
| 7982 | } for] |
|---|
| 7983 | solidaddface |
|---|
| 7984 | %% en ajustant la couleur de cette derniere |
|---|
| 7985 | solid N |
|---|
| 7986 | currentdict /couleurface known { |
|---|
| 7987 | couleurface |
|---|
| 7988 | } { |
|---|
| 7989 | couleurfaceorigine |
|---|
| 7990 | } ifelse |
|---|
| 7991 | solidputfcolor |
|---|
| 7992 | } if |
|---|
| 7993 | end |
|---|
| 7994 | } def |
|---|
| 7995 | |
|---|
| 7996 | %%%%% ### solidtronque ### |
|---|
| 7997 | %% syntaxe : solid indicesommet k solidtronque --> solid |
|---|
| 7998 | %% syntaxe : solid array k solidtronque --> solid |
|---|
| 7999 | %% syntaxe : solid k solidtronque --> solid |
|---|
| 8000 | %% k entier > 0, array = tableau des indices des sommets |
|---|
| 8001 | /solidtronque { |
|---|
| 8002 | 10 dict begin |
|---|
| 8003 | /coeff exch def |
|---|
| 8004 | dup issolid { |
|---|
| 8005 | dup solidnombresommets /N exch def |
|---|
| 8006 | /table [0 1 N 1 sub {} for] def |
|---|
| 8007 | } { |
|---|
| 8008 | dup isarray { |
|---|
| 8009 | /table exch def |
|---|
| 8010 | } { |
|---|
| 8011 | [ exch ] /table exch def |
|---|
| 8012 | } ifelse |
|---|
| 8013 | } ifelse |
|---|
| 8014 | /solid exch def |
|---|
| 8015 | solid dupsolid /result exch def pop |
|---|
| 8016 | /n solid solidnombrefaces def |
|---|
| 8017 | 0 1 table length 1 sub { |
|---|
| 8018 | table exch get /no exch def |
|---|
| 8019 | result no solidgetsommet /sommetvise defpoint3d |
|---|
| 8020 | %% on recup les sommets adjacents au sommet vise |
|---|
| 8021 | /sommetsadj solid no solidsommetsadjsommet def |
|---|
| 8022 | %% on calcule les nouveaux sommets |
|---|
| 8023 | /nouveauxsommets [ |
|---|
| 8024 | 0 1 sommetsadj length 1 sub { |
|---|
| 8025 | /i exch def |
|---|
| 8026 | solid sommetsadj i get solidgetsommet |
|---|
| 8027 | } for |
|---|
| 8028 | ] {sommetvise exchp3d coeff ABpoint3d} papply3d def |
|---|
| 8029 | %% on pose G = barycentre de ces points |
|---|
| 8030 | nouveauxsommets isobarycentre3d /G defpoint3d |
|---|
| 8031 | %% il faut ordonner ces sommets |
|---|
| 8032 | nouveauxsommets 0 getp3d /ptref defpoint3d |
|---|
| 8033 | G result no solidgetsommet vecteur3d /vecteurnormal defpoint3d |
|---|
| 8034 | %% on construit le tableau des angles ordonnes par rapport |
|---|
| 8035 | %% a la normale |
|---|
| 8036 | nouveauxsommets duparray exch pop |
|---|
| 8037 | {1 dict begin |
|---|
| 8038 | /M defpoint3d |
|---|
| 8039 | G ptref vecteur3d |
|---|
| 8040 | G M vecteur3d |
|---|
| 8041 | vecteurnormal angle3doriente |
|---|
| 8042 | end} papply3d |
|---|
| 8043 | doublebubblesort pop |
|---|
| 8044 | %% nos sommets sont tries |
|---|
| 8045 | /indicesommetstries exch def |
|---|
| 8046 | %% on rajoute les sommets au solide, et on note les nouveaux indices |
|---|
| 8047 | /nouveauxindices [ |
|---|
| 8048 | 0 1 nouveauxsommets length 3 idiv 1 sub { |
|---|
| 8049 | /k exch def |
|---|
| 8050 | result nouveauxsommets k getp3d solidaddsommet |
|---|
| 8051 | } for |
|---|
| 8052 | ] def |
|---|
| 8053 | %% on ajoute la face concernee |
|---|
| 8054 | result [ |
|---|
| 8055 | 0 1 indicesommetstries length 1 sub { |
|---|
| 8056 | /k exch def |
|---|
| 8057 | nouveauxindices indicesommetstries k get get |
|---|
| 8058 | } for |
|---|
| 8059 | ] solidaddface |
|---|
| 8060 | result no solidfacesadjsommet /lesfaces exch def |
|---|
| 8061 | %% on examine la face d indice i, et on elimine le |
|---|
| 8062 | %% sommet vise |
|---|
| 8063 | 0 1 lesfaces length 1 sub { |
|---|
| 8064 | /i exch def |
|---|
| 8065 | /j lesfaces i get def |
|---|
| 8066 | /F result j solidgetface def |
|---|
| 8067 | result [ |
|---|
| 8068 | 0 1 F length 1 sub { |
|---|
| 8069 | /k exch def |
|---|
| 8070 | F k get dup no eq {pop} if |
|---|
| 8071 | } for |
|---|
| 8072 | ] j exch solidputface |
|---|
| 8073 | } for |
|---|
| 8074 | } for |
|---|
| 8075 | table bubblesort reverse {result exch solidrmsommet} apply |
|---|
| 8076 | result |
|---|
| 8077 | end |
|---|
| 8078 | } def |
|---|
| 8079 | |
|---|
| 8080 | %%%%% ### dualpolyedre ### |
|---|
| 8081 | %% syntaxe : solid dualpolyedreregulier --> solid |
|---|
| 8082 | %% syntaxe : solid r dualpolyedreregulier --> solid |
|---|
| 8083 | %% si le nombre r est present, projette les nouveaux sommets sur la sphere de centre O , de rayon r |
|---|
| 8084 | /dualpolyedreregulier { |
|---|
| 8085 | 20 dict begin |
|---|
| 8086 | dup isnum { |
|---|
| 8087 | /r exch def |
|---|
| 8088 | /projection true def |
|---|
| 8089 | } { |
|---|
| 8090 | /projection false def |
|---|
| 8091 | } ifelse |
|---|
| 8092 | /solid exch def |
|---|
| 8093 | solid dupsolid /result exch def pop |
|---|
| 8094 | /n solid solidnombrefaces def |
|---|
| 8095 | /N solid solidnombresommets def |
|---|
| 8096 | /facesaenlever [] def |
|---|
| 8097 | %% pour chacun des sommets |
|---|
| 8098 | 0 1 N 1 sub { |
|---|
| 8099 | %% sommet d indice i |
|---|
| 8100 | /i exch def |
|---|
| 8101 | %% indicesfacesadj = liste des indices des faces ou on trouve le sommet i |
|---|
| 8102 | /indicesfacesadj solid i solidfacesadjsommet def |
|---|
| 8103 | %% on recupere les centres des faces concernees |
|---|
| 8104 | /nouveauxsommets [ |
|---|
| 8105 | 0 1 indicesfacesadj length 1 sub { |
|---|
| 8106 | /k exch def |
|---|
| 8107 | solid indicesfacesadj k get solidgetsommetsface isobarycentre3d |
|---|
| 8108 | } for |
|---|
| 8109 | ] def |
|---|
| 8110 | %% et on pose G = barycentre de ces points |
|---|
| 8111 | nouveauxsommets isobarycentre3d /G defpoint3d |
|---|
| 8112 | %% il faut ordonner ces sommets |
|---|
| 8113 | nouveauxsommets 0 getp3d /ptref defpoint3d |
|---|
| 8114 | G solid i solidgetsommet vecteur3d /vecteurnormal defpoint3d |
|---|
| 8115 | nouveauxsommets duparray exch pop |
|---|
| 8116 | {1 dict begin |
|---|
| 8117 | /M defpoint3d |
|---|
| 8118 | G ptref vecteur3d |
|---|
| 8119 | G M vecteur3d |
|---|
| 8120 | vecteurnormal angle3doriente |
|---|
| 8121 | end} papply3d |
|---|
| 8122 | doublebubblesort pop |
|---|
| 8123 | %% nos sommets sont tries |
|---|
| 8124 | /indicesommetstries exch def |
|---|
| 8125 | projection { |
|---|
| 8126 | %% on projette les sommets sur la sphere |
|---|
| 8127 | /nouveauxsommets [ nouveauxsommets {normalize3d r mulv3d} papply3d aload pop ] store |
|---|
| 8128 | } if |
|---|
| 8129 | %% puis on les rajoute au solide |
|---|
| 8130 | /nouveauxindices [ |
|---|
| 8131 | 0 1 nouveauxsommets length 3 idiv 1 sub { |
|---|
| 8132 | /k exch def |
|---|
| 8133 | result nouveauxsommets k getp3d solidaddsommet |
|---|
| 8134 | } for |
|---|
| 8135 | ] def |
|---|
| 8136 | %% ainsi que la face concernee |
|---|
| 8137 | result [ |
|---|
| 8138 | 0 1 indicesommetstries length 1 sub { |
|---|
| 8139 | /k exch def |
|---|
| 8140 | nouveauxindices indicesommetstries k get get |
|---|
| 8141 | } for |
|---|
| 8142 | ] solidaddface |
|---|
| 8143 | /facesaenlever [ facesaenlever aload pop indicesfacesadj aload pop ] store |
|---|
| 8144 | } for |
|---|
| 8145 | result [0 1 n 1 sub {} for] solidrmfaces |
|---|
| 8146 | [N 1 sub -1 0 {} for] {result exch solidrmsommet} apply |
|---|
| 8147 | result |
|---|
| 8148 | end |
|---|
| 8149 | } def |
|---|
| 8150 | |
|---|
| 8151 | %%%%% ### newgeode ### |
|---|
| 8152 | %% syntaxe : solid r newgeode --> solid |
|---|
| 8153 | %% syntaxe : N r newgeode --> solid |
|---|
| 8154 | %% N in {3,4,5} -> polyhedre de depart, r = niveau de recursion |
|---|
| 8155 | /newgeode { |
|---|
| 8156 | 2 dict begin |
|---|
| 8157 | /r exch def |
|---|
| 8158 | dup issolid not { |
|---|
| 8159 | /N exch def |
|---|
| 8160 | N 3 eq { |
|---|
| 8161 | 1 newtetraedre |
|---|
| 8162 | } { |
|---|
| 8163 | N 4 eq { |
|---|
| 8164 | 1 newoctaedre |
|---|
| 8165 | } { |
|---|
| 8166 | 1 newicosaedre |
|---|
| 8167 | } ifelse |
|---|
| 8168 | } ifelse |
|---|
| 8169 | } if |
|---|
| 8170 | |
|---|
| 8171 | r { |
|---|
| 8172 | 15 dict begin |
|---|
| 8173 | /solid exch def |
|---|
| 8174 | solid dupsolid /result exch def pop |
|---|
| 8175 | /n solid solidnombrefaces def |
|---|
| 8176 | n 1 sub -1 0 { |
|---|
| 8177 | /i exch def |
|---|
| 8178 | %% la face d indice i |
|---|
| 8179 | solid i solidgetface /F exch def |
|---|
| 8180 | /i0 F 0 get def |
|---|
| 8181 | /i1 F 1 get def |
|---|
| 8182 | /i2 F 2 get def |
|---|
| 8183 | solid i0 solidgetsommet /A0 defpoint3d |
|---|
| 8184 | solid i1 solidgetsommet /A1 defpoint3d |
|---|
| 8185 | solid i2 solidgetsommet /A2 defpoint3d |
|---|
| 8186 | A0 A1 milieu3d normalize3d /A01 defpoint3d |
|---|
| 8187 | A1 A2 milieu3d normalize3d /A12 defpoint3d |
|---|
| 8188 | A2 A0 milieu3d normalize3d /A20 defpoint3d |
|---|
| 8189 | result A01 solidaddsommet /i01 exch def |
|---|
| 8190 | result A12 solidaddsommet /i12 exch def |
|---|
| 8191 | result A20 solidaddsommet /i20 exch def |
|---|
| 8192 | result i solidrmface |
|---|
| 8193 | result [i0 i01 i20] solidaddface |
|---|
| 8194 | result [i01 i1 i12] solidaddface |
|---|
| 8195 | result [i01 i12 i20] solidaddface |
|---|
| 8196 | result [i20 i12 i2] solidaddface |
|---|
| 8197 | } for |
|---|
| 8198 | result |
|---|
| 8199 | end |
|---|
| 8200 | } repeat |
|---|
| 8201 | end |
|---|
| 8202 | } def |
|---|
| 8203 | |
|---|
| 8204 | %% syntaxe : N r newdualgeode --> solid |
|---|
| 8205 | /newdualgeode { |
|---|
| 8206 | newgeode 1 |
|---|
| 8207 | dualpolyedreregulier |
|---|
| 8208 | } def |
|---|
| 8209 | |
|---|
| 8210 | %%%%% ### fin insertion ### |
|---|
| 8211 | |
|---|
| 8212 | |
|---|
| 8213 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 8214 | %%%% quelques solides precalcules %%%% |
|---|
| 8215 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 8216 | |
|---|
| 8217 | %%%%% ### newface ### |
|---|
| 8218 | %% syntaxe : array newmonoface -> solid |
|---|
| 8219 | %% ou array = tableau de points 2d |
|---|
| 8220 | /newmonoface { |
|---|
| 8221 | 4 dict begin |
|---|
| 8222 | /table exch def |
|---|
| 8223 | /n table length 2 idiv def |
|---|
| 8224 | /S table {0} papply def |
|---|
| 8225 | |
|---|
| 8226 | /F [ |
|---|
| 8227 | [0 1 n 1 sub {} for] |
|---|
| 8228 | ] def |
|---|
| 8229 | S F generesolid |
|---|
| 8230 | end |
|---|
| 8231 | } def |
|---|
| 8232 | |
|---|
| 8233 | %% syntaxe : array newbiface -> solid |
|---|
| 8234 | %% ou array = tableau de points 2d |
|---|
| 8235 | /newbiface { |
|---|
| 8236 | newmonoface |
|---|
| 8237 | dup videsolid |
|---|
| 8238 | } def |
|---|
| 8239 | |
|---|
| 8240 | %%%%% ### newpolreg ### |
|---|
| 8241 | %% syntaxe : r n newpolreg --> solid |
|---|
| 8242 | /newpolreg { |
|---|
| 8243 | 5 dict begin |
|---|
| 8244 | /n exch def |
|---|
| 8245 | /r exch def |
|---|
| 8246 | /S [ |
|---|
| 8247 | 0 360 n div 360 360 n div sub { |
|---|
| 8248 | /theta exch def |
|---|
| 8249 | theta cos r mul |
|---|
| 8250 | theta sin r mul |
|---|
| 8251 | 0 |
|---|
| 8252 | } for |
|---|
| 8253 | ] def |
|---|
| 8254 | /F [ |
|---|
| 8255 | [0 1 n 1 sub {} for] |
|---|
| 8256 | ] def |
|---|
| 8257 | |
|---|
| 8258 | S F generesolid |
|---|
| 8259 | dup videsolid |
|---|
| 8260 | end |
|---|
| 8261 | } def |
|---|
| 8262 | |
|---|
| 8263 | %%%%% ### newgrille ### |
|---|
| 8264 | %% syntaxe : xmin xmax ymin ymax [dx dy] newgrille -> solid |
|---|
| 8265 | %% syntaxe : xmin xmax ymin ymax [nx ny] newgrille -> solid |
|---|
| 8266 | %% syntaxe : xmin xmax ymin ymax {mode} newgrille -> solid |
|---|
| 8267 | %% syntaxe : xmin xmax ymin ymax newgrille -> solid |
|---|
| 8268 | /newgrille { |
|---|
| 8269 | 10 dict begin |
|---|
| 8270 | [[/nx /ny] [1 1] [1. 1.] [1. 1.] [1. 1.] [.5 .5]] gestionsolidmode |
|---|
| 8271 | %% ny nb d etages en y |
|---|
| 8272 | %% nx nb d etages en x |
|---|
| 8273 | /biface false def |
|---|
| 8274 | [nx ny] {0} newsurfaceparametree |
|---|
| 8275 | end |
|---|
| 8276 | } def |
|---|
| 8277 | |
|---|
| 8278 | %% %% syntaxe : xmin xmax ymin ymax [dx dy] {f} newsurface -> solid |
|---|
| 8279 | %% %% f : R^2 -> R |
|---|
| 8280 | /newsurface { |
|---|
| 8281 | true newsurfaceparametree |
|---|
| 8282 | } def |
|---|
| 8283 | |
|---|
| 8284 | /biface true def |
|---|
| 8285 | |
|---|
| 8286 | /newsurfaceparametree { |
|---|
| 8287 | 10 dict begin |
|---|
| 8288 | dup isbool { |
|---|
| 8289 | pop /surfz true def |
|---|
| 8290 | } { |
|---|
| 8291 | /surfz false def |
|---|
| 8292 | } ifelse |
|---|
| 8293 | /f_surface exch def |
|---|
| 8294 | [[/nx /ny] [2 2] [4 4] [1. 1.] [1. 1.] [.25 .25]] gestionsolidmode |
|---|
| 8295 | %% ny nb d etages en y |
|---|
| 8296 | %% nx nb d etages en x |
|---|
| 8297 | /ymax exch def |
|---|
| 8298 | /ymin exch def |
|---|
| 8299 | /xmax exch def |
|---|
| 8300 | /xmin exch def |
|---|
| 8301 | |
|---|
| 8302 | nx isinteger not { |
|---|
| 8303 | %% alors nx est un dx |
|---|
| 8304 | /nx xmax xmin sub nx div cvi store |
|---|
| 8305 | } if |
|---|
| 8306 | ny isinteger not { |
|---|
| 8307 | %% alors ny est un dy |
|---|
| 8308 | /ny ymax ymin sub ny div cvi store |
|---|
| 8309 | } if |
|---|
| 8310 | /dy ymax ymin sub ny div def %% le pas sur y |
|---|
| 8311 | /dx xmax xmin sub nx div def %% le pas sur x |
|---|
| 8312 | |
|---|
| 8313 | /S [ |
|---|
| 8314 | 0 1 nx { |
|---|
| 8315 | /i exch def |
|---|
| 8316 | 0 1 ny { |
|---|
| 8317 | /j exch def |
|---|
| 8318 | /u xmin i dx mul add def |
|---|
| 8319 | /v ymin j dy mul add def |
|---|
| 8320 | u v |
|---|
| 8321 | surfz {2 copy} if |
|---|
| 8322 | f_surface |
|---|
| 8323 | pstrickactionR3 |
|---|
| 8324 | } for |
|---|
| 8325 | } for |
|---|
| 8326 | ] def |
|---|
| 8327 | |
|---|
| 8328 | /F [ |
|---|
| 8329 | 0 1 nx 1 sub { |
|---|
| 8330 | /i exch def |
|---|
| 8331 | 0 1 ny 1 sub { |
|---|
| 8332 | /j exch def |
|---|
| 8333 | [ |
|---|
| 8334 | j 1 add i ny 1 add mul add |
|---|
| 8335 | j i ny 1 add mul add |
|---|
| 8336 | j ny 1 add add i ny 1 add mul add |
|---|
| 8337 | j ny 2 add add i ny 1 add mul add |
|---|
| 8338 | ] |
|---|
| 8339 | } for |
|---|
| 8340 | } for |
|---|
| 8341 | %% 0 1 0 {%nx 1 sub { |
|---|
| 8342 | %% /i exch def |
|---|
| 8343 | %% 0 1 0 {%ny 2 sub { |
|---|
| 8344 | %% /j exch def |
|---|
| 8345 | %% [ |
|---|
| 8346 | %% j 1 add %% i ny mul add |
|---|
| 8347 | %% j %% i ny mul add |
|---|
| 8348 | %% ny 1 add j add %% i ny mul add |
|---|
| 8349 | %% ny 2 add j add %% i ny mul add |
|---|
| 8350 | %% ] |
|---|
| 8351 | %% } for |
|---|
| 8352 | %% } for |
|---|
| 8353 | ] def |
|---|
| 8354 | S F generesolid |
|---|
| 8355 | biface pl@n-en-cours not and {dup videsolid} if |
|---|
| 8356 | end |
|---|
| 8357 | } def |
|---|
| 8358 | |
|---|
| 8359 | %%%%% ### newgrillecirculaire ### |
|---|
| 8360 | %% syntaxe : r option newgrillecirculaire -> solid |
|---|
| 8361 | /newgrillecirculaire { |
|---|
| 8362 | 6 dict begin |
|---|
| 8363 | [[/K /N] [6 6] [6 8] [10 8] [16 12] [16 36]] gestionsolidmode |
|---|
| 8364 | |
|---|
| 8365 | %% N = nb de meridiens (diviseur de 360 = 2^4 * 3^2 * 5) |
|---|
| 8366 | %% K = nb d horizontales (diviseur de 160 = 2^5 * 5) |
|---|
| 8367 | |
|---|
| 8368 | /r exch def |
|---|
| 8369 | /F [ |
|---|
| 8370 | %% 1er etage |
|---|
| 8371 | 1 1 N { |
|---|
| 8372 | /i exch def |
|---|
| 8373 | [0 i i N mod 1 add] |
|---|
| 8374 | } for |
|---|
| 8375 | %% etages suivants |
|---|
| 8376 | 0 1 K 2 sub { |
|---|
| 8377 | /j exch def |
|---|
| 8378 | 1 1 N { |
|---|
| 8379 | /i exch def |
|---|
| 8380 | [i j N mul add |
|---|
| 8381 | i N add j N mul add |
|---|
| 8382 | i N mod N add 1 add j N mul add |
|---|
| 8383 | i N mod 1 add j N mul add] |
|---|
| 8384 | } for |
|---|
| 8385 | } for |
|---|
| 8386 | ] def |
|---|
| 8387 | |
|---|
| 8388 | %% tableau des sommets |
|---|
| 8389 | /S [ |
|---|
| 8390 | 0 0 0 |
|---|
| 8391 | 1 1 K { |
|---|
| 8392 | /j exch def |
|---|
| 8393 | 1 1 N { |
|---|
| 8394 | /i exch def |
|---|
| 8395 | /theta i 360 mul N div def |
|---|
| 8396 | theta cos r j mul K div mul |
|---|
| 8397 | theta sin r j mul K div mul |
|---|
| 8398 | 0 %2 copy f %exch atan 90 div |
|---|
| 8399 | } for |
|---|
| 8400 | } for |
|---|
| 8401 | ] def |
|---|
| 8402 | |
|---|
| 8403 | S F generesolid |
|---|
| 8404 | end |
|---|
| 8405 | } def |
|---|
| 8406 | |
|---|
| 8407 | %% syntaxe : r [dx dy] {f} newsurface* -> solid |
|---|
| 8408 | /newsurface* { |
|---|
| 8409 | 7 dict begin |
|---|
| 8410 | /f_surface exch def |
|---|
| 8411 | [[/nx /ny] [6 6] [6 8] [10 8] [16 12] [16 36]] gestionsolidmode |
|---|
| 8412 | |
|---|
| 8413 | nx isinteger not { |
|---|
| 8414 | %% alors nx est un dx |
|---|
| 8415 | /nx xmax xmin sub nx div cvi store |
|---|
| 8416 | } if |
|---|
| 8417 | ny isinteger not { |
|---|
| 8418 | %% alors ny est un dy |
|---|
| 8419 | /ny ymax ymin sub ny div cvi store |
|---|
| 8420 | } if |
|---|
| 8421 | /dy ymax ymin sub ny div def %% le pas sur y |
|---|
| 8422 | /dx xmax xmin sub nx div def %% le pas sur x |
|---|
| 8423 | |
|---|
| 8424 | %% ny = nb de meridiens |
|---|
| 8425 | %% nx = nb d horizontales |
|---|
| 8426 | |
|---|
| 8427 | /r exch def |
|---|
| 8428 | /F [ |
|---|
| 8429 | %% 1er etage |
|---|
| 8430 | 1 1 ny { |
|---|
| 8431 | /i exch def |
|---|
| 8432 | [0 i i ny mod 1 add] |
|---|
| 8433 | } for |
|---|
| 8434 | %% etages suivants |
|---|
| 8435 | 0 1 nx 2 sub { |
|---|
| 8436 | /j exch def |
|---|
| 8437 | 1 1 ny { |
|---|
| 8438 | /i exch def |
|---|
| 8439 | [i j ny mul add |
|---|
| 8440 | i ny add j ny mul add |
|---|
| 8441 | i ny mod ny add 1 add j ny mul add |
|---|
| 8442 | i ny mod 1 add j ny mul add] |
|---|
| 8443 | } for |
|---|
| 8444 | } for |
|---|
| 8445 | ] def |
|---|
| 8446 | |
|---|
| 8447 | %% tableau des sommets |
|---|
| 8448 | /S [ |
|---|
| 8449 | 0 0 0 |
|---|
| 8450 | 1 1 nx { |
|---|
| 8451 | /j exch def |
|---|
| 8452 | 1 1 ny { |
|---|
| 8453 | /i exch def |
|---|
| 8454 | /theta i 360 mul ny div def |
|---|
| 8455 | theta cos r j mul nx div mul |
|---|
| 8456 | theta sin r j mul nx div mul |
|---|
| 8457 | 2 copy f_surface |
|---|
| 8458 | } for |
|---|
| 8459 | } for |
|---|
| 8460 | ] def |
|---|
| 8461 | |
|---|
| 8462 | S F generesolid |
|---|
| 8463 | end |
|---|
| 8464 | } def |
|---|
| 8465 | |
|---|
| 8466 | %%%%% ### newruban ### |
|---|
| 8467 | %% syntaxe : array h u [n] newruban -> solid d axe (O, u), de maillage vertical n |
|---|
| 8468 | %% syntaxe : array h u newruban -> solid d axe (O, u), |
|---|
| 8469 | %% syntaxe : array h newruban -> solid d axe (O, k), |
|---|
| 8470 | %% ou array tableau de points 2d |
|---|
| 8471 | /newruban { |
|---|
| 8472 | 7 dict begin |
|---|
| 8473 | %% N = nb d etages |
|---|
| 8474 | [[/N] [1] [1] [1] [3] [4]] gestionsolidmode |
|---|
| 8475 | 2 copy pop isarray { |
|---|
| 8476 | /u {0 0 1} def |
|---|
| 8477 | } { |
|---|
| 8478 | /u defpoint3d |
|---|
| 8479 | } ifelse |
|---|
| 8480 | u 0 eq { |
|---|
| 8481 | (Error : 3eme composante nulle dans le vecteur pour newruban) == |
|---|
| 8482 | quit |
|---|
| 8483 | } if |
|---|
| 8484 | pop pop |
|---|
| 8485 | /h exch def |
|---|
| 8486 | /table exch def |
|---|
| 8487 | %% n = indice du dernier point |
|---|
| 8488 | /n table length 2 idiv 1 sub def |
|---|
| 8489 | %% vecteur de translation |
|---|
| 8490 | u |
|---|
| 8491 | h u norme3d div |
|---|
| 8492 | mulv3d /v defpoint3d |
|---|
| 8493 | |
|---|
| 8494 | %% tableau des sommets |
|---|
| 8495 | /S [ |
|---|
| 8496 | 0 1 N { |
|---|
| 8497 | /j exch def |
|---|
| 8498 | 0 1 n { |
|---|
| 8499 | /i exch def |
|---|
| 8500 | table i getp |
|---|
| 8501 | 0 |
|---|
| 8502 | v N j sub N div mulv addv3d |
|---|
| 8503 | } for |
|---|
| 8504 | } for |
|---|
| 8505 | ] def |
|---|
| 8506 | |
|---|
| 8507 | /F [ |
|---|
| 8508 | %% faces etage |
|---|
| 8509 | 1 1 N { |
|---|
| 8510 | /j exch def |
|---|
| 8511 | 1 1 n { |
|---|
| 8512 | /i exch def |
|---|
| 8513 | [i j 1 sub n 1 add mul add |
|---|
| 8514 | i 1 sub j 1 sub n 1 add mul add |
|---|
| 8515 | n 1 add i add 1 sub j 1 sub n 1 add mul add |
|---|
| 8516 | n 1 add i add j 1 sub n 1 add mul add] |
|---|
| 8517 | } for |
|---|
| 8518 | } for |
|---|
| 8519 | ] def |
|---|
| 8520 | |
|---|
| 8521 | S F generesolid |
|---|
| 8522 | dup videsolid |
|---|
| 8523 | end |
|---|
| 8524 | } def |
|---|
| 8525 | |
|---|
| 8526 | %%%%% ### newicosaedre ### |
|---|
| 8527 | /newicosaedre { |
|---|
| 8528 | 3 dict begin |
|---|
| 8529 | /a exch def |
|---|
| 8530 | /S [ |
|---|
| 8531 | 0.8944271 0 0.4472137 |
|---|
| 8532 | 0.2763932 0.8506507 0.4472137 |
|---|
| 8533 | -0.7236067 0.5257311 0.4472137 |
|---|
| 8534 | -0.7236067 -0.5257311 0.4472137 |
|---|
| 8535 | 0.2763932 -0.8506507 0.4472137 |
|---|
| 8536 | 0 0 1 |
|---|
| 8537 | 0 0 -1 |
|---|
| 8538 | -0.8944271 0 -0.4472137 |
|---|
| 8539 | -0.2763932 -0.8506507 -0.4472137 |
|---|
| 8540 | 0.7236067 -0.5257311 -0.4472137 |
|---|
| 8541 | 0.7236067 0.5257311 -0.4472137 |
|---|
| 8542 | -0.2763932 0.8506507 -0.4472137 |
|---|
| 8543 | ] {a mulv3d} papply3d def |
|---|
| 8544 | |
|---|
| 8545 | /F [ |
|---|
| 8546 | [0 1 5] %% 1 2 6 ] |
|---|
| 8547 | [1 2 5] %% 2 3 6 ] |
|---|
| 8548 | [2 3 5] %% 3 4 6 ] |
|---|
| 8549 | [3 4 5] %% 4 5 6 ] |
|---|
| 8550 | [4 0 5] %% 5 1 6 ] |
|---|
| 8551 | [9 0 4] %% 10 1 5 ] |
|---|
| 8552 | [0 9 10] %% 1 10 11] |
|---|
| 8553 | [10 1 0] %% 11 2 1 ] |
|---|
| 8554 | [1 10 11] %% 2 11 12] |
|---|
| 8555 | [11 2 1] %% 12 3 2 ] |
|---|
| 8556 | [2 11 7] %% 3 12 8 ] |
|---|
| 8557 | [2 7 3] %% 3 8 4 ] |
|---|
| 8558 | [3 7 8] %% 4 8 9 ] |
|---|
| 8559 | [3 8 4] %% 4 9 5 ] |
|---|
| 8560 | [4 8 9] %% 5 9 10 ] |
|---|
| 8561 | [6 7 11] %% 7 8 12 ] |
|---|
| 8562 | [6 8 7] %% 7 9 8 ] |
|---|
| 8563 | [6 9 8] %% 7 10 9 ] |
|---|
| 8564 | [6 10 9] %% 7 11 10] |
|---|
| 8565 | [6 11 10] %% 7 12 11] |
|---|
| 8566 | ] def |
|---|
| 8567 | |
|---|
| 8568 | S F generesolid |
|---|
| 8569 | end |
|---|
| 8570 | } def |
|---|
| 8571 | |
|---|
| 8572 | %%%%% ### newdodecaedre ### |
|---|
| 8573 | /newdodecaedre { |
|---|
| 8574 | 3 dict begin |
|---|
| 8575 | /a exch def |
|---|
| 8576 | /S [ |
|---|
| 8577 | 0 0.607062 0.7946545 |
|---|
| 8578 | -0.5773503 0.1875925 0.7946545 |
|---|
| 8579 | -0.3568221 -0.4911235 0.7946545 |
|---|
| 8580 | 0.3568221 -0.4911235 0.7946545 |
|---|
| 8581 | 0.5773503 0.1875925 0.7946545 |
|---|
| 8582 | 0 0.982247 0.1875925 |
|---|
| 8583 | -0.9341724 0.303531 0.1875925 |
|---|
| 8584 | -0.5773503 -0.7946645 0.1875925 |
|---|
| 8585 | 0.5773503 -0.7946645 0.1875925 |
|---|
| 8586 | 0.9341724 0.303531 0.1875925 |
|---|
| 8587 | 0 -0.982247 -0.1875925 |
|---|
| 8588 | 0.9341724 -0.303531 -0.1875925 |
|---|
| 8589 | 0.5773503 0.7946545 -0.1875925 |
|---|
| 8590 | -0.5773503 0.7946545 -0.1875925 |
|---|
| 8591 | -0.9341724 -0.303531 -0.1875925 |
|---|
| 8592 | -0.5773503 -0.1875925 -0.7946545 |
|---|
| 8593 | -0.3568221 0.4911235 -0.7946545 |
|---|
| 8594 | 0.3568221 0.4911235 -0.7946545 |
|---|
| 8595 | 0.5773503 -0.1875925 -0.7946545 |
|---|
| 8596 | 0 -0.607062 -0.7946545 |
|---|
| 8597 | ] {a mulv3d} papply3d def |
|---|
| 8598 | |
|---|
| 8599 | /F [ |
|---|
| 8600 | [0 1 2 3 4] |
|---|
| 8601 | [4 3 8 11 9] |
|---|
| 8602 | [4 9 12 5 0] |
|---|
| 8603 | [0 5 13 6 1] |
|---|
| 8604 | [1 6 14 7 2] |
|---|
| 8605 | [2 7 10 8 3] |
|---|
| 8606 | [10 19 18 11 8] |
|---|
| 8607 | [11 18 17 12 9] |
|---|
| 8608 | [12 17 16 13 5] |
|---|
| 8609 | [13 16 15 14 6] |
|---|
| 8610 | [14 15 19 10 7] |
|---|
| 8611 | [15 16 17 18 19] |
|---|
| 8612 | ] def |
|---|
| 8613 | S F generesolid |
|---|
| 8614 | end |
|---|
| 8615 | } def |
|---|
| 8616 | |
|---|
| 8617 | %%%%% ### newoctaedre ### |
|---|
| 8618 | /newoctaedre { |
|---|
| 8619 | 3 dict begin |
|---|
| 8620 | /a exch def |
|---|
| 8621 | %%Sommets |
|---|
| 8622 | /S [ |
|---|
| 8623 | 0 0 1 |
|---|
| 8624 | 1 0 0 |
|---|
| 8625 | 0 1 0 |
|---|
| 8626 | -1 0 0 |
|---|
| 8627 | 0 -1 0 |
|---|
| 8628 | 0 0 -1 |
|---|
| 8629 | ] {a mulv3d} papply3d def |
|---|
| 8630 | |
|---|
| 8631 | /F [ |
|---|
| 8632 | [0 4 1] |
|---|
| 8633 | [1 2 0] |
|---|
| 8634 | [0 2 3] |
|---|
| 8635 | [3 4 0] |
|---|
| 8636 | [1 5 2] |
|---|
| 8637 | [2 5 3] |
|---|
| 8638 | [3 5 4] |
|---|
| 8639 | [4 5 1] |
|---|
| 8640 | ] def |
|---|
| 8641 | |
|---|
| 8642 | S F generesolid |
|---|
| 8643 | end |
|---|
| 8644 | } def |
|---|
| 8645 | |
|---|
| 8646 | %%%%% ### newtetraedre ### |
|---|
| 8647 | /newtetraedre { |
|---|
| 8648 | 3 dict begin |
|---|
| 8649 | /r exch def |
|---|
| 8650 | %%Tetraedre |
|---|
| 8651 | /S [ |
|---|
| 8652 | 0 0 1 |
|---|
| 8653 | -0.4714045 -0.8164965 -1 3 div |
|---|
| 8654 | 0.942809 0 -1 3 div |
|---|
| 8655 | -0.4714045 0.8164965 -1 3 div |
|---|
| 8656 | ] {r mulv3d} papply3d def |
|---|
| 8657 | |
|---|
| 8658 | /F [ |
|---|
| 8659 | [0 1 2] |
|---|
| 8660 | [0 2 3] |
|---|
| 8661 | [0 3 1] |
|---|
| 8662 | [1 3 2] |
|---|
| 8663 | ] def |
|---|
| 8664 | |
|---|
| 8665 | S F generesolid |
|---|
| 8666 | end |
|---|
| 8667 | } def |
|---|
| 8668 | |
|---|
| 8669 | %%%%% ### newcube ### |
|---|
| 8670 | /newcube { |
|---|
| 8671 | 3 dict begin |
|---|
| 8672 | [[/n] [1] [1] [1] [3] [4]] gestionsolidmode |
|---|
| 8673 | /a exch 2 div def |
|---|
| 8674 | |
|---|
| 8675 | n 1 le { |
|---|
| 8676 | /F [ |
|---|
| 8677 | [0 1 2 3] |
|---|
| 8678 | [0 4 5 1] |
|---|
| 8679 | [1 5 6 2] |
|---|
| 8680 | [2 6 7 3] |
|---|
| 8681 | [0 3 7 4] |
|---|
| 8682 | [4 7 6 5] |
|---|
| 8683 | ] def |
|---|
| 8684 | |
|---|
| 8685 | %% tableau des sommets |
|---|
| 8686 | /S [ |
|---|
| 8687 | 1 1 1 %% 0 |
|---|
| 8688 | -1 1 1 %% 1 |
|---|
| 8689 | -1 -1 1 %% 2 |
|---|
| 8690 | 1 -1 1 %% 3 |
|---|
| 8691 | 1 1 -1 %% 4 |
|---|
| 8692 | -1 1 -1 %% 5 |
|---|
| 8693 | -1 -1 -1 %% 6 |
|---|
| 8694 | 1 -1 -1 %% 7 |
|---|
| 8695 | ] {a mulv3d} papply3d def |
|---|
| 8696 | S F generesolid |
|---|
| 8697 | } { |
|---|
| 8698 | /dl 2 n div def |
|---|
| 8699 | /N n dup mul n add 4 mul def |
|---|
| 8700 | /n1 n 1 sub dup mul def %% nb sommets centre d une face |
|---|
| 8701 | |
|---|
| 8702 | %% tableau des sommets |
|---|
| 8703 | /S1 [ |
|---|
| 8704 | 0 1 n 1 sub { |
|---|
| 8705 | /j exch def |
|---|
| 8706 | 0 1 n { |
|---|
| 8707 | /i exch def |
|---|
| 8708 | -1 i dl mul add |
|---|
| 8709 | -1 j dl mul add |
|---|
| 8710 | 1 |
|---|
| 8711 | } for |
|---|
| 8712 | } for |
|---|
| 8713 | ] def |
|---|
| 8714 | |
|---|
| 8715 | /S2 S1 {-90 0 0 rotateOpoint3d} papply3d def |
|---|
| 8716 | /S3 S2 {-90 0 0 rotateOpoint3d} papply3d def |
|---|
| 8717 | /S4 S3 {-90 0 0 rotateOpoint3d} papply3d def |
|---|
| 8718 | |
|---|
| 8719 | /S5 [ |
|---|
| 8720 | 1 1 n 1 sub { |
|---|
| 8721 | /j exch def |
|---|
| 8722 | 1 1 n 1 sub { |
|---|
| 8723 | /i exch def |
|---|
| 8724 | 1 |
|---|
| 8725 | -1 i dl mul add |
|---|
| 8726 | -1 j dl mul add |
|---|
| 8727 | } for |
|---|
| 8728 | } for |
|---|
| 8729 | ] def |
|---|
| 8730 | |
|---|
| 8731 | /S6 [ |
|---|
| 8732 | 1 1 n 1 sub { |
|---|
| 8733 | /j exch def |
|---|
| 8734 | 1 1 n 1 sub { |
|---|
| 8735 | /i exch def |
|---|
| 8736 | -1 |
|---|
| 8737 | -1 i dl mul add |
|---|
| 8738 | -1 j dl mul add |
|---|
| 8739 | } for |
|---|
| 8740 | } for |
|---|
| 8741 | ] def |
|---|
| 8742 | |
|---|
| 8743 | %% tableau des faces |
|---|
| 8744 | /F1 [ |
|---|
| 8745 | 0 1 n 1 sub { |
|---|
| 8746 | /j exch def |
|---|
| 8747 | 0 1 n 1 sub { |
|---|
| 8748 | /i exch def |
|---|
| 8749 | [ |
|---|
| 8750 | i n 1 add j mul add |
|---|
| 8751 | dup 1 add |
|---|
| 8752 | dup n 1 add add |
|---|
| 8753 | dup 1 sub |
|---|
| 8754 | ] |
|---|
| 8755 | } for |
|---|
| 8756 | } for |
|---|
| 8757 | ] def |
|---|
| 8758 | |
|---|
| 8759 | %% syntaxe : i sommettourgauche --> l indice du i-eme sommet du tour |
|---|
| 8760 | %% de la face gauche (en commencant par l indice 0). ATTENTION : |
|---|
| 8761 | %% utilise la variable globale n = nb d etages |
|---|
| 8762 | /sommettourgauche { |
|---|
| 8763 | 1 dict begin |
|---|
| 8764 | /i exch def |
|---|
| 8765 | i 4 n mul ge { |
|---|
| 8766 | i |
|---|
| 8767 | (Error: indice trop grand dans sommettourgauche) == |
|---|
| 8768 | exit |
|---|
| 8769 | } if |
|---|
| 8770 | n n 1 add i mul add |
|---|
| 8771 | end |
|---|
| 8772 | } def |
|---|
| 8773 | |
|---|
| 8774 | %% syntaxe : i sommetcentregauche --> l indice du i-eme sommet du centre |
|---|
| 8775 | %% de la face gauche (en commencant par l indice 0). ATTENTION : |
|---|
| 8776 | %% utilise les variables globales n = nb d etages, et N = nb sommets |
|---|
| 8777 | %% des 4 1eres faces |
|---|
| 8778 | /sommetcentregauche { |
|---|
| 8779 | 1 dict begin |
|---|
| 8780 | /i exch def |
|---|
| 8781 | i n 1 sub dup mul ge { |
|---|
| 8782 | i |
|---|
| 8783 | (Error: indice trop grand dans sommetcentregauche) == |
|---|
| 8784 | exit |
|---|
| 8785 | } if |
|---|
| 8786 | N i add |
|---|
| 8787 | end |
|---|
| 8788 | } def |
|---|
| 8789 | |
|---|
| 8790 | /F5 [ |
|---|
| 8791 | %%%%% la face gauche %%%%% |
|---|
| 8792 | %% le coin superieur gauche |
|---|
| 8793 | [ |
|---|
| 8794 | 1 sommettourgauche |
|---|
| 8795 | 0 sommettourgauche |
|---|
| 8796 | n 4 mul 1 sub sommettourgauche |
|---|
| 8797 | n1 n 1 sub sub sommetcentregauche |
|---|
| 8798 | ] |
|---|
| 8799 | |
|---|
| 8800 | %% la bande superieure (i from 1 to n-2) |
|---|
| 8801 | 1 1 n 2 sub { |
|---|
| 8802 | /i exch def |
|---|
| 8803 | [ |
|---|
| 8804 | i 1 add sommettourgauche |
|---|
| 8805 | i sommettourgauche |
|---|
| 8806 | n1 n sub i add sommetcentregauche |
|---|
| 8807 | n1 n sub i 1 add add sommetcentregauche |
|---|
| 8808 | ] |
|---|
| 8809 | } for |
|---|
| 8810 | |
|---|
| 8811 | %% le coin superieur droit |
|---|
| 8812 | [ |
|---|
| 8813 | n sommettourgauche |
|---|
| 8814 | n 1 sub sommettourgauche |
|---|
| 8815 | n1 1 sub sommetcentregauche |
|---|
| 8816 | n 1 add sommettourgauche |
|---|
| 8817 | ] |
|---|
| 8818 | |
|---|
| 8819 | %% la descente gauche |
|---|
| 8820 | %% j from 1 to n-2 |
|---|
| 8821 | 1 1 n 2 sub { |
|---|
| 8822 | /j exch def |
|---|
| 8823 | [ |
|---|
| 8824 | n1 n 1 sub j mul sub sommetcentregauche |
|---|
| 8825 | n 4 mul j sub sommettourgauche |
|---|
| 8826 | n 4 mul j 1 add sub sommettourgauche |
|---|
| 8827 | n1 n 1 sub j 1 add mul sub sommetcentregauche |
|---|
| 8828 | ] |
|---|
| 8829 | } for |
|---|
| 8830 | |
|---|
| 8831 | %% les bandes centrales (j from 1 to n-2 et i from 1 to n-2) |
|---|
| 8832 | 1 1 n 2 sub { |
|---|
| 8833 | /j exch def |
|---|
| 8834 | 1 1 n 2 sub { |
|---|
| 8835 | /i exch def |
|---|
| 8836 | [ |
|---|
| 8837 | n1 i n 1 sub j 1 sub mul add sub sommetcentregauche |
|---|
| 8838 | n1 i 1 add n 1 sub j 1 sub mul add sub sommetcentregauche |
|---|
| 8839 | n1 i 1 add n 1 sub j mul add sub sommetcentregauche |
|---|
| 8840 | n1 i n 1 sub j mul add sub sommetcentregauche |
|---|
| 8841 | ] |
|---|
| 8842 | } for |
|---|
| 8843 | } for |
|---|
| 8844 | |
|---|
| 8845 | %% la descente droite |
|---|
| 8846 | 1 1 n 2 sub { |
|---|
| 8847 | /j exch def |
|---|
| 8848 | [ |
|---|
| 8849 | n j add sommettourgauche |
|---|
| 8850 | n1 1 sub j 1 sub n 1 sub mul sub sommetcentregauche |
|---|
| 8851 | n1 1 sub j n 1 sub mul sub sommetcentregauche |
|---|
| 8852 | n j 1 add add sommettourgauche |
|---|
| 8853 | ] |
|---|
| 8854 | } for |
|---|
| 8855 | |
|---|
| 8856 | %% le coin inferieur gauche |
|---|
| 8857 | [ |
|---|
| 8858 | 0 sommetcentregauche |
|---|
| 8859 | n 3 mul 1 add sommettourgauche |
|---|
| 8860 | n 3 mul sommettourgauche |
|---|
| 8861 | n 3 mul 1 sub sommettourgauche |
|---|
| 8862 | ] |
|---|
| 8863 | |
|---|
| 8864 | %% la bande inferieure (i from 1 to n-2) |
|---|
| 8865 | 1 1 n 2 sub { |
|---|
| 8866 | /i exch def |
|---|
| 8867 | [ |
|---|
| 8868 | i sommetcentregauche |
|---|
| 8869 | i 1 sub sommetcentregauche |
|---|
| 8870 | n 3 mul i sub sommettourgauche |
|---|
| 8871 | n 3 mul i sub 1 sub sommettourgauche |
|---|
| 8872 | ] |
|---|
| 8873 | } for |
|---|
| 8874 | |
|---|
| 8875 | %% le coin inferieur droit |
|---|
| 8876 | [ |
|---|
| 8877 | n 2 mul 1 sub sommettourgauche |
|---|
| 8878 | n 2 sub sommetcentregauche |
|---|
| 8879 | n 2 mul 1 add sommettourgauche |
|---|
| 8880 | n 2 mul sommettourgauche |
|---|
| 8881 | ] |
|---|
| 8882 | ] def |
|---|
| 8883 | |
|---|
| 8884 | %% syntaxe : i sommettourdroit --> l indice du i-eme sommet du tour |
|---|
| 8885 | %% de la face droit (en commencant par l indice 0). ATTENTION : |
|---|
| 8886 | %% utilise la variable globale n = nb d etages |
|---|
| 8887 | /sommettourdroit { |
|---|
| 8888 | 1 dict begin |
|---|
| 8889 | /i exch def |
|---|
| 8890 | i 4 n mul ge { |
|---|
| 8891 | i |
|---|
| 8892 | (Error: indice trop grand dans sommettourdroit) == |
|---|
| 8893 | exit |
|---|
| 8894 | } if |
|---|
| 8895 | n 1 add i mul |
|---|
| 8896 | end |
|---|
| 8897 | } def |
|---|
| 8898 | |
|---|
| 8899 | %% syntaxe : i sommetcentredroit --> l indice du i-eme sommet du centre |
|---|
| 8900 | %% de la face droit (en commencant par l indice 0). ATTENTION : |
|---|
| 8901 | %% utilise les variables globales n = nb d etages, et N = nb sommets |
|---|
| 8902 | %% des 4 1eres faces |
|---|
| 8903 | /sommetcentredroit { |
|---|
| 8904 | 1 dict begin |
|---|
| 8905 | /i exch def |
|---|
| 8906 | i n 1 sub dup mul ge { |
|---|
| 8907 | i |
|---|
| 8908 | (Error: indice trop grand dans sommetcentredroit) == |
|---|
| 8909 | exit |
|---|
| 8910 | } if |
|---|
| 8911 | N n1 add i add |
|---|
| 8912 | end |
|---|
| 8913 | } def |
|---|
| 8914 | |
|---|
| 8915 | /F6 [ |
|---|
| 8916 | %% coin superieur droit |
|---|
| 8917 | [ |
|---|
| 8918 | 0 sommettourdroit |
|---|
| 8919 | 1 sommettourdroit |
|---|
| 8920 | n1 n 1 sub sub sommetcentredroit |
|---|
| 8921 | 4 n mul 1 sub sommettourdroit |
|---|
| 8922 | ] |
|---|
| 8923 | %% coin superieur gauche |
|---|
| 8924 | [ |
|---|
| 8925 | n 1 sub sommettourdroit |
|---|
| 8926 | n sommettourdroit |
|---|
| 8927 | n 1 add sommettourdroit |
|---|
| 8928 | n1 1 sub sommetcentredroit |
|---|
| 8929 | ] |
|---|
| 8930 | %% coin inferieur gauche |
|---|
| 8931 | [ |
|---|
| 8932 | n 2 sub sommetcentredroit |
|---|
| 8933 | 2 n mul 1 sub sommettourdroit |
|---|
| 8934 | 2 n mul sommettourdroit |
|---|
| 8935 | 2 n mul 1 add sommettourdroit |
|---|
| 8936 | ] |
|---|
| 8937 | %% coin inferieur droit |
|---|
| 8938 | [ |
|---|
| 8939 | 3 n mul 1 add sommettourdroit |
|---|
| 8940 | 0 sommetcentredroit |
|---|
| 8941 | 3 n mul 1 sub sommettourdroit |
|---|
| 8942 | 3 n mul sommettourdroit |
|---|
| 8943 | ] |
|---|
| 8944 | %% bande superieure |
|---|
| 8945 | 1 1 n 2 sub { |
|---|
| 8946 | /i exch def |
|---|
| 8947 | [ |
|---|
| 8948 | i sommettourdroit |
|---|
| 8949 | i 1 add sommettourdroit |
|---|
| 8950 | n 1 sub n 2 sub mul i add sommetcentredroit |
|---|
| 8951 | n 1 sub n 2 sub mul i 1 sub add sommetcentredroit |
|---|
| 8952 | ] |
|---|
| 8953 | } for |
|---|
| 8954 | %% bande inferieure |
|---|
| 8955 | 1 1 n 2 sub { |
|---|
| 8956 | /i exch def |
|---|
| 8957 | [ |
|---|
| 8958 | i 1 sub sommetcentredroit |
|---|
| 8959 | i sommetcentredroit |
|---|
| 8960 | 3 n mul 1 sub i sub sommettourdroit |
|---|
| 8961 | 3 n mul i sub sommettourdroit |
|---|
| 8962 | ] |
|---|
| 8963 | } for |
|---|
| 8964 | %% descente gauche |
|---|
| 8965 | 1 1 n 2 sub { |
|---|
| 8966 | /i exch def |
|---|
| 8967 | [ |
|---|
| 8968 | n1 1 sub i 1 sub n 1 sub mul sub sommetcentredroit |
|---|
| 8969 | n i add sommettourdroit |
|---|
| 8970 | n i 1 add add sommettourdroit |
|---|
| 8971 | n1 1 sub i n 1 sub mul sub sommetcentredroit |
|---|
| 8972 | ] |
|---|
| 8973 | } for |
|---|
| 8974 | %% descente droite |
|---|
| 8975 | 1 1 n 2 sub { |
|---|
| 8976 | /i exch def |
|---|
| 8977 | [ |
|---|
| 8978 | 4 n mul i sub sommettourdroit |
|---|
| 8979 | n 1 sub n 1 sub i sub mul sommetcentredroit |
|---|
| 8980 | n 1 sub n 2 sub i sub mul sommetcentredroit |
|---|
| 8981 | 4 n mul i sub 1 sub sommettourdroit |
|---|
| 8982 | ] |
|---|
| 8983 | } for |
|---|
| 8984 | %% bandes interieures |
|---|
| 8985 | 1 1 n 2 sub { |
|---|
| 8986 | /j exch def |
|---|
| 8987 | 1 1 n 2 sub { |
|---|
| 8988 | /i exch def |
|---|
| 8989 | [ |
|---|
| 8990 | n 1 sub j mul i 1 sub add sommetcentredroit |
|---|
| 8991 | n 1 sub j mul i add sommetcentredroit |
|---|
| 8992 | n 1 sub j 1 sub mul i add sommetcentredroit |
|---|
| 8993 | n 1 sub j 1 sub mul i 1 sub add sommetcentredroit |
|---|
| 8994 | ] |
|---|
| 8995 | } for |
|---|
| 8996 | } for |
|---|
| 8997 | |
|---|
| 8998 | ] def |
|---|
| 8999 | |
|---|
| 9000 | /F2 F1 {{n dup mul n add add} apply} apply def |
|---|
| 9001 | /F3 F2 {{n dup mul n add add} apply} apply def |
|---|
| 9002 | /F4 F3 {{n dup mul n add add} apply} apply def |
|---|
| 9003 | |
|---|
| 9004 | |
|---|
| 9005 | S1 S2 append S3 append S4 append S5 append S6 append {a mulv3d} papply3d |
|---|
| 9006 | F1 F2 append F3 append F4 append {{N mod} apply} apply F5 append F6 append |
|---|
| 9007 | generesolid |
|---|
| 9008 | } ifelse |
|---|
| 9009 | end |
|---|
| 9010 | } def |
|---|
| 9011 | |
|---|
| 9012 | %%%%% ### newparallelepiped ### |
|---|
| 9013 | % 14 octobre 2006 |
|---|
| 9014 | /newparallelepiped { |
|---|
| 9015 | 2 dict begin |
|---|
| 9016 | /c exch 2 div def |
|---|
| 9017 | /b exch 2 div def |
|---|
| 9018 | /a exch 2 div def |
|---|
| 9019 | /F [ |
|---|
| 9020 | [0 1 2 3] |
|---|
| 9021 | [0 4 5 1] |
|---|
| 9022 | [1 5 6 2] |
|---|
| 9023 | [2 6 7 3] |
|---|
| 9024 | [0 3 7 4] |
|---|
| 9025 | [4 7 6 5] |
|---|
| 9026 | ] def |
|---|
| 9027 | |
|---|
| 9028 | %% tableau des sommets |
|---|
| 9029 | /S [ |
|---|
| 9030 | a b c %% 0 |
|---|
| 9031 | a neg b c %% 1 |
|---|
| 9032 | a neg b neg c %% 2 |
|---|
| 9033 | a b neg c %% 3 |
|---|
| 9034 | a b c neg %% 4 |
|---|
| 9035 | a neg b c neg %% 5 |
|---|
| 9036 | a neg b neg c neg %% 6 |
|---|
| 9037 | a b neg c neg %% 7 |
|---|
| 9038 | ] def |
|---|
| 9039 | S F generesolid |
|---|
| 9040 | end |
|---|
| 9041 | } def |
|---|
| 9042 | |
|---|
| 9043 | %%%%% ### newcylindre ### |
|---|
| 9044 | %% syntaxe : z0 r0 z1 newcylindre -> solide |
|---|
| 9045 | %% syntaxe : z0 r0 z1 {mode} newcylindre -> solide |
|---|
| 9046 | %% syntaxe : z0 r0 z1 [n1 n2] newcylindre -> solide |
|---|
| 9047 | %% syntaxe : a b {f} {u} h [n1 n2] newcylindre |
|---|
| 9048 | /newcylindre { |
|---|
| 9049 | 2 dict begin |
|---|
| 9050 | [[/n2 /n1] [1 6] [1 8] [1 10] [3 12] [5 18]] gestionsolidmode |
|---|
| 9051 | 2 copy pop xcheck { |
|---|
| 9052 | %% cylindre cas general |
|---|
| 9053 | /h exch def |
|---|
| 9054 | /U exch def |
|---|
| 9055 | U normalize3d /u defpoint3d |
|---|
| 9056 | /lafonction exch def |
|---|
| 9057 | /b exch def |
|---|
| 9058 | /a exch def |
|---|
| 9059 | /pas b a sub n1 div def |
|---|
| 9060 | /vpas h n2 div def |
|---|
| 9061 | /S [ |
|---|
| 9062 | 0 1 n2 { |
|---|
| 9063 | /j exch def |
|---|
| 9064 | 0 1 n1 { |
|---|
| 9065 | /i exch def |
|---|
| 9066 | a i pas mul add lafonction |
|---|
| 9067 | u j vpas mul mulv3d addv3d |
|---|
| 9068 | } for |
|---|
| 9069 | } for |
|---|
| 9070 | ] def |
|---|
| 9071 | /F [ |
|---|
| 9072 | 0 1 n2 1 sub { |
|---|
| 9073 | /j exch def |
|---|
| 9074 | 0 1 n1 1 sub { |
|---|
| 9075 | /i exch def |
|---|
| 9076 | [ |
|---|
| 9077 | i n1 1 add j mul add |
|---|
| 9078 | dup 1 add |
|---|
| 9079 | dup n1 1 add add |
|---|
| 9080 | dup 1 sub |
|---|
| 9081 | ] |
|---|
| 9082 | } for |
|---|
| 9083 | } for |
|---|
| 9084 | ] def |
|---|
| 9085 | |
|---|
| 9086 | S F generesolid |
|---|
| 9087 | % dup videsolid |
|---|
| 9088 | } { |
|---|
| 9089 | %% cylindre de revolution |
|---|
| 9090 | 2 copy pop [n2 n1] newtronccone |
|---|
| 9091 | } ifelse |
|---|
| 9092 | end |
|---|
| 9093 | } def |
|---|
| 9094 | |
|---|
| 9095 | %% syntaxe : z0 r0 z1 newcylindrecreux -> solide |
|---|
| 9096 | /newcylindrecreux { |
|---|
| 9097 | newcylindre |
|---|
| 9098 | dup creusesolid |
|---|
| 9099 | } def |
|---|
| 9100 | |
|---|
| 9101 | %%%%% ### newtronccone ### |
|---|
| 9102 | %% syntaxe : z0 r0 z1 r1 newtronccone -> solid |
|---|
| 9103 | /newtronccone { |
|---|
| 9104 | 11 dict begin |
|---|
| 9105 | [[/n /N] [1 6] [1 8] [1 10] [3 12] [5 18]] gestionsolidmode |
|---|
| 9106 | |
|---|
| 9107 | /r1 exch def |
|---|
| 9108 | /z1 exch def |
|---|
| 9109 | /r0 exch def |
|---|
| 9110 | /z0 exch def |
|---|
| 9111 | /dz z1 z0 sub n div def |
|---|
| 9112 | /dr r1 r0 sub n div def |
|---|
| 9113 | |
|---|
| 9114 | /FE [ |
|---|
| 9115 | [0 1 N 1 sub {} for] |
|---|
| 9116 | [n 1 add N mul 1 sub -1 n N mul {} for] |
|---|
| 9117 | |
|---|
| 9118 | 0 1 n 1 sub { |
|---|
| 9119 | /k exch def |
|---|
| 9120 | k N mul 1 add 1 k 1 add N mul 1 sub { |
|---|
| 9121 | /i exch def |
|---|
| 9122 | [i i 1 sub N i add 1 sub N i add] |
|---|
| 9123 | } for |
|---|
| 9124 | [k N mul k 1 add N mul 1 sub k 2 add N mul 1 sub k 1 add N mul] |
|---|
| 9125 | } for |
|---|
| 9126 | |
|---|
| 9127 | ] def |
|---|
| 9128 | |
|---|
| 9129 | %% tableau des sommets |
|---|
| 9130 | /S [ |
|---|
| 9131 | n -1 0 { |
|---|
| 9132 | /k exch def |
|---|
| 9133 | 0 1 N 1 sub { |
|---|
| 9134 | /i exch def |
|---|
| 9135 | 360 N idiv i mul cos r0 dr k mul add mul |
|---|
| 9136 | 360 N idiv i mul sin r0 dr k mul add mul |
|---|
| 9137 | z0 dz k mul add |
|---|
| 9138 | } for |
|---|
| 9139 | } for |
|---|
| 9140 | ] def |
|---|
| 9141 | S FE generesolid |
|---|
| 9142 | end |
|---|
| 9143 | } def |
|---|
| 9144 | |
|---|
| 9145 | %% syntaxe : z0 r0 z1 r1 newtroncconecreux -> solid |
|---|
| 9146 | /newtroncconecreux { |
|---|
| 9147 | newtronccone |
|---|
| 9148 | dup creusesolid |
|---|
| 9149 | } def |
|---|
| 9150 | |
|---|
| 9151 | %%%%% ### newcone ### |
|---|
| 9152 | %% syntaxe : z0 r0 z1 newcone -> solid |
|---|
| 9153 | %% syntaxe : z0 r0 z1 {mode} newcone -> solid |
|---|
| 9154 | %% syntaxe : z0 r0 z1 [n1 n2] newcone -> solid |
|---|
| 9155 | %% syntaxe : a b {f} {sommet} [n1 n2] newcone -> solid |
|---|
| 9156 | /newcone { |
|---|
| 9157 | 11 dict begin |
|---|
| 9158 | [ [/n /N] [1 6] [1 8] [1 10] [3 12] [5 18] ] gestionsolidmode |
|---|
| 9159 | dup xcheck { |
|---|
| 9160 | %% cas general |
|---|
| 9161 | /sommet exch def |
|---|
| 9162 | /lafonction exch def |
|---|
| 9163 | /b exch def |
|---|
| 9164 | /a exch def |
|---|
| 9165 | |
|---|
| 9166 | /pas b a sub N div def |
|---|
| 9167 | /S [ |
|---|
| 9168 | sommet |
|---|
| 9169 | 0 1 n 1 sub { |
|---|
| 9170 | /j exch def |
|---|
| 9171 | 0 1 N { |
|---|
| 9172 | /i exch def |
|---|
| 9173 | a i pas mul add lafonction |
|---|
| 9174 | dupp3d sommet vecteur3d j n div mulv3d addv3d |
|---|
| 9175 | } for |
|---|
| 9176 | } for |
|---|
| 9177 | 1 1 n { |
|---|
| 9178 | /j exch def |
|---|
| 9179 | 0 1 N { |
|---|
| 9180 | /i exch def |
|---|
| 9181 | a i pas mul add lafonction |
|---|
| 9182 | sommet vecteur3d j n div mulv3d sommet addv3d |
|---|
| 9183 | } for |
|---|
| 9184 | } for |
|---|
| 9185 | ] def |
|---|
| 9186 | |
|---|
| 9187 | /F [ |
|---|
| 9188 | %% les etages inferieurs |
|---|
| 9189 | 0 1 n 2 sub { |
|---|
| 9190 | /j exch def |
|---|
| 9191 | 1 1 N { |
|---|
| 9192 | /i exch def |
|---|
| 9193 | [ |
|---|
| 9194 | i j N 1 add mul add |
|---|
| 9195 | dup 1 add |
|---|
| 9196 | dup N add 1 add |
|---|
| 9197 | dup 1 sub |
|---|
| 9198 | ] |
|---|
| 9199 | } for |
|---|
| 9200 | } for |
|---|
| 9201 | %% dernier etage inferieur |
|---|
| 9202 | 1 1 N { |
|---|
| 9203 | /i exch def |
|---|
| 9204 | [ |
|---|
| 9205 | i N 1 add n 1 sub mul add |
|---|
| 9206 | dup 1 add |
|---|
| 9207 | 0 |
|---|
| 9208 | ] |
|---|
| 9209 | } for |
|---|
| 9210 | %% premier etage superieur |
|---|
| 9211 | 1 1 N { |
|---|
| 9212 | /i exch def |
|---|
| 9213 | [ |
|---|
| 9214 | i N 1 add n mul add |
|---|
| 9215 | dup 1 add |
|---|
| 9216 | 0 |
|---|
| 9217 | exch |
|---|
| 9218 | ] |
|---|
| 9219 | } for |
|---|
| 9220 | %% les etages superieurs |
|---|
| 9221 | n 1 n 2 mul 2 sub { |
|---|
| 9222 | /j exch def |
|---|
| 9223 | 1 1 N { |
|---|
| 9224 | /i exch def |
|---|
| 9225 | [ |
|---|
| 9226 | i j N 1 add mul add |
|---|
| 9227 | dup 1 add |
|---|
| 9228 | dup N add 1 add |
|---|
| 9229 | dup 1 sub |
|---|
| 9230 | ] |
|---|
| 9231 | } for |
|---|
| 9232 | } for |
|---|
| 9233 | ] def |
|---|
| 9234 | |
|---|
| 9235 | S F generesolid |
|---|
| 9236 | % dup videsolid |
|---|
| 9237 | } { |
|---|
| 9238 | %% cylindre de revolution |
|---|
| 9239 | /z1 exch def |
|---|
| 9240 | /r0 exch def |
|---|
| 9241 | /z0 exch def |
|---|
| 9242 | /dz z1 z0 sub n div def |
|---|
| 9243 | /dr r0 n div def |
|---|
| 9244 | |
|---|
| 9245 | /F [ |
|---|
| 9246 | %% la base |
|---|
| 9247 | [N 1 sub -1 0 {} for] |
|---|
| 9248 | %% le dernier etage |
|---|
| 9249 | n 1 sub N mul 1 add 1 n N mul 1 sub { |
|---|
| 9250 | /i exch def |
|---|
| 9251 | [i 1 sub i n N mul] |
|---|
| 9252 | } for |
|---|
| 9253 | [n N mul 1 sub n 1 sub N mul n N mul] |
|---|
| 9254 | %% les autres etages |
|---|
| 9255 | 0 1 n 2 sub { |
|---|
| 9256 | /j exch def |
|---|
| 9257 | 0 N j mul add 1 N N j mul add 2 sub { |
|---|
| 9258 | /i exch def |
|---|
| 9259 | [i i 1 add dup N add dup 1 sub] |
|---|
| 9260 | } for |
|---|
| 9261 | [N N j mul add 1 sub N j mul dup N add dup N add 1 sub] |
|---|
| 9262 | } for |
|---|
| 9263 | ] def |
|---|
| 9264 | |
|---|
| 9265 | %% tableau des sommets |
|---|
| 9266 | /S [ |
|---|
| 9267 | %% etage no j (in [1; n]) |
|---|
| 9268 | 0 1 n 1 sub { |
|---|
| 9269 | /j exch def |
|---|
| 9270 | 0 1 N 1 sub { |
|---|
| 9271 | /i exch def |
|---|
| 9272 | 360 N idiv i mul cos r0 dr j mul sub mul |
|---|
| 9273 | 360 N idiv i mul sin r0 dr j mul sub mul |
|---|
| 9274 | z0 dz j mul add |
|---|
| 9275 | } for |
|---|
| 9276 | } for |
|---|
| 9277 | 0 0 z1 |
|---|
| 9278 | ] def |
|---|
| 9279 | S F generesolid |
|---|
| 9280 | } ifelse |
|---|
| 9281 | end |
|---|
| 9282 | } def |
|---|
| 9283 | |
|---|
| 9284 | %% %% syntaxe : z0 r0 z1 newconecreux -> solid |
|---|
| 9285 | /newconecreux { |
|---|
| 9286 | newcone |
|---|
| 9287 | dup 0 solidrmface |
|---|
| 9288 | dup videsolid |
|---|
| 9289 | } def |
|---|
| 9290 | |
|---|
| 9291 | %%%%% ### newtore ### |
|---|
| 9292 | %% syntaxe : r R newtore -> solid |
|---|
| 9293 | /newtore { |
|---|
| 9294 | 10 dict begin |
|---|
| 9295 | [[/n1 /n2] [4 5] [6 10] [8 12] [9 18] [18 36]] gestionsolidmode |
|---|
| 9296 | /n2 n2 3 max store |
|---|
| 9297 | /n1 n1 2 max store |
|---|
| 9298 | /R exch def |
|---|
| 9299 | /r exch def |
|---|
| 9300 | /S [ |
|---|
| 9301 | 0 1 n1 1 sub { |
|---|
| 9302 | /i exch def |
|---|
| 9303 | 360 n1 div i mul cos r mul R add |
|---|
| 9304 | 360 n1 div i mul sin r mul |
|---|
| 9305 | } for |
|---|
| 9306 | ] |
|---|
| 9307 | def |
|---|
| 9308 | S [n2] newanneau |
|---|
| 9309 | end |
|---|
| 9310 | } def |
|---|
| 9311 | |
|---|
| 9312 | %%%%% ### newprisme ### |
|---|
| 9313 | %% syntaxe : array z0 z1 newprisme -> solid d axe (O, u), |
|---|
| 9314 | /newprismedroit { |
|---|
| 9315 | [[/N] [1] [1] [1] [3] [6]] gestionsolidmode |
|---|
| 9316 | 0 0 1 [N] newprisme |
|---|
| 9317 | } def |
|---|
| 9318 | |
|---|
| 9319 | %% syntaxe : array z0 z1 u newprisme -> solid d axe (O, u), |
|---|
| 9320 | %% ou array tableau de points 2d |
|---|
| 9321 | /newprisme { |
|---|
| 9322 | 7 dict begin |
|---|
| 9323 | [[/N] [1] [1] [1] [3] [6]] gestionsolidmode |
|---|
| 9324 | dup 0 eq { |
|---|
| 9325 | (Error : 3eme composante nulle dans le vecteur pour newprisme) == |
|---|
| 9326 | quit |
|---|
| 9327 | } if |
|---|
| 9328 | /u defpoint3d |
|---|
| 9329 | /z1 exch def |
|---|
| 9330 | /z0 exch def |
|---|
| 9331 | %% N = nb d etages |
|---|
| 9332 | /table exch def |
|---|
| 9333 | %% n = indice du dernier point |
|---|
| 9334 | /n table length 2 idiv 1 sub def |
|---|
| 9335 | %% vecteur de translation |
|---|
| 9336 | u |
|---|
| 9337 | z1 z0 sub u norme3d div |
|---|
| 9338 | mulv3d /v defpoint3d |
|---|
| 9339 | |
|---|
| 9340 | %% tableau des sommets |
|---|
| 9341 | /S [ |
|---|
| 9342 | 0 1 N { |
|---|
| 9343 | /j exch def |
|---|
| 9344 | 0 1 n { |
|---|
| 9345 | /i exch def |
|---|
| 9346 | table i getp |
|---|
| 9347 | z0 |
|---|
| 9348 | v N j sub N div mulv addv3d |
|---|
| 9349 | } for |
|---|
| 9350 | } for |
|---|
| 9351 | ] def |
|---|
| 9352 | |
|---|
| 9353 | /F [ |
|---|
| 9354 | %% face superieure |
|---|
| 9355 | [0 1 n {} for] |
|---|
| 9356 | %% base |
|---|
| 9357 | [N 1 add n 1 add mul 1 sub -1 N n 1 add mul {} for] |
|---|
| 9358 | %% faces etage |
|---|
| 9359 | 1 1 N { |
|---|
| 9360 | /j exch def |
|---|
| 9361 | 1 1 n { |
|---|
| 9362 | /i exch def |
|---|
| 9363 | [i j 1 sub n 1 add mul add |
|---|
| 9364 | i 1 sub j 1 sub n 1 add mul add |
|---|
| 9365 | n 1 add i add 1 sub j 1 sub n 1 add mul add |
|---|
| 9366 | n 1 add i add j 1 sub n 1 add mul add] |
|---|
| 9367 | } for |
|---|
| 9368 | [0 j 1 sub n 1 add mul add |
|---|
| 9369 | n j 1 sub n 1 add mul add |
|---|
| 9370 | 2 n mul 1 add j 1 sub n 1 add mul add |
|---|
| 9371 | n 1 add j 1 sub n 1 add mul add] |
|---|
| 9372 | } for |
|---|
| 9373 | ] def |
|---|
| 9374 | |
|---|
| 9375 | S F generesolid |
|---|
| 9376 | end |
|---|
| 9377 | } def |
|---|
| 9378 | |
|---|
| 9379 | %%%%% ### newsphere ### |
|---|
| 9380 | %% syntaxe : r option newsphere -> solid |
|---|
| 9381 | /newsphere { |
|---|
| 9382 | 2 dict begin |
|---|
| 9383 | [[/K /N] [6 6] [8 8] [10 12] [16 12] [16 36]] gestionsolidmode |
|---|
| 9384 | -90 90 [K N] newcalottesphere |
|---|
| 9385 | end |
|---|
| 9386 | } def |
|---|
| 9387 | |
|---|
| 9388 | %% syntaxe : r phi theta option newcalottesphere -> solid |
|---|
| 9389 | /newcalottesphere { |
|---|
| 9390 | 6 dict begin |
|---|
| 9391 | [[/K /N] [6 6] [8 8] [10 12] [16 12] [16 36]] gestionsolidmode |
|---|
| 9392 | |
|---|
| 9393 | %% test de beta (ex-theta) |
|---|
| 9394 | dup 90 eq { |
|---|
| 9395 | /beta exch def |
|---|
| 9396 | /idebut 1 def |
|---|
| 9397 | } { |
|---|
| 9398 | /beta exch 80 min -80 max def |
|---|
| 9399 | /idebut 0 def |
|---|
| 9400 | } ifelse |
|---|
| 9401 | %% test de alpha (ex-phi) |
|---|
| 9402 | dup -90 eq { |
|---|
| 9403 | /alpha exch def |
|---|
| 9404 | } { |
|---|
| 9405 | /alpha exch beta min -80 max def |
|---|
| 9406 | } ifelse |
|---|
| 9407 | /r exch def |
|---|
| 9408 | beta 90 eq { |
|---|
| 9409 | alpha -90 eq { |
|---|
| 9410 | /ifin K def |
|---|
| 9411 | /db alpha beta sub K 1 add div def |
|---|
| 9412 | } { |
|---|
| 9413 | /ifin K def |
|---|
| 9414 | /db alpha beta sub K div def |
|---|
| 9415 | } ifelse |
|---|
| 9416 | } { |
|---|
| 9417 | alpha -90 eq { |
|---|
| 9418 | /ifin K 1 sub def |
|---|
| 9419 | /db alpha beta sub K div def |
|---|
| 9420 | } { |
|---|
| 9421 | /ifin K 1 sub def |
|---|
| 9422 | /db alpha beta sub K 1 sub div def |
|---|
| 9423 | } ifelse |
|---|
| 9424 | } ifelse |
|---|
| 9425 | |
|---|
| 9426 | %% nombre de sommets -2 |
|---|
| 9427 | /nb N K mul def |
|---|
| 9428 | |
|---|
| 9429 | %% tableau des sommets |
|---|
| 9430 | /S [ |
|---|
| 9431 | idebut 1 ifin { |
|---|
| 9432 | /j exch def |
|---|
| 9433 | /phi beta j db mul add def |
|---|
| 9434 | phi cos r mul /r_tmp exch def |
|---|
| 9435 | 0 1 N 1 sub { |
|---|
| 9436 | /i exch def |
|---|
| 9437 | 360 N idiv i mul cos r_tmp mul |
|---|
| 9438 | 360 N idiv i mul sin r_tmp mul |
|---|
| 9439 | phi sin r mul |
|---|
| 9440 | } for |
|---|
| 9441 | } for |
|---|
| 9442 | 0 0 r neg |
|---|
| 9443 | 0 0 r |
|---|
| 9444 | ] def |
|---|
| 9445 | |
|---|
| 9446 | /F [ |
|---|
| 9447 | %% calotte inferieure |
|---|
| 9448 | alpha -90 eq { |
|---|
| 9449 | 1 1 N 1 sub { |
|---|
| 9450 | /i exch def |
|---|
| 9451 | [ |
|---|
| 9452 | nb |
|---|
| 9453 | nb i sub |
|---|
| 9454 | nb i 1 add sub |
|---|
| 9455 | ] |
|---|
| 9456 | } for |
|---|
| 9457 | [nb nb N sub nb 1 sub] |
|---|
| 9458 | } { |
|---|
| 9459 | [nb 1 sub -1 nb N sub {} for ] |
|---|
| 9460 | } ifelse |
|---|
| 9461 | |
|---|
| 9462 | %% calotte superieure |
|---|
| 9463 | beta 90 eq { |
|---|
| 9464 | 0 1 N 1 sub { |
|---|
| 9465 | /i exch def |
|---|
| 9466 | [i i 1 add N mod N K mul 1 add] |
|---|
| 9467 | } for |
|---|
| 9468 | } { |
|---|
| 9469 | [0 1 N 1 sub {} for] |
|---|
| 9470 | } ifelse |
|---|
| 9471 | |
|---|
| 9472 | 1 1 K 1 sub { |
|---|
| 9473 | /j exch def |
|---|
| 9474 | [ |
|---|
| 9475 | j N mul |
|---|
| 9476 | j N mul 1 add |
|---|
| 9477 | j 1 sub N mul 1 add |
|---|
| 9478 | j 1 sub N mul |
|---|
| 9479 | ] |
|---|
| 9480 | N 2 sub {dup {1 add} apply} repeat |
|---|
| 9481 | [ |
|---|
| 9482 | j 1 add N mul 1 sub |
|---|
| 9483 | j N mul |
|---|
| 9484 | j 1 sub N mul |
|---|
| 9485 | j N mul 1 sub |
|---|
| 9486 | ] |
|---|
| 9487 | } for |
|---|
| 9488 | ] def |
|---|
| 9489 | |
|---|
| 9490 | S F generesolid |
|---|
| 9491 | end |
|---|
| 9492 | } def |
|---|
| 9493 | |
|---|
| 9494 | %% syntaxe : r phi theta option newcalottespherecreuse -> solid |
|---|
| 9495 | /newcalottespherecreuse { |
|---|
| 9496 | 6 dict begin |
|---|
| 9497 | [[/K /N] [6 6] [8 8] [10 12] [16 12] [16 36]] gestionsolidmode |
|---|
| 9498 | |
|---|
| 9499 | %% test de beta (ex-theta) |
|---|
| 9500 | dup 90 eq { |
|---|
| 9501 | /beta exch def |
|---|
| 9502 | /idebut 1 def |
|---|
| 9503 | } { |
|---|
| 9504 | /beta exch 80 min -80 max def |
|---|
| 9505 | /idebut 0 def |
|---|
| 9506 | } ifelse |
|---|
| 9507 | %% test de alpha (ex-phi) |
|---|
| 9508 | dup -90 eq { |
|---|
| 9509 | /alpha exch def |
|---|
| 9510 | } { |
|---|
| 9511 | /alpha exch beta min -80 max def |
|---|
| 9512 | } ifelse |
|---|
| 9513 | /r exch def |
|---|
| 9514 | beta 90 eq { |
|---|
| 9515 | alpha -90 eq { |
|---|
| 9516 | /ifin K def |
|---|
| 9517 | /db alpha beta sub K 1 add div def |
|---|
| 9518 | } { |
|---|
| 9519 | /ifin K def |
|---|
| 9520 | /db alpha beta sub K div def |
|---|
| 9521 | } ifelse |
|---|
| 9522 | } { |
|---|
| 9523 | alpha -90 eq { |
|---|
| 9524 | /ifin K 1 sub def |
|---|
| 9525 | /db alpha beta sub K div def |
|---|
| 9526 | } { |
|---|
| 9527 | /ifin K 1 sub def |
|---|
| 9528 | /db alpha beta sub K 1 sub div def |
|---|
| 9529 | } ifelse |
|---|
| 9530 | } ifelse |
|---|
| 9531 | |
|---|
| 9532 | %% nombre de sommets -2 |
|---|
| 9533 | /nb N K mul def |
|---|
| 9534 | |
|---|
| 9535 | %% tableau des sommets |
|---|
| 9536 | /S [ |
|---|
| 9537 | idebut 1 ifin { |
|---|
| 9538 | /j exch def |
|---|
| 9539 | /phi beta j db mul add def |
|---|
| 9540 | phi cos r mul /r_tmp exch def |
|---|
| 9541 | 0 1 N 1 sub { |
|---|
| 9542 | /i exch def |
|---|
| 9543 | 360 N idiv i mul cos r_tmp mul |
|---|
| 9544 | 360 N idiv i mul sin r_tmp mul |
|---|
| 9545 | phi sin r mul |
|---|
| 9546 | } for |
|---|
| 9547 | } for |
|---|
| 9548 | 0 0 r neg |
|---|
| 9549 | 0 0 r |
|---|
| 9550 | ] def |
|---|
| 9551 | |
|---|
| 9552 | /F [ |
|---|
| 9553 | %% calotte inferieure |
|---|
| 9554 | alpha -90 eq { |
|---|
| 9555 | 1 1 N 1 sub { |
|---|
| 9556 | /i exch def |
|---|
| 9557 | [ |
|---|
| 9558 | nb |
|---|
| 9559 | nb i sub |
|---|
| 9560 | nb i 1 add sub |
|---|
| 9561 | ] |
|---|
| 9562 | } for |
|---|
| 9563 | [nb nb N sub nb 1 sub] |
|---|
| 9564 | } { |
|---|
| 9565 | % [nb 1 sub -1 nb N sub {} for ] |
|---|
| 9566 | } ifelse |
|---|
| 9567 | |
|---|
| 9568 | %% calotte superieure |
|---|
| 9569 | beta 90 eq { |
|---|
| 9570 | 0 1 N 1 sub { |
|---|
| 9571 | /i exch def |
|---|
| 9572 | [i i 1 add N mod N K mul 1 add] |
|---|
| 9573 | } for |
|---|
| 9574 | } { |
|---|
| 9575 | % [0 1 N 1 sub {} for] |
|---|
| 9576 | } ifelse |
|---|
| 9577 | |
|---|
| 9578 | 1 1 K 1 sub { |
|---|
| 9579 | /j exch def |
|---|
| 9580 | [ |
|---|
| 9581 | j N mul |
|---|
| 9582 | j N mul 1 add |
|---|
| 9583 | j 1 sub N mul 1 add |
|---|
| 9584 | j 1 sub N mul |
|---|
| 9585 | ] |
|---|
| 9586 | N 2 sub {dup {1 add} apply} repeat |
|---|
| 9587 | [ |
|---|
| 9588 | j 1 add N mul 1 sub |
|---|
| 9589 | j N mul |
|---|
| 9590 | j 1 sub N mul |
|---|
| 9591 | j N mul 1 sub |
|---|
| 9592 | ] |
|---|
| 9593 | } for |
|---|
| 9594 | ] def |
|---|
| 9595 | |
|---|
| 9596 | S F generesolid |
|---|
| 9597 | dup videsolid |
|---|
| 9598 | end |
|---|
| 9599 | } def |
|---|
| 9600 | |
|---|
| 9601 | %%%%% ### newanneau ### |
|---|
| 9602 | %% syntaxe : array n newanneau --> solid |
|---|
| 9603 | %% syntaxe : array {mode} newanneau --> solid |
|---|
| 9604 | %% ou array est un tableau de points de R^2 et n un nombre entier positif |
|---|
| 9605 | /newanneau { |
|---|
| 9606 | 10 dict begin |
|---|
| 9607 | dup isnum { |
|---|
| 9608 | /n exch def |
|---|
| 9609 | [n] |
|---|
| 9610 | } if |
|---|
| 9611 | [[/n2] [6] [12] [24] [32] [36]] gestionsolidmode |
|---|
| 9612 | /n2 n2 3 max store |
|---|
| 9613 | %% on plonge la section dans R^3 par projection sur yOz |
|---|
| 9614 | /S1 exch {0 3 1 roll} papply def |
|---|
| 9615 | %% nombre de sommets |
|---|
| 9616 | /n1 S1 length 3 idiv def |
|---|
| 9617 | |
|---|
| 9618 | /S S1 |
|---|
| 9619 | n2 { |
|---|
| 9620 | duparray |
|---|
| 9621 | {0 0 360 n2 div rotateOpoint3d} papply3d |
|---|
| 9622 | } repeat |
|---|
| 9623 | n2 {append} repeat |
|---|
| 9624 | def |
|---|
| 9625 | |
|---|
| 9626 | /F [ |
|---|
| 9627 | 0 1 n2 1 sub { |
|---|
| 9628 | /j exch def |
|---|
| 9629 | n1 j mul 1 j 1 add n1 mul 2 sub { |
|---|
| 9630 | /i exch def |
|---|
| 9631 | [i 1 add i dup n1 add i n1 1 add add] |
|---|
| 9632 | } for |
|---|
| 9633 | [n1 j mul j 1 add n1 mul 1 sub j 2 add n1 mul 1 sub j 1 add n1 mul] |
|---|
| 9634 | } for |
|---|
| 9635 | ] def |
|---|
| 9636 | |
|---|
| 9637 | S F generesolid |
|---|
| 9638 | end |
|---|
| 9639 | } def |
|---|
| 9640 | |
|---|
| 9641 | %%%%% ### newvecteur ### |
|---|
| 9642 | %% syntaxe : x y z newvecteur |
|---|
| 9643 | %% syntaxe : x y z array newvecteur |
|---|
| 9644 | /newvecteur { |
|---|
| 9645 | 4 dict begin |
|---|
| 9646 | dup isarray { |
|---|
| 9647 | /table exch def |
|---|
| 9648 | /h@uteur table 1 get def |
|---|
| 9649 | /r@y@n table 0 get def |
|---|
| 9650 | } { |
|---|
| 9651 | /h@uteur .3 def |
|---|
| 9652 | /r@y@n .1 def |
|---|
| 9653 | } ifelse |
|---|
| 9654 | /A defpoint3d |
|---|
| 9655 | %%Sommets |
|---|
| 9656 | /S [0 0 0 A] def |
|---|
| 9657 | /F [ |
|---|
| 9658 | [0 1] |
|---|
| 9659 | ] def |
|---|
| 9660 | S F generesolid |
|---|
| 9661 | [ A ] |
|---|
| 9662 | normalvect_to_orthobase |
|---|
| 9663 | /imK defpoint3d |
|---|
| 9664 | /imJ defpoint3d |
|---|
| 9665 | /imI defpoint3d |
|---|
| 9666 | |
|---|
| 9667 | A norme3d /z exch h@uteur sub def |
|---|
| 9668 | 0 r@y@n h@uteur [1 8] newcone |
|---|
| 9669 | dup (noir) outputcolors |
|---|
| 9670 | {0 0 z translatepoint3d} solidtransform |
|---|
| 9671 | {imI imJ imK transformpoint3d} solidtransform |
|---|
| 9672 | solidfuz |
|---|
| 9673 | end |
|---|
| 9674 | } def |
|---|
| 9675 | |
|---|
| 9676 | %%%%% ### readsolidfile ### |
|---|
| 9677 | %% syntaxe : str readsolidfile -> solid |
|---|
| 9678 | /readsolidfile { |
|---|
| 9679 | 1 dict begin |
|---|
| 9680 | /str exch def |
|---|
| 9681 | [str (-sommets.dat) append run] |
|---|
| 9682 | [str (-faces.dat) append run] |
|---|
| 9683 | generesolid |
|---|
| 9684 | dup [str (-couleurs.dat) append run] solidputfcolors |
|---|
| 9685 | dup [str (-io.dat) append run] solidputinouttable |
|---|
| 9686 | end |
|---|
| 9687 | } def |
|---|
| 9688 | |
|---|
| 9689 | %%%%% ### writesolidfile ### |
|---|
| 9690 | %% syntaxe : solid str writesolidfile -> - |
|---|
| 9691 | /writesolidfile { |
|---|
| 9692 | 10 dict begin |
|---|
| 9693 | /str exch def |
|---|
| 9694 | /solid exch def |
|---|
| 9695 | solid issolid not { |
|---|
| 9696 | (Error : mauvais type d argument dans writesolidfile) == |
|---|
| 9697 | quit |
|---|
| 9698 | } if |
|---|
| 9699 | str (-sommets.dat) append (w) file /lefichiersommets exch def |
|---|
| 9700 | str (-faces.dat) append (w) file /lefichierfaces exch def |
|---|
| 9701 | str (-couleurs.dat) append (w) file /lefichiercouleurs exch def |
|---|
| 9702 | str (-io.dat) append (w) file /lefichierio exch def |
|---|
| 9703 | |
|---|
| 9704 | /S solid solidgetsommets def |
|---|
| 9705 | 0 1 S length 3 idiv 1 sub { |
|---|
| 9706 | /i exch def |
|---|
| 9707 | solid i solidgetsommet |
|---|
| 9708 | /z exch def |
|---|
| 9709 | /y exch def |
|---|
| 9710 | /x exch def |
|---|
| 9711 | lefichiersommets x chaine cvs writestring |
|---|
| 9712 | lefichiersommets 32 write %% espace |
|---|
| 9713 | lefichiersommets y chaine cvs writestring |
|---|
| 9714 | lefichiersommets 32 write %% espace |
|---|
| 9715 | lefichiersommets z chaine cvs writestring |
|---|
| 9716 | lefichiersommets 10 write %% CR |
|---|
| 9717 | } for |
|---|
| 9718 | lefichiersommets closefile |
|---|
| 9719 | |
|---|
| 9720 | /F solid solidgetfaces def |
|---|
| 9721 | 0 1 F length 1 sub { |
|---|
| 9722 | /i exch def |
|---|
| 9723 | /Fi solid i solidgetface def |
|---|
| 9724 | lefichierfaces 91 write %% [ |
|---|
| 9725 | 0 1 Fi length 1 sub { |
|---|
| 9726 | /j exch def |
|---|
| 9727 | lefichierfaces Fi j get chaine cvs writestring |
|---|
| 9728 | lefichierfaces 32 write %% espace |
|---|
| 9729 | } for |
|---|
| 9730 | lefichierfaces 93 write %% ] |
|---|
| 9731 | lefichierfaces 10 write %% CR |
|---|
| 9732 | } for |
|---|
| 9733 | lefichierfaces closefile |
|---|
| 9734 | |
|---|
| 9735 | /C solid solidgetfcolors def |
|---|
| 9736 | 0 1 C length 1 sub { |
|---|
| 9737 | /i exch def |
|---|
| 9738 | lefichiercouleurs 40 write %% ( |
|---|
| 9739 | lefichiercouleurs C i get writestring |
|---|
| 9740 | lefichiercouleurs 41 write %% ) |
|---|
| 9741 | lefichiercouleurs 10 write %% CR |
|---|
| 9742 | } for |
|---|
| 9743 | lefichiercouleurs closefile |
|---|
| 9744 | |
|---|
| 9745 | /IO solid solidgetinouttable def |
|---|
| 9746 | 0 1 3 { |
|---|
| 9747 | /i exch def |
|---|
| 9748 | lefichierio IO i get chaine cvs writestring |
|---|
| 9749 | lefichierio 32 write %% space |
|---|
| 9750 | } for |
|---|
| 9751 | lefichierio closefile |
|---|
| 9752 | end |
|---|
| 9753 | } def |
|---|
| 9754 | |
|---|
| 9755 | %%%%% ### writeobjfile ### |
|---|
| 9756 | %% syntaxe : solid str writeobjfile -> - |
|---|
| 9757 | /writeobjfile { |
|---|
| 9758 | 10 dict begin |
|---|
| 9759 | /str exch (.obj) append def |
|---|
| 9760 | /solid exch def |
|---|
| 9761 | solid issolid not { |
|---|
| 9762 | (Erreur : mauvais type d argument dans writeobjfile) == |
|---|
| 9763 | quit |
|---|
| 9764 | } if |
|---|
| 9765 | /n solid solidnombresommets def |
|---|
| 9766 | str (w) file /lefichier exch def |
|---|
| 9767 | 0 1 n 1 sub { |
|---|
| 9768 | /i exch def |
|---|
| 9769 | solid i solidgetsommet |
|---|
| 9770 | /z exch def |
|---|
| 9771 | /y exch def |
|---|
| 9772 | /x exch def |
|---|
| 9773 | lefichier (v ) writestring |
|---|
| 9774 | lefichier x chaine cvs writestring |
|---|
| 9775 | lefichier 32 write %% espace |
|---|
| 9776 | lefichier y chaine cvs writestring |
|---|
| 9777 | lefichier 32 write %% espace |
|---|
| 9778 | lefichier z chaine cvs writestring |
|---|
| 9779 | lefichier 10 write %% CR |
|---|
| 9780 | } for |
|---|
| 9781 | /n solid solidnombrefaces def |
|---|
| 9782 | 0 1 n 1 sub { |
|---|
| 9783 | /i exch def |
|---|
| 9784 | lefichier (f ) writestring |
|---|
| 9785 | /F solid i solidgetface {1 add} apply def |
|---|
| 9786 | F { |
|---|
| 9787 | lefichier exch |
|---|
| 9788 | chaine cvs writestring |
|---|
| 9789 | lefichier 32 write %% espace |
|---|
| 9790 | } apply |
|---|
| 9791 | lefichier 10 write %% CR |
|---|
| 9792 | } for |
|---|
| 9793 | lefichier closefile |
|---|
| 9794 | end |
|---|
| 9795 | } def |
|---|
| 9796 | |
|---|
| 9797 | %%%%% ### writeofffile ### |
|---|
| 9798 | %% syntaxe : solid str writeobjfile -> - |
|---|
| 9799 | /writeofffile { |
|---|
| 9800 | 12 dict begin |
|---|
| 9801 | /str exch (.off) append def |
|---|
| 9802 | /solid exch def |
|---|
| 9803 | solid issolid not { |
|---|
| 9804 | (Erreur : mauvais type d argument dans writeofffile) == |
|---|
| 9805 | quit |
|---|
| 9806 | } if |
|---|
| 9807 | /n solid solidnombresommets def |
|---|
| 9808 | /nf solid solidnombrefaces def |
|---|
| 9809 | str (w) file /lefichier exch def |
|---|
| 9810 | lefichier (OFF) writestring |
|---|
| 9811 | lefichier 10 write %% CR |
|---|
| 9812 | lefichier n chaine cvs writestring |
|---|
| 9813 | lefichier 32 write %% espace |
|---|
| 9814 | lefichier nf chaine cvs writestring |
|---|
| 9815 | lefichier 32 write %% espace |
|---|
| 9816 | lefichier 0 chaine cvs writestring |
|---|
| 9817 | lefichier 10 write %% CR |
|---|
| 9818 | 0 1 n 1 sub { |
|---|
| 9819 | /i exch def |
|---|
| 9820 | solid i solidgetsommet |
|---|
| 9821 | /z exch def |
|---|
| 9822 | /y exch def |
|---|
| 9823 | /x exch def |
|---|
| 9824 | lefichier x chaine cvs writestring |
|---|
| 9825 | lefichier 32 write %% espace |
|---|
| 9826 | lefichier y chaine cvs writestring |
|---|
| 9827 | lefichier 32 write %% espace |
|---|
| 9828 | lefichier z chaine cvs writestring |
|---|
| 9829 | lefichier 10 write %% CR |
|---|
| 9830 | } for |
|---|
| 9831 | 0 1 nf 1 sub { |
|---|
| 9832 | /i exch def |
|---|
| 9833 | /F solid i solidgetface def |
|---|
| 9834 | lefichier F length chaine cvs writestring |
|---|
| 9835 | lefichier 32 write %% espace |
|---|
| 9836 | F { |
|---|
| 9837 | lefichier exch |
|---|
| 9838 | chaine cvs writestring |
|---|
| 9839 | lefichier 32 write %% espace |
|---|
| 9840 | } apply |
|---|
| 9841 | lefichier 10 write %% CR |
|---|
| 9842 | } for |
|---|
| 9843 | lefichier closefile |
|---|
| 9844 | end |
|---|
| 9845 | } def |
|---|
| 9846 | |
|---|
| 9847 | %%%%% ### newobjfile ### |
|---|
| 9848 | /newobjfile { |
|---|
| 9849 | 3 dict begin |
|---|
| 9850 | /objfilename exch (.obj) append def |
|---|
| 9851 | /v {} def |
|---|
| 9852 | /ok true def |
|---|
| 9853 | /f { |
|---|
| 9854 | ok { |
|---|
| 9855 | %% 1ere fois |
|---|
| 9856 | ] %% ferme les sommets |
|---|
| 9857 | [ [ %% ouvre les faces |
|---|
| 9858 | /ok false store |
|---|
| 9859 | } { |
|---|
| 9860 | %% les autres fois |
|---|
| 9861 | ] %% ferme la face |
|---|
| 9862 | [ %% ouvre la nouvelle |
|---|
| 9863 | } ifelse |
|---|
| 9864 | } def |
|---|
| 9865 | [ 0 0 0 %% sommet fantome pour respecter l'indexation (a partir de l'indice 1) |
|---|
| 9866 | objfilename run |
|---|
| 9867 | ]] |
|---|
| 9868 | /F exch def |
|---|
| 9869 | /S exch def |
|---|
| 9870 | |
|---|
| 9871 | S F generesolid |
|---|
| 9872 | % dup videsolid |
|---|
| 9873 | end |
|---|
| 9874 | } def |
|---|
| 9875 | |
|---|
| 9876 | %%%%% ### newofffile ### |
|---|
| 9877 | /newofffile { |
|---|
| 9878 | 3 dict begin |
|---|
| 9879 | /str 35 string def |
|---|
| 9880 | /offfilename exch (.off) append def |
|---|
| 9881 | offfilename (r) file |
|---|
| 9882 | /offfile exch def |
|---|
| 9883 | offfile str readline pop pop |
|---|
| 9884 | offfile str readline pop |
|---|
| 9885 | numstr2array |
|---|
| 9886 | dup 0 get /ns exch def |
|---|
| 9887 | 1 get /nf exch def |
|---|
| 9888 | [ns { |
|---|
| 9889 | offfile str readline pop numstr2array aload pop |
|---|
| 9890 | % 3 1 roll |
|---|
| 9891 | } repeat] |
|---|
| 9892 | /S exch def |
|---|
| 9893 | [nf { |
|---|
| 9894 | [ |
|---|
| 9895 | offfile str readline pop numstr2array |
|---|
| 9896 | /table exch def |
|---|
| 9897 | 1 1 table length 1 sub { |
|---|
| 9898 | /i exch def |
|---|
| 9899 | table i get |
|---|
| 9900 | } for |
|---|
| 9901 | ] |
|---|
| 9902 | } repeat] |
|---|
| 9903 | /F exch def |
|---|
| 9904 | |
|---|
| 9905 | S F generesolid |
|---|
| 9906 | % dup videsolid |
|---|
| 9907 | end |
|---|
| 9908 | } def |
|---|
| 9909 | |
|---|
| 9910 | %%%%% ### newtube ### |
|---|
| 9911 | /tub@dernierk1 [1 0 0] def |
|---|
| 9912 | /tub@dernierk2 [0 1 0] def |
|---|
| 9913 | /tub@dernierk3 [0 0 1] def |
|---|
| 9914 | |
|---|
| 9915 | /inittube { |
|---|
| 9916 | 2 dict begin |
|---|
| 9917 | normalize3d /vect3 defpoint3d |
|---|
| 9918 | normalize3d /vect2 defpoint3d |
|---|
| 9919 | normalize3d /vect1 defpoint3d |
|---|
| 9920 | vect1 norme3d 0 eq { |
|---|
| 9921 | vect2 vect3 vectprod3d /vect1 defpoint3d |
|---|
| 9922 | } if |
|---|
| 9923 | vect2 norme3d 0 eq { |
|---|
| 9924 | vect3 vect1 vectprod3d /vect2 defpoint3d |
|---|
| 9925 | } if |
|---|
| 9926 | vect3 norme3d 0 eq { |
|---|
| 9927 | vect1 vect2 vectprod3d /vect3 defpoint3d |
|---|
| 9928 | } if |
|---|
| 9929 | /tub@dernierk1 [vect1] store |
|---|
| 9930 | /tub@dernierk2 [vect2] store |
|---|
| 9931 | /tub@dernierk3 [vect3] store |
|---|
| 9932 | end |
|---|
| 9933 | } def |
|---|
| 9934 | |
|---|
| 9935 | %% syntaxe : tmin tmax (f) array r newtube -> solid |
|---|
| 9936 | %% array = [K N] |
|---|
| 9937 | /newtube { |
|---|
| 9938 | 10 dict begin |
|---|
| 9939 | /table exch def |
|---|
| 9940 | /K table 0 get def %% nb d etages |
|---|
| 9941 | /N table 1 get def %% nb de points sur le perimetre |
|---|
| 9942 | /@r exch def %% le rayon du tube |
|---|
| 9943 | /str exch def |
|---|
| 9944 | /lafonction str cvx def |
|---|
| 9945 | /laderivee str (') append cvx def |
|---|
| 9946 | %% /laderivee2nd str ('') append cvx def |
|---|
| 9947 | /tmax exch def |
|---|
| 9948 | /tmin exch def |
|---|
| 9949 | /pas tmax tmin sub K 1 sub div def |
|---|
| 9950 | |
|---|
| 9951 | %% definition des sommets |
|---|
| 9952 | [ |
|---|
| 9953 | /@k 0 def |
|---|
| 9954 | K { |
|---|
| 9955 | /a0 tmin @k pas mul add def |
|---|
| 9956 | |
|---|
| 9957 | %% definition du repere de Frenet (k1, k2, k3) au point f(a) |
|---|
| 9958 | a0 lafonction /M defpoint3d |
|---|
| 9959 | |
|---|
| 9960 | str (') append cvlit where { |
|---|
| 9961 | pop |
|---|
| 9962 | a0 laderivee normalize3d /k1 defpoint3d |
|---|
| 9963 | % pop /avecderiv true def |
|---|
| 9964 | } { |
|---|
| 9965 | M a0 pas 100 div add lafonction vecteur3d normalize3d /k1 defpoint3d |
|---|
| 9966 | % /avecderiv false |
|---|
| 9967 | } ifelse |
|---|
| 9968 | |
|---|
| 9969 | k1 baseplannormal /K3 defpoint3d /K2 defpoint3d |
|---|
| 9970 | % a0 laderivee2nd normalize3d /k2 defpoint3d |
|---|
| 9971 | |
|---|
| 9972 | %% projete orthogonal du dernier rayon sur le plan actuel |
|---|
| 9973 | %% (normal a la vitesse) |
|---|
| 9974 | K2 tub@dernierk2 aload pop K2 scalprod3d mulv3d |
|---|
| 9975 | K3 tub@dernierk2 aload pop K3 scalprod3d mulv3d addv3d /k2 defpoint3d |
|---|
| 9976 | % M k1 K2 K3 dessinebase |
|---|
| 9977 | k1 norme3d 0 eq { |
|---|
| 9978 | tub@dernierk1 aload pop /k1 defpoint3d |
|---|
| 9979 | } { |
|---|
| 9980 | /tub@dernierk1 [k1] store |
|---|
| 9981 | } ifelse |
|---|
| 9982 | k2 norme3d 0 eq { |
|---|
| 9983 | tub@dernierk2 aload pop /k2 defpoint3d |
|---|
| 9984 | } { |
|---|
| 9985 | /tub@dernierk2 [k2] store |
|---|
| 9986 | } ifelse |
|---|
| 9987 | k1 k2 vectprod3d normalize3d /k3 defpoint3d |
|---|
| 9988 | k3 norme3d 0 eq { |
|---|
| 9989 | tub@dernierk3 aload pop /k3 defpoint3d |
|---|
| 9990 | } { |
|---|
| 9991 | /tub@dernierk3 [k3] store |
|---|
| 9992 | } ifelse |
|---|
| 9993 | k3 k1 vectprod3d normalize3d /k2 defpoint3d |
|---|
| 9994 | %% M k1 k2 k3 dessinebase |
|---|
| 9995 | /tub@dernierk2 [k2] store |
|---|
| 9996 | /@n 360 N div def %% le pas angulaire |
|---|
| 9997 | 0 @n 360 @n sub { |
|---|
| 9998 | /@i exch def |
|---|
| 9999 | M |
|---|
| 10000 | k2 @i cos @r mul mulv3d addv3d |
|---|
| 10001 | k3 @i sin @r mul mulv3d addv3d |
|---|
| 10002 | } for |
|---|
| 10003 | /@k @k 1 add store |
|---|
| 10004 | } repeat |
|---|
| 10005 | ] |
|---|
| 10006 | |
|---|
| 10007 | dup length 3 idiv /nb exch def |
|---|
| 10008 | %% definition des faces |
|---|
| 10009 | [ |
|---|
| 10010 | %% face de depart |
|---|
| 10011 | [N 1 sub -1 0 {} for] |
|---|
| 10012 | %% face d arrivee |
|---|
| 10013 | [nb 1 sub N 1 sub {dup 1 sub} repeat] reverse |
|---|
| 10014 | |
|---|
| 10015 | %% les etages |
|---|
| 10016 | /j 0 def |
|---|
| 10017 | K 1 sub { |
|---|
| 10018 | 0 1 N 1 sub { |
|---|
| 10019 | /i exch def |
|---|
| 10020 | [ |
|---|
| 10021 | i N j mul add |
|---|
| 10022 | i 1 add N mod N j mul add |
|---|
| 10023 | i 1 add N mod N add N j mul add |
|---|
| 10024 | i N add N j mul add |
|---|
| 10025 | ] |
|---|
| 10026 | } for |
|---|
| 10027 | /j j 1 add store |
|---|
| 10028 | } repeat |
|---|
| 10029 | ] |
|---|
| 10030 | generesolid |
|---|
| 10031 | end |
|---|
| 10032 | } def |
|---|
| 10033 | |
|---|
| 10034 | %%%%% ### newcourbe ### |
|---|
| 10035 | %% syntaxe : a b {f} array newcourbe --> solid |
|---|
| 10036 | /newcourbe { |
|---|
| 10037 | 10 dict begin |
|---|
| 10038 | dup xcheck not { |
|---|
| 10039 | 0 get /n exch def |
|---|
| 10040 | } { |
|---|
| 10041 | /n 80 def |
|---|
| 10042 | } ifelse |
|---|
| 10043 | /l@f@nct exch def |
|---|
| 10044 | /b exch def |
|---|
| 10045 | /a exch def |
|---|
| 10046 | /pas b a sub n 1 sub div def |
|---|
| 10047 | /S [ |
|---|
| 10048 | 0 1 n 1 sub { |
|---|
| 10049 | /@i exch def |
|---|
| 10050 | a @i pas mul add |
|---|
| 10051 | l@f@nct |
|---|
| 10052 | pstrickactionR3 |
|---|
| 10053 | } for |
|---|
| 10054 | ] def |
|---|
| 10055 | /@F [ |
|---|
| 10056 | 0 1 n 2 sub { |
|---|
| 10057 | /@i exch def |
|---|
| 10058 | [@i @i 1 add] |
|---|
| 10059 | } for |
|---|
| 10060 | ] def |
|---|
| 10061 | S @F generesolid |
|---|
| 10062 | end |
|---|
| 10063 | } def |
|---|
| 10064 | |
|---|
| 10065 | %%%%% ### baseplannormal ### |
|---|
| 10066 | %% syntaxe : x y z baseplannormal -> x1 y1 z1 x2 y2 z2 |
|---|
| 10067 | /baseplannormal { |
|---|
| 10068 | 5 dict begin |
|---|
| 10069 | /K defpoint3d |
|---|
| 10070 | 1 0 0 K vectprod3d normalize3d /U defpoint3d |
|---|
| 10071 | U norme3d 0 eq { |
|---|
| 10072 | 0 1 0 K vectprod3d normalize3d /U defpoint3d |
|---|
| 10073 | } if |
|---|
| 10074 | K U vectprod3d normalize3d /V defpoint3d |
|---|
| 10075 | U V |
|---|
| 10076 | end |
|---|
| 10077 | } def |
|---|
| 10078 | |
|---|
| 10079 | %%%%% ### fin insertion ### |
|---|
| 10080 | |
|---|
| 10081 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10082 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10083 | %%%% %%%% |
|---|
| 10084 | %%%% fin insertion librairie jps %%%% |
|---|
| 10085 | %%%% %%%% |
|---|
| 10086 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10087 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10088 | |
|---|
| 10089 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10090 | %%%% gestion de chaine de caracteres %%%% |
|---|
| 10091 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10092 | |
|---|
| 10093 | /Times-Roman findfont |
|---|
| 10094 | dup length dict begin |
|---|
| 10095 | { |
|---|
| 10096 | 1 index /FID ne |
|---|
| 10097 | {def} |
|---|
| 10098 | {pop pop} |
|---|
| 10099 | ifelse |
|---|
| 10100 | } forall |
|---|
| 10101 | /Encoding ISOLatin1Encoding def |
|---|
| 10102 | currentdict |
|---|
| 10103 | end |
|---|
| 10104 | /Times-Roman-ISOLatin1 exch definefont pop |
|---|
| 10105 | |
|---|
| 10106 | /setTimesRoman { |
|---|
| 10107 | /Times-Roman-ISOLatin1 findfont |
|---|
| 10108 | fontsize scalefont |
|---|
| 10109 | setfont |
|---|
| 10110 | } def |
|---|
| 10111 | |
|---|
| 10112 | /setTimes { |
|---|
| 10113 | setTimesRoman |
|---|
| 10114 | } def |
|---|
| 10115 | |
|---|
| 10116 | %% syntaxe : string x y cctext |
|---|
| 10117 | /cctext { |
|---|
| 10118 | 5 dict begin |
|---|
| 10119 | /y exch def |
|---|
| 10120 | /x exch def |
|---|
| 10121 | /str exch def |
|---|
| 10122 | str stringwidth |
|---|
| 10123 | /wy exch def |
|---|
| 10124 | /wx exch def |
|---|
| 10125 | gsave |
|---|
| 10126 | x y smoveto |
|---|
| 10127 | wx -2 div wy -2 div rmoveto |
|---|
| 10128 | str show |
|---|
| 10129 | grestore |
|---|
| 10130 | end |
|---|
| 10131 | } def |
|---|
| 10132 | |
|---|
| 10133 | /dbtext {gsave newpath dbtext_ Fill grestore} def |
|---|
| 10134 | /dctext {gsave newpath dctext_ Fill grestore} def |
|---|
| 10135 | /dltext {gsave newpath dltext_ Fill grestore} def |
|---|
| 10136 | /drtext {gsave newpath drtext_ Fill grestore} def |
|---|
| 10137 | |
|---|
| 10138 | /bbtext {gsave newpath bbtext_ Fill grestore} def |
|---|
| 10139 | /bctext {gsave newpath bctext_ Fill grestore} def |
|---|
| 10140 | /bltext {gsave newpath bltext_ Fill grestore} def |
|---|
| 10141 | /brtext {gsave newpath brtext_ Fill grestore} def |
|---|
| 10142 | |
|---|
| 10143 | /cbtext {gsave newpath cbtext_ Fill grestore} def |
|---|
| 10144 | /cctext {gsave newpath cctext_ Fill grestore} def |
|---|
| 10145 | /cltext {gsave newpath cltext_ Fill grestore} def |
|---|
| 10146 | /crtext {gsave newpath crtext_ Fill grestore} def |
|---|
| 10147 | |
|---|
| 10148 | /ubtext {gsave newpath ubtext_ Fill grestore} def |
|---|
| 10149 | /uctext {gsave newpath uctext_ Fill grestore} def |
|---|
| 10150 | /ultext {gsave newpath ultext_ Fill grestore} def |
|---|
| 10151 | /urtext {gsave newpath urtext_ Fill grestore} def |
|---|
| 10152 | |
|---|
| 10153 | |
|---|
| 10154 | %% syntaxe : str x y show_dim --> str x y llx lly wx wy |
|---|
| 10155 | %% attention, doit laisser la pile intacte |
|---|
| 10156 | /show_dim { |
|---|
| 10157 | 3 copy pop pop |
|---|
| 10158 | newpath |
|---|
| 10159 | 0 0 moveto |
|---|
| 10160 | true charpath flattenpath pathbbox |
|---|
| 10161 | closepath |
|---|
| 10162 | newpath |
|---|
| 10163 | } def |
|---|
| 10164 | |
|---|
| 10165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10166 | %%%% procedures pour PSTricks %%%% |
|---|
| 10167 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10168 | |
|---|
| 10169 | %%% les 3 procedures utilisees pour transformer les depots de AlgToPs en nombres |
|---|
| 10170 | /pstrickactionR3 { |
|---|
| 10171 | 3 dict begin |
|---|
| 10172 | /len@3 exch def |
|---|
| 10173 | /len@2 exch def |
|---|
| 10174 | /len@1 exch def |
|---|
| 10175 | len@1 exec |
|---|
| 10176 | len@2 exec |
|---|
| 10177 | len@3 exec |
|---|
| 10178 | end |
|---|
| 10179 | } def |
|---|
| 10180 | |
|---|
| 10181 | /pstrickactionR2 { |
|---|
| 10182 | exec exch exec exch |
|---|
| 10183 | } def |
|---|
| 10184 | |
|---|
| 10185 | /pstrickactionR { |
|---|
| 10186 | exec |
|---|
| 10187 | } def |
|---|
| 10188 | |
|---|
| 10189 | /gere_pst-deffunction { |
|---|
| 10190 | counttomark |
|---|
| 10191 | dup 1 eq { |
|---|
| 10192 | pop |
|---|
| 10193 | pstrickactionR |
|---|
| 10194 | ] aload pop |
|---|
| 10195 | } { |
|---|
| 10196 | 2 eq { |
|---|
| 10197 | pstrickactionR2 |
|---|
| 10198 | ] aload pop |
|---|
| 10199 | } { |
|---|
| 10200 | pstrickactionR3 |
|---|
| 10201 | ] aload pop |
|---|
| 10202 | } ifelse |
|---|
| 10203 | } ifelse |
|---|
| 10204 | } def |
|---|
| 10205 | |
|---|
| 10206 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10207 | %%%% procedures pour \psSolid %%%% |
|---|
| 10208 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 10209 | |
|---|
| 10210 | /all (all) def |
|---|
| 10211 | |
|---|
| 10212 | /draw {drawsolid} def |
|---|
| 10213 | /draw* {drawsolid*} def |
|---|
| 10214 | /draw** {drawsolid**} def |
|---|
| 10215 | /writeobj {solidfilename writeobjfile} def |
|---|
| 10216 | /writesolid {solidfilename writesolidfile} def |
|---|
| 10217 | /writeoff {solidfilename writeofffile} def |
|---|
| 10218 | /none {pop} def |
|---|
| 10219 | /vecteur_en_c@urs false def |
|---|
| 10220 | |
|---|
| 10221 | /gere_pstricks_color_inout { |
|---|
| 10222 | gsave |
|---|
| 10223 | dup [fillincolor] (setrgbcolor) astr2str |
|---|
| 10224 | [fillcolor] (setrgbcolor) astr2str inoutputcolors |
|---|
| 10225 | grestore |
|---|
| 10226 | } def |
|---|
| 10227 | |
|---|
| 10228 | /gere_pstricks_color_out { |
|---|
| 10229 | gsave |
|---|
| 10230 | dup [fillcolor] (setrgbcolor) astr2str outputcolors |
|---|
| 10231 | grestore |
|---|
| 10232 | } def |
|---|
| 10233 | |
|---|
| 10234 | /gere_pstfont { |
|---|
| 10235 | fontsize mul setfontsize |
|---|
| 10236 | %setTimes |
|---|
| 10237 | PSfont dup /Symbol ne isolatin and { |
|---|
| 10238 | /ISO-Font ReEncode /ISO-Font |
|---|
| 10239 | } if |
|---|
| 10240 | findfont fontsize scalefont setfont |
|---|
| 10241 | } def |
|---|
| 10242 | |
|---|
| 10243 | /gere_pstricks_opt { |
|---|
| 10244 | % /CourbeR2 {CourbeR2+} def |
|---|
| 10245 | 1 gere_pstfont |
|---|
| 10246 | linecolor |
|---|
| 10247 | linestyle |
|---|
| 10248 | solidlinewidth setlinewidth |
|---|
| 10249 | solidtrunc length 0 ne { |
|---|
| 10250 | solidtrunc 0 get isstring { |
|---|
| 10251 | dup trunccoeff solidtronque |
|---|
| 10252 | } { |
|---|
| 10253 | dup solidtrunc trunccoeff solidtronque |
|---|
| 10254 | } ifelse |
|---|
| 10255 | } if |
|---|
| 10256 | solidgeode { |
|---|
| 10257 | 1 newgeode |
|---|
| 10258 | } if |
|---|
| 10259 | soliddualreg { |
|---|
| 10260 | dualpolyedreregulier |
|---|
| 10261 | } if |
|---|
| 10262 | chanfrein { |
|---|
| 10263 | dup chanfreincoeff solidchanfreine |
|---|
| 10264 | } if |
|---|
| 10265 | RotX 0 ne RotY 0 ne or RotZ 0 ne or { |
|---|
| 10266 | {RotX RotY RotZ rotateOpoint3d} solidtransform |
|---|
| 10267 | } if |
|---|
| 10268 | CX 0 ne CY 0 ne or CZ 0 ne or { |
|---|
| 10269 | {CX CY CZ translatepoint3d} solidtransform |
|---|
| 10270 | } if |
|---|
| 10271 | plansection length 0 gt { |
|---|
| 10272 | 0 1 plansection length 1 sub { |
|---|
| 10273 | /i exch def |
|---|
| 10274 | plansection i get solidplansection |
|---|
| 10275 | dup 0 solidrmface |
|---|
| 10276 | } for |
|---|
| 10277 | } if |
|---|
| 10278 | /rmfaces rmfaces bubblesort reverse store |
|---|
| 10279 | 0 1 rmfaces length 1 sub { |
|---|
| 10280 | /i exch def |
|---|
| 10281 | dup rmfaces i get solidrmface |
|---|
| 10282 | } for |
|---|
| 10283 | tx@Dict /pst-transformoption known { |
|---|
| 10284 | dup {pst-transformoption} solidtransform |
|---|
| 10285 | } if |
|---|
| 10286 | solidaffinage length 0 ne { |
|---|
| 10287 | %% si on affine, il faut colorier avant |
|---|
| 10288 | activationgestioncouleurs { |
|---|
| 10289 | gere_pstricks_color_out |
|---|
| 10290 | } if |
|---|
| 10291 | solidaffinage 0 get isstring { |
|---|
| 10292 | dup affinagecoeff |
|---|
| 10293 | /solidfcolor where { |
|---|
| 10294 | pop |
|---|
| 10295 | solidfcolor |
|---|
| 10296 | } if |
|---|
| 10297 | affinagerm solidaffine |
|---|
| 10298 | } { |
|---|
| 10299 | dup affinagecoeff solidaffinage |
|---|
| 10300 | /solidfcolor where { |
|---|
| 10301 | pop |
|---|
| 10302 | solidfcolor |
|---|
| 10303 | } if |
|---|
| 10304 | affinagerm solidaffine |
|---|
| 10305 | } ifelse |
|---|
| 10306 | %% et il faut evider et coloriier l'interieur si necessaire |
|---|
| 10307 | solidhollow { |
|---|
| 10308 | dup videsolid |
|---|
| 10309 | activationgestioncouleurs { |
|---|
| 10310 | gsave |
|---|
| 10311 | dup [fillincolor] (setrgbcolor) astr2str inputcolors |
|---|
| 10312 | grestore |
|---|
| 10313 | } if |
|---|
| 10314 | } if |
|---|
| 10315 | /activationgestioncouleurs false def |
|---|
| 10316 | } if |
|---|
| 10317 | tx@Dict /plansepare known { |
|---|
| 10318 | plansepare solidplansepare |
|---|
| 10319 | tx@Dict /plansepare undef |
|---|
| 10320 | tx@Dict /solidname known { |
|---|
| 10321 | solidname (1) append cvlit exch def |
|---|
| 10322 | dup solidname (0) append cvlit exch def |
|---|
| 10323 | %% |
|---|
| 10324 | solidname (1) append cvx exec |
|---|
| 10325 | solidhollow { |
|---|
| 10326 | dup videsolid |
|---|
| 10327 | } if |
|---|
| 10328 | activationgestioncouleurs { |
|---|
| 10329 | dup solidwithinfaces { |
|---|
| 10330 | gere_pstricks_color_inout |
|---|
| 10331 | } { |
|---|
| 10332 | gere_pstricks_color_out |
|---|
| 10333 | } ifelse |
|---|
| 10334 | } if |
|---|
| 10335 | solidinouthue length 0 gt { |
|---|
| 10336 | dup solidinouthue solidputinouthuecolors |
|---|
| 10337 | } { |
|---|
| 10338 | solidhue length 0 gt { |
|---|
| 10339 | dup solidhue solidputhuecolors |
|---|
| 10340 | } if |
|---|
| 10341 | solidinhue length 0 gt { |
|---|
| 10342 | dup solidinhue solidputinhuecolors |
|---|
| 10343 | } if |
|---|
| 10344 | } ifelse |
|---|
| 10345 | pop |
|---|
| 10346 | tx@Dict /solidname undef |
|---|
| 10347 | } { |
|---|
| 10348 | /solid1 exch def |
|---|
| 10349 | /solid2 exch def |
|---|
| 10350 | } ifelse |
|---|
| 10351 | } if |
|---|
| 10352 | solidhollow { |
|---|
| 10353 | dup videsolid |
|---|
| 10354 | } if |
|---|
| 10355 | activationgestioncouleurs { |
|---|
| 10356 | zcolor length 0 ne { |
|---|
| 10357 | dup zcolor tablez solidcolorz |
|---|
| 10358 | } { |
|---|
| 10359 | dup solidwithinfaces { |
|---|
| 10360 | gere_pstricks_color_inout |
|---|
| 10361 | } { |
|---|
| 10362 | gere_pstricks_color_out |
|---|
| 10363 | } ifelse |
|---|
| 10364 | solidinouthue length 0 gt { |
|---|
| 10365 | dup solidinouthue solidputinouthuecolors |
|---|
| 10366 | } { |
|---|
| 10367 | solidhue length 0 gt { |
|---|
| 10368 | dup solidhue solidputhuecolors |
|---|
| 10369 | } if |
|---|
| 10370 | solidinhue length 0 gt { |
|---|
| 10371 | dup solidinhue solidputinhuecolors |
|---|
| 10372 | } if |
|---|
| 10373 | } ifelse |
|---|
| 10374 | } ifelse |
|---|
| 10375 | } { |
|---|
| 10376 | /activationgestioncouleurs true def |
|---|
| 10377 | } ifelse |
|---|
| 10378 | |
|---|
| 10379 | 0 1 fcol length 2 idiv 1 sub { |
|---|
| 10380 | /i exch def |
|---|
| 10381 | dup fcol 2 i mul get fcol 2 i mul 1 add get solidputfcolor |
|---|
| 10382 | } for |
|---|
| 10383 | vecteur_en_c@urs not { |
|---|
| 10384 | /lightsrc where {pop solidlightOn} if |
|---|
| 10385 | } { |
|---|
| 10386 | /vecteur_en_c@urs false def |
|---|
| 10387 | } ifelse |
|---|
| 10388 | dup action cvx exec |
|---|
| 10389 | noir |
|---|
| 10390 | solidnumf length 0 ne { |
|---|
| 10391 | solidnumf 0 get isstring { |
|---|
| 10392 | dup projectionsifacevisible solidnumfaces |
|---|
| 10393 | } { |
|---|
| 10394 | dup solidnumf projectionsifacevisible solidnumfaces |
|---|
| 10395 | } ifelse |
|---|
| 10396 | } if |
|---|
| 10397 | solidshow length 0 ne { |
|---|
| 10398 | solidshow 0 get isstring { |
|---|
| 10399 | dup solidshowsommets |
|---|
| 10400 | } { |
|---|
| 10401 | dup solidshow solidshowsommets |
|---|
| 10402 | } ifelse |
|---|
| 10403 | } if |
|---|
| 10404 | solidnum length 0 ne { |
|---|
| 10405 | solidnum 0 get isstring { |
|---|
| 10406 | .8 gere_pstfont |
|---|
| 10407 | dup solidnumsommets |
|---|
| 10408 | } { |
|---|
| 10409 | dup solidnum solidnumsommets |
|---|
| 10410 | } ifelse |
|---|
| 10411 | } { |
|---|
| 10412 | %% pop |
|---|
| 10413 | } ifelse |
|---|
| 10414 | tx@Dict /solidname known { |
|---|
| 10415 | solidname cvlit exch bind def |
|---|
| 10416 | tx@Dict /solidname undef |
|---|
| 10417 | } { |
|---|
| 10418 | pop |
|---|
| 10419 | } ifelse |
|---|
| 10420 | } def |
|---|
| 10421 | |
|---|
| 10422 | /pst-octahedron { |
|---|
| 10423 | a newoctaedre |
|---|
| 10424 | gere_pstricks_opt |
|---|
| 10425 | } def |
|---|
| 10426 | |
|---|
| 10427 | /pst-dodecahedron { |
|---|
| 10428 | a newdodecaedre |
|---|
| 10429 | gere_pstricks_opt |
|---|
| 10430 | } def |
|---|
| 10431 | |
|---|
| 10432 | /pst-icosahedron { |
|---|
| 10433 | a newicosaedre |
|---|
| 10434 | gere_pstricks_opt |
|---|
| 10435 | } def |
|---|
| 10436 | |
|---|
| 10437 | /pst-cube { |
|---|
| 10438 | a |
|---|
| 10439 | ngrid length 1 eq { |
|---|
| 10440 | ngrid |
|---|
| 10441 | } { |
|---|
| 10442 | {Mode} |
|---|
| 10443 | } ifelse |
|---|
| 10444 | newcube |
|---|
| 10445 | %% solidhollow { |
|---|
| 10446 | %% dup videsolid |
|---|
| 10447 | %% } if |
|---|
| 10448 | gere_pstricks_opt |
|---|
| 10449 | } def |
|---|
| 10450 | |
|---|
| 10451 | /pst-parallelepiped { |
|---|
| 10452 | a b c |
|---|
| 10453 | newparallelepiped |
|---|
| 10454 | gere_pstricks_opt |
|---|
| 10455 | } def |
|---|
| 10456 | |
|---|
| 10457 | /pst-tetrahedron { |
|---|
| 10458 | r newtetraedre |
|---|
| 10459 | gere_pstricks_opt |
|---|
| 10460 | } def |
|---|
| 10461 | |
|---|
| 10462 | /pst-tore { |
|---|
| 10463 | r0 r1 |
|---|
| 10464 | ngrid length 2 eq { |
|---|
| 10465 | ngrid |
|---|
| 10466 | } { |
|---|
| 10467 | {Mode} |
|---|
| 10468 | } ifelse |
|---|
| 10469 | newtore |
|---|
| 10470 | gere_pstricks_opt |
|---|
| 10471 | } def |
|---|
| 10472 | |
|---|
| 10473 | /pst-sphere { |
|---|
| 10474 | % rayon |
|---|
| 10475 | % mode |
|---|
| 10476 | % r {Mode} newsphere |
|---|
| 10477 | r |
|---|
| 10478 | ngrid length 2 eq { |
|---|
| 10479 | ngrid |
|---|
| 10480 | } { |
|---|
| 10481 | {Mode} |
|---|
| 10482 | } ifelse |
|---|
| 10483 | newsphere |
|---|
| 10484 | gere_pstricks_opt |
|---|
| 10485 | } def |
|---|
| 10486 | % |
|---|
| 10487 | /pst-cylindre { |
|---|
| 10488 | /save-cylinderhollow solidhollow def |
|---|
| 10489 | tx@Dict /function known { |
|---|
| 10490 | range aload pop function cvx {axe} h ngrid newcylindre |
|---|
| 10491 | tx@Dict /function undef |
|---|
| 10492 | /solidhollow true def |
|---|
| 10493 | } { |
|---|
| 10494 | % rayon |
|---|
| 10495 | % mode |
|---|
| 10496 | 0 r h |
|---|
| 10497 | ngrid length 2 eq { |
|---|
| 10498 | ngrid |
|---|
| 10499 | } { |
|---|
| 10500 | {Mode} |
|---|
| 10501 | } ifelse |
|---|
| 10502 | newcylindre |
|---|
| 10503 | solidhollow { |
|---|
| 10504 | dup creusesolid |
|---|
| 10505 | } if |
|---|
| 10506 | } ifelse |
|---|
| 10507 | gere_pstricks_opt |
|---|
| 10508 | /solidhollow save-cylinderhollow store |
|---|
| 10509 | } def |
|---|
| 10510 | % |
|---|
| 10511 | /pst-cylindrecreux { |
|---|
| 10512 | % rayon |
|---|
| 10513 | % mode |
|---|
| 10514 | 0 r h |
|---|
| 10515 | ngrid length 2 eq { |
|---|
| 10516 | ngrid |
|---|
| 10517 | } { |
|---|
| 10518 | {Mode} |
|---|
| 10519 | } ifelse |
|---|
| 10520 | newcylindre |
|---|
| 10521 | dup creusesolid |
|---|
| 10522 | gere_pstricks_opt |
|---|
| 10523 | } def |
|---|
| 10524 | |
|---|
| 10525 | /pst-cone { |
|---|
| 10526 | /save-conehollow solidhollow def |
|---|
| 10527 | tx@Dict /function known { |
|---|
| 10528 | range aload pop function cvx {origin} ngrid newcone |
|---|
| 10529 | tx@Dict /function undef |
|---|
| 10530 | /solidhollow true def |
|---|
| 10531 | } { |
|---|
| 10532 | % rayon |
|---|
| 10533 | % mode |
|---|
| 10534 | 0 r h |
|---|
| 10535 | ngrid length 2 eq { |
|---|
| 10536 | ngrid |
|---|
| 10537 | } { |
|---|
| 10538 | {Mode} |
|---|
| 10539 | } ifelse |
|---|
| 10540 | solidhollow { |
|---|
| 10541 | newconecreux |
|---|
| 10542 | } { |
|---|
| 10543 | newcone |
|---|
| 10544 | } ifelse |
|---|
| 10545 | } ifelse |
|---|
| 10546 | gere_pstricks_opt |
|---|
| 10547 | /solidhollow save-conehollow store |
|---|
| 10548 | } def |
|---|
| 10549 | |
|---|
| 10550 | /pst-tronccone { |
|---|
| 10551 | % rayon |
|---|
| 10552 | % mode |
|---|
| 10553 | 0 r0 h r1 |
|---|
| 10554 | ngrid length 2 eq { |
|---|
| 10555 | ngrid |
|---|
| 10556 | } { |
|---|
| 10557 | {Mode} |
|---|
| 10558 | } ifelse |
|---|
| 10559 | solidhollow { |
|---|
| 10560 | newtroncconecreux |
|---|
| 10561 | } { |
|---|
| 10562 | newtronccone |
|---|
| 10563 | } ifelse |
|---|
| 10564 | gere_pstricks_opt |
|---|
| 10565 | } def |
|---|
| 10566 | |
|---|
| 10567 | /pst-troncconecreux { |
|---|
| 10568 | % rayon |
|---|
| 10569 | % mode |
|---|
| 10570 | 0 r0 h r1 |
|---|
| 10571 | ngrid length 2 eq { |
|---|
| 10572 | ngrid |
|---|
| 10573 | } { |
|---|
| 10574 | {Mode} |
|---|
| 10575 | } ifelse |
|---|
| 10576 | newtroncconecreux |
|---|
| 10577 | gere_pstricks_opt |
|---|
| 10578 | } def |
|---|
| 10579 | |
|---|
| 10580 | /pst-conecreux { |
|---|
| 10581 | % rayon |
|---|
| 10582 | % mode |
|---|
| 10583 | 0 r h |
|---|
| 10584 | ngrid length 2 eq { |
|---|
| 10585 | ngrid |
|---|
| 10586 | } { |
|---|
| 10587 | {Mode} |
|---|
| 10588 | } ifelse |
|---|
| 10589 | newconecreux |
|---|
| 10590 | gere_pstricks_opt |
|---|
| 10591 | } def |
|---|
| 10592 | |
|---|
| 10593 | /pst-anneau { |
|---|
| 10594 | [ section ] |
|---|
| 10595 | ngrid length 1 ge { |
|---|
| 10596 | [ngrid 0 get] |
|---|
| 10597 | } { |
|---|
| 10598 | [24] |
|---|
| 10599 | } ifelse |
|---|
| 10600 | newanneau |
|---|
| 10601 | gere_pstricks_opt |
|---|
| 10602 | } def |
|---|
| 10603 | |
|---|
| 10604 | |
|---|
| 10605 | /pst-prisme { |
|---|
| 10606 | % tableau des points de la base |
|---|
| 10607 | % h hauteur du prisme |
|---|
| 10608 | % axe : vecteur direction de l axe |
|---|
| 10609 | base decal rollparray |
|---|
| 10610 | 0 h axe |
|---|
| 10611 | ngrid length 1 ge { |
|---|
| 10612 | [ngrid 0 get] |
|---|
| 10613 | } if |
|---|
| 10614 | newprisme |
|---|
| 10615 | solidhollow { |
|---|
| 10616 | dup creusesolid |
|---|
| 10617 | } if |
|---|
| 10618 | gere_pstricks_opt |
|---|
| 10619 | } def |
|---|
| 10620 | |
|---|
| 10621 | /pst-prismecreux { |
|---|
| 10622 | % tableau des points de la base |
|---|
| 10623 | % h hauteur du prisme |
|---|
| 10624 | % axe : vecteur direction de l axe |
|---|
| 10625 | base |
|---|
| 10626 | 0 h axe |
|---|
| 10627 | ngrid length 1 ge { |
|---|
| 10628 | [ngrid 0 get] |
|---|
| 10629 | } if |
|---|
| 10630 | newprisme |
|---|
| 10631 | dup creusesolid |
|---|
| 10632 | gere_pstricks_opt |
|---|
| 10633 | } def |
|---|
| 10634 | |
|---|
| 10635 | /pst-grille { |
|---|
| 10636 | base aload pop |
|---|
| 10637 | ngrid length 2 ge { |
|---|
| 10638 | [ngrid 0 get ngrid 1 get] |
|---|
| 10639 | } { |
|---|
| 10640 | ngrid length 1 eq { |
|---|
| 10641 | [ngrid 0 get dup] |
|---|
| 10642 | } if |
|---|
| 10643 | } ifelse |
|---|
| 10644 | newgrille |
|---|
| 10645 | gere_pstricks_opt |
|---|
| 10646 | } def |
|---|
| 10647 | |
|---|
| 10648 | %% syntaxe : array N h u newruban -> solid d axe (O, u), |
|---|
| 10649 | /pst-ruban { |
|---|
| 10650 | % tableau des points de la base |
|---|
| 10651 | % h hauteur du prisme |
|---|
| 10652 | % axe : vecteur direction de l axe |
|---|
| 10653 | base |
|---|
| 10654 | h axe |
|---|
| 10655 | ngrid length 1 ge { |
|---|
| 10656 | [ngrid 0 get] |
|---|
| 10657 | } if |
|---|
| 10658 | newruban |
|---|
| 10659 | gere_pstricks_opt |
|---|
| 10660 | } def |
|---|
| 10661 | |
|---|
| 10662 | %% syntaxe : r phi option newcalottesphere -> solid |
|---|
| 10663 | /pst-calottesphere { |
|---|
| 10664 | % rayon |
|---|
| 10665 | % mode |
|---|
| 10666 | % r phi theta option newcalottesphere |
|---|
| 10667 | r |
|---|
| 10668 | phi theta |
|---|
| 10669 | ngrid length 2 eq { |
|---|
| 10670 | ngrid |
|---|
| 10671 | } { |
|---|
| 10672 | {Mode} |
|---|
| 10673 | } ifelse |
|---|
| 10674 | solidhollow { |
|---|
| 10675 | newcalottespherecreuse |
|---|
| 10676 | } { |
|---|
| 10677 | newcalottesphere |
|---|
| 10678 | } ifelse |
|---|
| 10679 | gere_pstricks_opt |
|---|
| 10680 | } def |
|---|
| 10681 | |
|---|
| 10682 | %% syntaxe : r phi option newcalottesphere -> solid |
|---|
| 10683 | /pst-calottespherecreuse { |
|---|
| 10684 | % rayon |
|---|
| 10685 | % mode |
|---|
| 10686 | % r phi theta option newcalottespherecreuse |
|---|
| 10687 | r |
|---|
| 10688 | phi theta |
|---|
| 10689 | ngrid length 2 eq { |
|---|
| 10690 | ngrid |
|---|
| 10691 | } { |
|---|
| 10692 | {Mode} |
|---|
| 10693 | } ifelse |
|---|
| 10694 | newcalottespherecreuse |
|---|
| 10695 | gere_pstricks_opt |
|---|
| 10696 | } def |
|---|
| 10697 | |
|---|
| 10698 | /pointtest{2 2 2} def |
|---|
| 10699 | |
|---|
| 10700 | /pst-face { |
|---|
| 10701 | % tableau des points de la base |
|---|
| 10702 | % h hauteur du prisme |
|---|
| 10703 | % axe : vecteur direction de l axe |
|---|
| 10704 | base |
|---|
| 10705 | solidbiface { |
|---|
| 10706 | newbiface |
|---|
| 10707 | } { |
|---|
| 10708 | newmonoface |
|---|
| 10709 | } ifelse |
|---|
| 10710 | gere_pstricks_opt |
|---|
| 10711 | } def |
|---|
| 10712 | |
|---|
| 10713 | /pst-Surface { |
|---|
| 10714 | base |
|---|
| 10715 | base aload pop |
|---|
| 10716 | ngrid length 2 ge { |
|---|
| 10717 | [ngrid 0 get ngrid 1 get] |
|---|
| 10718 | } { |
|---|
| 10719 | ngrid length 1 eq { |
|---|
| 10720 | [ngrid 0 get dup] |
|---|
| 10721 | } ifelse |
|---|
| 10722 | } ifelse |
|---|
| 10723 | {f} newsurface |
|---|
| 10724 | solidbiface { |
|---|
| 10725 | dup videsolid |
|---|
| 10726 | } if |
|---|
| 10727 | gere_pstricks_opt |
|---|
| 10728 | } def |
|---|
| 10729 | |
|---|
| 10730 | /pst-surface { |
|---|
| 10731 | base |
|---|
| 10732 | base aload pop |
|---|
| 10733 | ngrid length 2 ge { |
|---|
| 10734 | [ngrid 0 get ngrid 1 get] |
|---|
| 10735 | } { |
|---|
| 10736 | ngrid length 1 eq { |
|---|
| 10737 | [ngrid 0 get dup] |
|---|
| 10738 | } ifelse |
|---|
| 10739 | } ifelse |
|---|
| 10740 | { function cvx exec } newsurface |
|---|
| 10741 | solidbiface { |
|---|
| 10742 | dup videsolid |
|---|
| 10743 | } if |
|---|
| 10744 | gere_pstricks_opt |
|---|
| 10745 | } def |
|---|
| 10746 | |
|---|
| 10747 | /pst-polygoneregulier { |
|---|
| 10748 | r ngrid 0 get |
|---|
| 10749 | newpolreg |
|---|
| 10750 | solidbiface { |
|---|
| 10751 | } { |
|---|
| 10752 | dup 1 solidrmface |
|---|
| 10753 | } ifelse |
|---|
| 10754 | gere_pstricks_opt |
|---|
| 10755 | } def |
|---|
| 10756 | |
|---|
| 10757 | /pst-fusion { |
|---|
| 10758 | 1 dict begin |
|---|
| 10759 | /activationgestioncouleurs false def |
|---|
| 10760 | /n base length def |
|---|
| 10761 | base aload pop n 1 sub {solidfuz} repeat |
|---|
| 10762 | gere_pstricks_opt |
|---|
| 10763 | end |
|---|
| 10764 | } def |
|---|
| 10765 | |
|---|
| 10766 | /pst-new { |
|---|
| 10767 | sommets faces |
|---|
| 10768 | generesolid |
|---|
| 10769 | %% solidhollow { |
|---|
| 10770 | %% dup videsolid |
|---|
| 10771 | %% } if |
|---|
| 10772 | gere_pstricks_opt |
|---|
| 10773 | } def |
|---|
| 10774 | |
|---|
| 10775 | /pst-courbe { |
|---|
| 10776 | solidlinewidth setlinewidth |
|---|
| 10777 | r 0 eq { |
|---|
| 10778 | range aload pop function cvx [resolution] newcourbe |
|---|
| 10779 | gere_pstricks_opt |
|---|
| 10780 | } { |
|---|
| 10781 | range aload pop function r |
|---|
| 10782 | ngrid length 2 lt { |
|---|
| 10783 | [300 4] |
|---|
| 10784 | } { |
|---|
| 10785 | ngrid |
|---|
| 10786 | } ifelse |
|---|
| 10787 | newtube |
|---|
| 10788 | gere_pstricks_opt %% r function [36 12] newtube |
|---|
| 10789 | } ifelse |
|---|
| 10790 | } def |
|---|
| 10791 | % |
|---|
| 10792 | /pst-surfaceparametree { |
|---|
| 10793 | base aload pop |
|---|
| 10794 | ngrid length 2 ge { |
|---|
| 10795 | [ngrid 0 get ngrid 1 get] |
|---|
| 10796 | } { |
|---|
| 10797 | ngrid length 1 eq { |
|---|
| 10798 | [ngrid 0 get dup] |
|---|
| 10799 | } if |
|---|
| 10800 | } ifelse |
|---|
| 10801 | { function cvx exec } newsurfaceparametree |
|---|
| 10802 | dup videsolid |
|---|
| 10803 | gere_pstricks_opt |
|---|
| 10804 | tx@Dict /function undef |
|---|
| 10805 | } def |
|---|
| 10806 | % |
|---|
| 10807 | /pst-surface* { |
|---|
| 10808 | r |
|---|
| 10809 | ngrid length 2 ge { |
|---|
| 10810 | [ngrid 0 get ngrid 1 get] |
|---|
| 10811 | } { |
|---|
| 10812 | ngrid length 1 eq { |
|---|
| 10813 | [ngrid 0 get dup] |
|---|
| 10814 | } if |
|---|
| 10815 | } ifelse |
|---|
| 10816 | { function cvx exec } newsurface* |
|---|
| 10817 | dup videsolid |
|---|
| 10818 | gere_pstricks_opt |
|---|
| 10819 | } def |
|---|
| 10820 | |
|---|
| 10821 | /pst-vecteur { |
|---|
| 10822 | gsave |
|---|
| 10823 | /activationgestioncouleurs false def |
|---|
| 10824 | /vecteur_en_c@urs true def |
|---|
| 10825 | solidlinewidth setlinewidth |
|---|
| 10826 | 2 setlinejoin |
|---|
| 10827 | 1 setlinecap |
|---|
| 10828 | linecolor |
|---|
| 10829 | linestyle |
|---|
| 10830 | tx@Dict /solidname known { |
|---|
| 10831 | args definition cvx exec |
|---|
| 10832 | solidname cvlit defpoint3d |
|---|
| 10833 | tx@Dict /solidname undef |
|---|
| 10834 | } if |
|---|
| 10835 | args definition cvx exec newvecteur |
|---|
| 10836 | dup |
|---|
| 10837 | gsave |
|---|
| 10838 | [linecolor currentrgbcolor] ( ) astr2str (setrgbcolor) append |
|---|
| 10839 | outputcolors |
|---|
| 10840 | grestore |
|---|
| 10841 | gere_pstricks_opt |
|---|
| 10842 | grestore |
|---|
| 10843 | } def |
|---|
| 10844 | |
|---|
| 10845 | %/pst-vect- {} def |
|---|
| 10846 | %/pst-vect-2points {vecteur3d} def |
|---|
| 10847 | /pst-line { |
|---|
| 10848 | gsave |
|---|
| 10849 | linestyle |
|---|
| 10850 | linecolor |
|---|
| 10851 | [args] ligne3d |
|---|
| 10852 | grestore |
|---|
| 10853 | } def |
|---|
| 10854 | |
|---|
| 10855 | /pst-objfile { |
|---|
| 10856 | solidfilename newobjfile |
|---|
| 10857 | gere_pstricks_opt |
|---|
| 10858 | } def |
|---|
| 10859 | |
|---|
| 10860 | /pst-offfile { |
|---|
| 10861 | solidfilename newofffile |
|---|
| 10862 | gere_pstricks_opt |
|---|
| 10863 | } def |
|---|
| 10864 | |
|---|
| 10865 | /pst-datfile { |
|---|
| 10866 | solidfilename readsolidfile |
|---|
| 10867 | % /activationgestioncouleurs false def |
|---|
| 10868 | gere_pstricks_opt |
|---|
| 10869 | } def |
|---|
| 10870 | |
|---|
| 10871 | /pst-plantype { |
|---|
| 10872 | % args definition |
|---|
| 10873 | args (pst-plan-) definition append cvx exec |
|---|
| 10874 | dup phi rotateplan |
|---|
| 10875 | base length 4 eq { |
|---|
| 10876 | dup base planputrange |
|---|
| 10877 | } if |
|---|
| 10878 | origin eqpl@n pointeqplan 0 eq { |
|---|
| 10879 | dup origin planputorigine |
|---|
| 10880 | } if |
|---|
| 10881 | ngrid length 0 ne { |
|---|
| 10882 | dup ngrid planputngrid |
|---|
| 10883 | } if |
|---|
| 10884 | tx@Dict /solidname known { |
|---|
| 10885 | solidname cvlit exch bind def |
|---|
| 10886 | tx@Dict /solidname undef |
|---|
| 10887 | } { |
|---|
| 10888 | pop |
|---|
| 10889 | } ifelse |
|---|
| 10890 | } def |
|---|
| 10891 | /pst-plan- {pst-plan-plantype} def |
|---|
| 10892 | |
|---|
| 10893 | %x0 y0 z0 [normalvect] norm2plan |
|---|
| 10894 | /pst-plan-plantype { |
|---|
| 10895 | dup plan2eq /eqpl@n exch def |
|---|
| 10896 | /plan-@k true def |
|---|
| 10897 | } def |
|---|
| 10898 | |
|---|
| 10899 | /pst-plan { |
|---|
| 10900 | % args definition |
|---|
| 10901 | args (pst-plan-) definition append cvx exec |
|---|
| 10902 | /pl@n-en-cours true def |
|---|
| 10903 | definition length 0 ne { |
|---|
| 10904 | % plan-@k not { |
|---|
| 10905 | dup |
|---|
| 10906 | base 0 get base 1 get lt |
|---|
| 10907 | base 2 get base 3 get lt and { |
|---|
| 10908 | base |
|---|
| 10909 | } { |
|---|
| 10910 | [-3 3 -2 2] %pop base %aload pop boum |
|---|
| 10911 | } ifelse |
|---|
| 10912 | planputrange |
|---|
| 10913 | origin eqpl@n pointeqplan 0 eq { |
|---|
| 10914 | dup origin planputorigine |
|---|
| 10915 | } if |
|---|
| 10916 | CX isreal |
|---|
| 10917 | CX 0 eq and |
|---|
| 10918 | CY isreal and |
|---|
| 10919 | CY 0 eq and |
|---|
| 10920 | CZ isreal and |
|---|
| 10921 | CZ 0 eq and not { |
|---|
| 10922 | dup CX CY CZ planputorigine |
|---|
| 10923 | } if |
|---|
| 10924 | /CX 0. def |
|---|
| 10925 | /CY 0. def |
|---|
| 10926 | /CZ 0. def |
|---|
| 10927 | ngrid length 0 ne { |
|---|
| 10928 | dup ngrid planputngrid |
|---|
| 10929 | } if |
|---|
| 10930 | } if |
|---|
| 10931 | % dup RotX RotY RotZ rotateOplan |
|---|
| 10932 | dup phi rotateplan |
|---|
| 10933 | /l@pl@n exch def |
|---|
| 10934 | tx@Dict /solidname known { |
|---|
| 10935 | l@pl@n solidname cvlit exch bind def |
|---|
| 10936 | /solidname solidname (_s) append store |
|---|
| 10937 | } if |
|---|
| 10938 | l@pl@n newplan |
|---|
| 10939 | gere_pstricks_opt |
|---|
| 10940 | /pl@n-en-cours false def |
|---|
| 10941 | % action == |
|---|
| 10942 | % noir |
|---|
| 10943 | l@pl@n RotX RotY RotZ rotateOplan |
|---|
| 10944 | % l@pl@n CX CY CZ plantranslate |
|---|
| 10945 | % fontsize setfontsize |
|---|
| 10946 | % setTimes |
|---|
| 10947 | 1 gere_pstfont |
|---|
| 10948 | solidplanmarks {l@pl@n projectionsifacevisible planmarks} if |
|---|
| 10949 | solidplangrid {linecolor l@pl@n projectionsifacevisible planquadrillage} if |
|---|
| 10950 | solidshowbase {l@pl@n projectionsifacevisible planshowbase} if |
|---|
| 10951 | solidshowbase3d {l@pl@n projectionsifacevisible planshowbase3d} if |
|---|
| 10952 | } def |
|---|
| 10953 | |
|---|
| 10954 | |
|---|
| 10955 | /pst-plan-normalpoint { |
|---|
| 10956 | /plan-@k false def |
|---|
| 10957 | norm2plan |
|---|
| 10958 | dup plan2eq /eqpl@n exch def |
|---|
| 10959 | } def |
|---|
| 10960 | |
|---|
| 10961 | /pst-plan-equation { |
|---|
| 10962 | /plan-@k false def |
|---|
| 10963 | dup isarray { |
|---|
| 10964 | dup /eqpl@n exch def |
|---|
| 10965 | } { |
|---|
| 10966 | 2 copy pop /eqpl@n exch def |
|---|
| 10967 | } ifelse |
|---|
| 10968 | eq2plan |
|---|
| 10969 | } def |
|---|
| 10970 | |
|---|
| 10971 | /pst-plan-solidface { |
|---|
| 10972 | /plan-@k false def |
|---|
| 10973 | solidface2plan |
|---|
| 10974 | CX isreal |
|---|
| 10975 | CX 0 eq and |
|---|
| 10976 | CY isreal and |
|---|
| 10977 | CY 0 eq and |
|---|
| 10978 | CZ isreal and |
|---|
| 10979 | CZ 0 eq and not { |
|---|
| 10980 | dup CX CY CZ planputorigine |
|---|
| 10981 | } if |
|---|
| 10982 | |
|---|
| 10983 | % dup plangetrange aload pop boum |
|---|
| 10984 | % dup origin planputorigine |
|---|
| 10985 | dup plan2eq /eqpl@n exch def |
|---|
| 10986 | } def |
|---|
| 10987 | |
|---|
| 10988 | /pst-geode { |
|---|
| 10989 | ngrid aload pop newgeode |
|---|
| 10990 | gere_pstricks_opt |
|---|
| 10991 | } def |
|---|
| 10992 | |
|---|
| 10993 | /pst-load { |
|---|
| 10994 | solidloadname |
|---|
| 10995 | % /activationgestioncouleurs false def |
|---|
| 10996 | gere_pstricks_opt |
|---|
| 10997 | } def |
|---|
| 10998 | |
|---|
| 10999 | /pst-point { |
|---|
| 11000 | gsave |
|---|
| 11001 | linecolor |
|---|
| 11002 | 1 gere_pstfont |
|---|
| 11003 | action (none) eqstring not { |
|---|
| 11004 | args definition cvx exec point3d |
|---|
| 11005 | } if |
|---|
| 11006 | texte args definition cvx exec pos (text3d) append cvx exec |
|---|
| 11007 | tx@Dict /solidname known { |
|---|
| 11008 | args definition cvx exec |
|---|
| 11009 | solidname cvlit defpoint3d |
|---|
| 11010 | tx@Dict /solidname undef |
|---|
| 11011 | } if |
|---|
| 11012 | grestore |
|---|
| 11013 | } def |
|---|
| 11014 | |
|---|
| 11015 | %% syntaxe : alpha beta r h newpie --> solid |
|---|
| 11016 | /pst-pie { |
|---|
| 11017 | phi theta r h |
|---|
| 11018 | ngrid length 2 ge { |
|---|
| 11019 | [ngrid 0 get ngrid 1 get] |
|---|
| 11020 | } if |
|---|
| 11021 | newpie |
|---|
| 11022 | gere_pstricks_opt |
|---|
| 11023 | } def |
|---|
| 11024 | |
|---|
| 11025 | /pst-trigospherique { |
|---|
| 11026 | 3 dict begin |
|---|
| 11027 | gsave |
|---|
| 11028 | solidlinewidth setlinewidth |
|---|
| 11029 | linecolor |
|---|
| 11030 | linestyle |
|---|
| 11031 | args definition cvx exec |
|---|
| 11032 | grestore |
|---|
| 11033 | end |
|---|
| 11034 | } def |
|---|
| 11035 | |
|---|
| 11036 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 11037 | %%%% procedures pour \psProjection %%%% |
|---|
| 11038 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 11039 | |
|---|
| 11040 | /gere_pstricks_proj_opt { |
|---|
| 11041 | /planprojpst where { |
|---|
| 11042 | pop |
|---|
| 11043 | planprojpst projectionsifacevisible projpath |
|---|
| 11044 | % /planprojpst where pop /planprojpst undef |
|---|
| 11045 | } { |
|---|
| 11046 | /solidprojname where { |
|---|
| 11047 | /solidprojname get noface phi |
|---|
| 11048 | xorigine 0 eq |
|---|
| 11049 | yorigine 0 eq and |
|---|
| 11050 | zorigine 0 eq and |
|---|
| 11051 | xorigine isinteger not and |
|---|
| 11052 | yorigine isinteger not and |
|---|
| 11053 | yorigine isinteger not and { |
|---|
| 11054 | } { |
|---|
| 11055 | [xorigine yorigine zorigine] ( ) astr2str |
|---|
| 11056 | } ifelse |
|---|
| 11057 | projectionsifacevisible solidprojpath |
|---|
| 11058 | } { |
|---|
| 11059 | xorigine yorigine zorigine [ normale ] projectionsifacevisible planprojpath |
|---|
| 11060 | } ifelse |
|---|
| 11061 | } ifelse |
|---|
| 11062 | } def |
|---|
| 11063 | |
|---|
| 11064 | /proj-pst-chemin { |
|---|
| 11065 | solidlinewidth setlinewidth |
|---|
| 11066 | 1 dict begin |
|---|
| 11067 | newpath |
|---|
| 11068 | /cercle {cercle_} def |
|---|
| 11069 | path |
|---|
| 11070 | linecolor |
|---|
| 11071 | gere_pstricks_proj_opt |
|---|
| 11072 | end |
|---|
| 11073 | } def |
|---|
| 11074 | |
|---|
| 11075 | /proj-pst-courbeR2 { |
|---|
| 11076 | l@pl@n plangetrange aload pop |
|---|
| 11077 | setyrange setxrange |
|---|
| 11078 | newpath |
|---|
| 11079 | xmin ymin l@pl@n pointplan smoveto |
|---|
| 11080 | xmin ymax l@pl@n pointplan slineto |
|---|
| 11081 | xmax ymax l@pl@n pointplan slineto |
|---|
| 11082 | xmax ymin l@pl@n pointplan slineto |
|---|
| 11083 | xmin ymin l@pl@n pointplan slineto |
|---|
| 11084 | planprojpst projpath |
|---|
| 11085 | clip |
|---|
| 11086 | solidlinewidth setlinewidth |
|---|
| 11087 | newpath |
|---|
| 11088 | linecolor |
|---|
| 11089 | range aload pop { function cvx exec } CourbeR2_ |
|---|
| 11090 | gere_pstricks_proj_opt |
|---|
| 11091 | } def |
|---|
| 11092 | |
|---|
| 11093 | /proj-pst-courbe { |
|---|
| 11094 | l@pl@n plangetrange aload pop |
|---|
| 11095 | setyrange setxrange |
|---|
| 11096 | newpath |
|---|
| 11097 | xmin ymin l@pl@n pointplan smoveto |
|---|
| 11098 | xmin ymax l@pl@n pointplan slineto |
|---|
| 11099 | xmax ymax l@pl@n pointplan slineto |
|---|
| 11100 | xmax ymin l@pl@n pointplan slineto |
|---|
| 11101 | xmin ymin l@pl@n pointplan slineto |
|---|
| 11102 | planprojpst projpath |
|---|
| 11103 | clip |
|---|
| 11104 | solidlinewidth setlinewidth |
|---|
| 11105 | newpath |
|---|
| 11106 | linecolor |
|---|
| 11107 | range aload pop {} { function cvx exec } Courbeparam_ |
|---|
| 11108 | gere_pstricks_proj_opt |
|---|
| 11109 | } def |
|---|
| 11110 | |
|---|
| 11111 | /proj-pst-point { |
|---|
| 11112 | [proj-args] length 0 eq { |
|---|
| 11113 | xorigine yorigine /proj-args defpoint |
|---|
| 11114 | } if |
|---|
| 11115 | /projname where { |
|---|
| 11116 | pop |
|---|
| 11117 | [proj-args proj-definition cvx exec] |
|---|
| 11118 | dup 0 getp projname cvlit defpoint |
|---|
| 11119 | dup length 2 gt { |
|---|
| 11120 | 1 getp projname (0) append cvlit defpoint |
|---|
| 11121 | } if |
|---|
| 11122 | /projname where pop /projname undef |
|---|
| 11123 | } if |
|---|
| 11124 | proj-action (none) eqstring not { |
|---|
| 11125 | solidlinewidth setlinewidth |
|---|
| 11126 | linecolor |
|---|
| 11127 | [proj-args proj-definition cvx exec] 0 getp point_ |
|---|
| 11128 | gere_pstricks_proj_opt |
|---|
| 11129 | Stroke |
|---|
| 11130 | } if |
|---|
| 11131 | % 1 1 0 0 1 1 Diamond |
|---|
| 11132 | texte length 0 gt { |
|---|
| 11133 | proj-fontsize setfontsize |
|---|
| 11134 | %setTimes |
|---|
| 11135 | solidlinewidth setlinewidth |
|---|
| 11136 | newpath |
|---|
| 11137 | linecolor |
|---|
| 11138 | texte [proj-args proj-definition cvx exec 0 0 phi neg rotatepoint] 0 getp |
|---|
| 11139 | pos (text_) append cvx exec |
|---|
| 11140 | %% /planprojpst where { |
|---|
| 11141 | %% planprojpst dupplan dup phi rotateplan /planprojpst exch def |
|---|
| 11142 | %% pop |
|---|
| 11143 | %% xorigine yorigine |
|---|
| 11144 | %% 0 0 phi neg rotatepoint |
|---|
| 11145 | %% } { |
|---|
| 11146 | %% 0 0 |
|---|
| 11147 | %% } ifelse |
|---|
| 11148 | %gere_pstricks_proj_opt |
|---|
| 11149 | planprojpst dupplan dup phi rotateplan projectionsifacevisible projpath |
|---|
| 11150 | Fill |
|---|
| 11151 | } if |
|---|
| 11152 | } def |
|---|
| 11153 | |
|---|
| 11154 | /proj-pst-vecteur { |
|---|
| 11155 | proj-action (none) eqstring not { |
|---|
| 11156 | planprojpst bprojscene |
|---|
| 11157 | solidlinewidth setlinewidth |
|---|
| 11158 | linestyle |
|---|
| 11159 | linecolor |
|---|
| 11160 | xorigine yorigine 2 copy proj-args proj-definition cvx exec addv drawvecteur |
|---|
| 11161 | eprojscene |
|---|
| 11162 | } if |
|---|
| 11163 | /projname where { |
|---|
| 11164 | pop |
|---|
| 11165 | proj-args proj-definition cvx exec projname cvlit defpoint |
|---|
| 11166 | /projname where pop /projname undef |
|---|
| 11167 | } if |
|---|
| 11168 | } def |
|---|
| 11169 | |
|---|
| 11170 | /proj-pst-droite { |
|---|
| 11171 | proj-action (none) eqstring not { |
|---|
| 11172 | l@pl@n plangetrange aload pop |
|---|
| 11173 | setyrange setxrange |
|---|
| 11174 | %% newpath |
|---|
| 11175 | %% xmin ymin l@pl@n pointplan smoveto |
|---|
| 11176 | %% xmin ymax l@pl@n pointplan slineto |
|---|
| 11177 | %% xmax ymax l@pl@n pointplan slineto |
|---|
| 11178 | %% xmax ymin l@pl@n pointplan slineto |
|---|
| 11179 | %% xmin ymin l@pl@n pointplan smoveto |
|---|
| 11180 | %% planprojpst projpath |
|---|
| 11181 | %% clip |
|---|
| 11182 | planprojpst bprojscene |
|---|
| 11183 | solidlinewidth setlinewidth |
|---|
| 11184 | linestyle |
|---|
| 11185 | linecolor |
|---|
| 11186 | proj-args proj-definition cvx exec droite |
|---|
| 11187 | eprojscene |
|---|
| 11188 | } if |
|---|
| 11189 | /projname where { |
|---|
| 11190 | pop |
|---|
| 11191 | proj-args proj-definition cvx exec projname cvlit defdroite |
|---|
| 11192 | /projname where pop /projname undef |
|---|
| 11193 | } if |
|---|
| 11194 | } def |
|---|
| 11195 | |
|---|
| 11196 | /proj-pst-polygone { |
|---|
| 11197 | proj-action (none) eqstring not { |
|---|
| 11198 | l@pl@n plangetrange aload pop |
|---|
| 11199 | setyrange setxrange |
|---|
| 11200 | newpath |
|---|
| 11201 | xmin ymin l@pl@n pointplan smoveto |
|---|
| 11202 | xmin ymax l@pl@n pointplan slineto |
|---|
| 11203 | xmax ymax l@pl@n pointplan slineto |
|---|
| 11204 | xmax ymin l@pl@n pointplan slineto |
|---|
| 11205 | xmin ymin l@pl@n pointplan slineto |
|---|
| 11206 | planprojpst projpath |
|---|
| 11207 | clip |
|---|
| 11208 | solidlinewidth setlinewidth |
|---|
| 11209 | linestyle |
|---|
| 11210 | linecolor |
|---|
| 11211 | proj-definition length 0 eq { |
|---|
| 11212 | [proj-args] |
|---|
| 11213 | } { |
|---|
| 11214 | proj-args |
|---|
| 11215 | } ifelse |
|---|
| 11216 | proj-definition cvx exec polygone_ |
|---|
| 11217 | planprojpst projectionsifacevisible projpath |
|---|
| 11218 | } if |
|---|
| 11219 | /projname where { |
|---|
| 11220 | pop |
|---|
| 11221 | proj-definition length 0 eq { |
|---|
| 11222 | [proj-args] |
|---|
| 11223 | } { |
|---|
| 11224 | proj-args |
|---|
| 11225 | } ifelse |
|---|
| 11226 | proj-definition cvx exec projname cvlit exch def |
|---|
| 11227 | /projname where pop /projname undef |
|---|
| 11228 | } if |
|---|
| 11229 | } def |
|---|
| 11230 | |
|---|
| 11231 | /proj-pst-cercle { |
|---|
| 11232 | /projname where { |
|---|
| 11233 | pop |
|---|
| 11234 | proj-args proj-definition cvx exec projname cvlit defcercle |
|---|
| 11235 | /projname where pop /projname undef |
|---|
| 11236 | } if |
|---|
| 11237 | proj-action (none) eqstring not { |
|---|
| 11238 | l@pl@n plangetrange aload pop |
|---|
| 11239 | setyrange setxrange |
|---|
| 11240 | %% newpath |
|---|
| 11241 | %% xmin ymin l@pl@n pointplan smoveto |
|---|
| 11242 | %% xmin ymax l@pl@n pointplan slineto |
|---|
| 11243 | %% xmax ymax l@pl@n pointplan slineto |
|---|
| 11244 | %% xmax ymin l@pl@n pointplan slineto |
|---|
| 11245 | %% xmin ymin l@pl@n pointplan slineto |
|---|
| 11246 | %% planprojpst projpath |
|---|
| 11247 | %% clip |
|---|
| 11248 | solidlinewidth setlinewidth |
|---|
| 11249 | linestyle |
|---|
| 11250 | linecolor |
|---|
| 11251 | newpath |
|---|
| 11252 | range aload pop proj-args |
|---|
| 11253 | proj-definition cvx exec Cercle_ |
|---|
| 11254 | planprojpst projectionsifacevisible projpath |
|---|
| 11255 | } if |
|---|
| 11256 | } def |
|---|
| 11257 | |
|---|
| 11258 | /proj-pst-line { |
|---|
| 11259 | proj-action (none) eqstring not { |
|---|
| 11260 | l@pl@n plangetrange aload pop |
|---|
| 11261 | setyrange setxrange |
|---|
| 11262 | %% newpath |
|---|
| 11263 | %% xmin ymin l@pl@n pointplan smoveto |
|---|
| 11264 | %% xmin ymax l@pl@n pointplan slineto |
|---|
| 11265 | %% xmax ymax l@pl@n pointplan slineto |
|---|
| 11266 | %% xmax ymin l@pl@n pointplan slineto |
|---|
| 11267 | %% xmin ymin l@pl@n pointplan slineto |
|---|
| 11268 | %% planprojpst projpath |
|---|
| 11269 | %% clip |
|---|
| 11270 | planprojpst bprojscene |
|---|
| 11271 | solidlinewidth setlinewidth |
|---|
| 11272 | linestyle |
|---|
| 11273 | linecolor |
|---|
| 11274 | proj-definition length 0 eq { |
|---|
| 11275 | [proj-args] |
|---|
| 11276 | } { |
|---|
| 11277 | proj-args |
|---|
| 11278 | } ifelse |
|---|
| 11279 | proj-definition cvx exec ligne |
|---|
| 11280 | eprojscene |
|---|
| 11281 | } if |
|---|
| 11282 | /projname where { |
|---|
| 11283 | pop |
|---|
| 11284 | proj-definition length 0 eq { |
|---|
| 11285 | [proj-args] |
|---|
| 11286 | } { |
|---|
| 11287 | proj-args |
|---|
| 11288 | } ifelse |
|---|
| 11289 | proj-definition cvx exec projname cvlit exch def |
|---|
| 11290 | /projname where pop /projname undef |
|---|
| 11291 | } if |
|---|
| 11292 | } def |
|---|
| 11293 | |
|---|
| 11294 | /proj-pst-rightangle { |
|---|
| 11295 | proj-action (none) eqstring not { |
|---|
| 11296 | planprojpst bprojscene |
|---|
| 11297 | solidlinewidth setlinewidth |
|---|
| 11298 | linestyle |
|---|
| 11299 | linecolor |
|---|
| 11300 | proj-args proj-definition cvx exec angledroit |
|---|
| 11301 | eprojscene |
|---|
| 11302 | } if |
|---|
| 11303 | } def |
|---|
| 11304 | |
|---|
| 11305 | /proj-pst-texte { |
|---|
| 11306 | 2 dict begin |
|---|
| 11307 | proj-fontsize setfontsize |
|---|
| 11308 | %setTimes |
|---|
| 11309 | 1 gere_pstfont |
|---|
| 11310 | solidlinewidth setlinewidth |
|---|
| 11311 | newpath |
|---|
| 11312 | linecolor |
|---|
| 11313 | texte |
|---|
| 11314 | /planprojpst where { |
|---|
| 11315 | planprojpst dupplan dup phi rotateplan /planprojpst exch def |
|---|
| 11316 | pop |
|---|
| 11317 | xorigine yorigine |
|---|
| 11318 | 0 0 phi neg rotatepoint |
|---|
| 11319 | } { |
|---|
| 11320 | 0 0 |
|---|
| 11321 | } ifelse |
|---|
| 11322 | pos (text_) append cvx exec |
|---|
| 11323 | gere_pstricks_proj_opt |
|---|
| 11324 | Fill |
|---|
| 11325 | end |
|---|
| 11326 | } def |
|---|
| 11327 | |
|---|
| 11328 | % END solides.pro |
|---|