| | 418 | %%%% la 2D %%%% |
|---|
| | 419 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| | 420 | |
|---|
| | 421 | %%%%% ### vecteur ### |
|---|
| | 422 | %% syntaxe~: A B vecteur |
|---|
| | 423 | /vecteur { |
|---|
| | 424 | %% xA yA xB yB |
|---|
| | 425 | 3 -1 roll %% xA xB yB yA |
|---|
| | 426 | sub %% xA xB yB-yA |
|---|
| | 427 | 3 1 roll %% yB-yA xA xB |
|---|
| | 428 | exch sub %% yB-yA xB-xA |
|---|
| | 429 | exch |
|---|
| | 430 | } def |
|---|
| | 431 | |
|---|
| | 432 | %%%%% ### defpoint ### |
|---|
| | 433 | %% syntaxe : xA yA /A defpoint |
|---|
| | 434 | /defpoint { |
|---|
| | 435 | 1 dict begin |
|---|
| | 436 | /t@mp@r@ire exch def |
|---|
| | 437 | [ 3 1 roll ] cvx t@mp@r@ire exch |
|---|
| | 438 | end def |
|---|
| | 439 | } def |
|---|
| | 440 | |
|---|
| | 441 | %%%%% ### normalize ### |
|---|
| | 442 | %% syntaxe : u normalize -> u / ||u|| |
|---|
| | 443 | /normalize { |
|---|
| | 444 | 2 dict begin |
|---|
| | 445 | /u defpoint |
|---|
| | 446 | /n u norme def |
|---|
| | 447 | u 1 n div mulv |
|---|
| | 448 | end |
|---|
| | 449 | } def |
|---|
| | 450 | |
|---|
| | 451 | %%%%% ### norme ### |
|---|
| | 452 | %% syntaxe : u norme --> |u| |
|---|
| | 453 | /norme { |
|---|
| | 454 | dup mul |
|---|
| | 455 | exch |
|---|
| | 456 | dup mul |
|---|
| | 457 | add sqrt |
|---|
| | 458 | } def |
|---|
| | 459 | |
|---|
| | 460 | %%%%% ### oldarrow ### |
|---|
| | 461 | %% syntaxe : A B oldarrow --> trace fleche en B, direction AB |
|---|
| | 462 | /oldarrow { |
|---|
| | 463 | 4 dict begin |
|---|
| | 464 | gsave |
|---|
| | 465 | /B defpoint |
|---|
| | 466 | /A defpoint |
|---|
| | 467 | oldarrowscale scale |
|---|
| | 468 | oldarrowangle rotate |
|---|
| | 469 | newpath |
|---|
| | 470 | B smoveto |
|---|
| | 471 | A B vecteur normalize /u defpoint |
|---|
| | 472 | u neg exch /v defpoint |
|---|
| | 473 | u oldarrowpointe neg mulv rmoveto %% ainsi c'est la pointe qui est en (0, 0) |
|---|
| | 474 | %% le pt extremal arriere haut |
|---|
| | 475 | u oldarrowplume neg mulv %% l'abscisse |
|---|
| | 476 | v oldarrow@ngle sin oldarrow@ngle cos div oldarrowplume mul mulv addv %% l'ordonnee |
|---|
| | 477 | rlineto |
|---|
| | 478 | u oldarrowplume oldarrowpointe add mulv |
|---|
| | 479 | v oldarrow@ngle sin oldarrow@ngle cos div oldarrowplume mul neg mulv addv |
|---|
| | 480 | rlineto |
|---|
| | 481 | u oldarrowplume oldarrowpointe add neg mulv |
|---|
| | 482 | v oldarrow@ngle sin oldarrow@ngle cos div oldarrowplume mul neg mulv addv |
|---|
| | 483 | rlineto |
|---|
| | 484 | closepath fill |
|---|
| | 485 | grestore |
|---|
| | 486 | end |
|---|
| | 487 | } def |
|---|
| | 488 | |
|---|
| | 489 | /oldarrowpointe 12.5 def |
|---|
| | 490 | /oldarrowplume 2.5 def |
|---|
| | 491 | /oldarrow@ngle 60 def |
|---|
| | 492 | /oldarrowscale {1 1} def |
|---|
| | 493 | /oldarrowangle 0 def %% pour l'utilisateur |
|---|
| | 494 | |
|---|
| | 495 | %%%%% ### fin insertion ### |
|---|
| | 496 | |
|---|
| | 497 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| | 5350 | end |
|---|
| | 5351 | } def |
|---|
| | 5352 | |
|---|
| | 5353 | %% syntaxe : plantype str1 str2 planshowbase -> - |
|---|
| | 5354 | %% syntaxe : plantype str2 planshowbase -> - |
|---|
| | 5355 | %% syntaxe : plantype planshowbase -> - |
|---|
| | 5356 | /planshowbase { |
|---|
| | 5357 | 3 dict begin |
|---|
| | 5358 | dup isstring { |
|---|
| | 5359 | /couleur2 exch def |
|---|
| | 5360 | dup isstring { |
|---|
| | 5361 | /couleur1 exch def |
|---|
| | 5362 | } { |
|---|
| | 5363 | /couleur1 (rouge) def |
|---|
| | 5364 | } ifelse |
|---|
| | 5365 | } { |
|---|
| | 5366 | /couleur1 (rouge) def |
|---|
| | 5367 | /couleur2 (vert) def |
|---|
| | 5368 | } ifelse |
|---|
| | 5369 | bprojscene |
|---|
| | 5370 | couleur1 cvx exec |
|---|
| | 5371 | newpath |
|---|
| | 5372 | 0 0 smoveto |
|---|
| | 5373 | 1 0 slineto |
|---|
| | 5374 | stroke |
|---|
| | 5375 | 0 0 1 0 oldarrow |
|---|
| | 5376 | couleur2 cvx exec |
|---|
| | 5377 | newpath |
|---|
| | 5378 | 0 0 smoveto |
|---|
| | 5379 | 0 1 slineto |
|---|
| | 5380 | stroke |
|---|
| | 5381 | 0 0 0 1 oldarrow |
|---|
| | 5382 | eprojscene |
|---|
| | 5383 | end |
|---|
| | 5384 | } def |
|---|
| | 5385 | |
|---|
| | 5386 | %% syntaxe : plantype str1 str2 str3 planshowbase3d -> - |
|---|
| | 5387 | %% syntaxe : plantype str2 str3 planshowbase3d -> - |
|---|
| | 5388 | %% syntaxe : plantype str3 planshowbase3d -> - |
|---|
| | 5389 | %% syntaxe : plantype planshowbase3d -> - |
|---|
| | 5390 | %% syntaxe : plantype str1 str2 str3 array planshowbase3d -> - |
|---|
| | 5391 | %% syntaxe : plantype str2 str3 array planshowbase3d -> - |
|---|
| | 5392 | %% syntaxe : plantype str3 array planshowbase3d -> - |
|---|
| | 5393 | %% syntaxe : plantype array planshowbase3d -> - |
|---|
| | 5394 | /planshowbase3d { |
|---|
| | 5395 | 7 dict begin |
|---|
| | 5396 | dup dup isarray exch isplan not and { |
|---|
| | 5397 | /table exch def |
|---|
| | 5398 | } { |
|---|
| | 5399 | /table {} def |
|---|
| | 5400 | } ifelse |
|---|
| | 5401 | dup isstring { |
|---|
| | 5402 | /couleur3 exch def |
|---|
| | 5403 | dup isstring { |
|---|
| | 5404 | /couleur2 exch def |
|---|
| | 5405 | dup isstring { |
|---|
| | 5406 | /couleur1 exch def |
|---|
| | 5407 | } { |
|---|
| | 5408 | /couleur1 (rouge) def |
|---|
| | 5409 | } ifelse |
|---|
| | 5410 | } { |
|---|
| | 5411 | /couleur2 (vert) def |
|---|
| | 5412 | /couleur1 (rouge) def |
|---|
| | 5413 | } ifelse |
|---|
| | 5414 | } { |
|---|
| | 5415 | /couleur1 (rouge) def |
|---|
| | 5416 | /couleur2 (vert) def |
|---|
| | 5417 | /couleur3 (bleu) def |
|---|
| | 5418 | } ifelse |
|---|
| | 5419 | /plan exch def |
|---|
| | 5420 | plan couleur1 couleur2 planshowbase |
|---|
| | 5421 | plan plangetorigine /I defpoint3d |
|---|
| | 5422 | plan plangetbase |
|---|
| | 5423 | dup 0 getp3d /u defpoint3d |
|---|
| | 5424 | 1 getp3d /v defpoint3d |
|---|
| | 5425 | u v vectprod3d table newvecteur |
|---|
| | 5426 | {I addv3d} solidtransform |
|---|
| | 5427 | dup couleur3 solidputcolors |
|---|
| | 5428 | solidgridOff |
|---|
| | 5429 | drawsolid** |
|---|