| | 556 | } def |
|---|
| | 557 | |
|---|
| | 558 | % coordonnées sphériques -> coordonnées cartésiennes |
|---|
| | 559 | /rtp2xyz { |
|---|
| | 560 | 6 dict begin |
|---|
| | 561 | /phi exch def |
|---|
| | 562 | /theta exch def |
|---|
| | 563 | /r exch def |
|---|
| | 564 | /x phi cos theta cos mul r mul def |
|---|
| | 565 | /y phi cos theta sin mul r mul def |
|---|
| | 566 | /z phi sin r mul def |
|---|
| | 567 | x y z |
|---|
| | 568 | end |
|---|
| | 569 | } def |
|---|
| | 570 | |
|---|
| | 571 | %% norme d'un vecteur 3d |
|---|
| | 572 | /norme3d { %% x y z |
|---|
| | 573 | 3 dict begin |
|---|
| | 574 | /z exch def |
|---|
| | 575 | /y exch def |
|---|
| | 576 | /x exch def |
|---|
| | 577 | x dup mul y dup mul add z dup mul add sqrt |
|---|
| | 578 | end |
|---|
| | 579 | } def |
|---|
| | 580 | |
|---|
| | 581 | %% duplique le vecteur 3d |
|---|
| | 582 | /dupp3d { %% x y z |
|---|
| | 583 | 3 copy |
|---|
| | 584 | } def |
|---|
| | 585 | /dupv3d {dupp3d} def |
|---|
| | 586 | |
|---|
| | 587 | %%%%% ### mulv3d ### |
|---|
| | 588 | %% (scalaire)*(vecteur 3d) Attention : dans l autre sens ! |
|---|
| | 589 | /mulv3d { %% x y z lambda |
|---|
| | 590 | 4 dict begin |
|---|
| | 591 | /lambda exch def |
|---|
| | 592 | /z exch def |
|---|
| | 593 | /y exch def |
|---|
| | 594 | /x exch def |
|---|
| | 595 | x lambda mul |
|---|
| | 596 | y lambda mul |
|---|
| | 597 | z lambda mul |
|---|
| | 598 | end |
|---|
| | 599 | } def |
|---|
| | 600 | |
|---|
| | 601 | %%%%% ### defpoint3d ### |
|---|
| | 602 | %% creation du point A a partir de xA yA yB et du nom /A |
|---|
| | 603 | /defpoint3d { %% xA yA zA /nom |
|---|
| | 604 | 1 dict begin |
|---|
| | 605 | /memo exch def |
|---|
| | 606 | [ 4 1 roll ] cvx memo exch |
|---|
| | 607 | end def |
|---|
| | 608 | }def |
|---|
| | 609 | |
|---|
| | 610 | %%%%% ### scalprod3d ### |
|---|
| | 611 | %% produit scalaire de deux vecteurs 3d |
|---|
| | 612 | /scalprod3d { %% x1 y1 z1 x2 y2 z2 |
|---|
| | 613 | 6 dict begin |
|---|
| | 614 | /zp exch def |
|---|
| | 615 | /yp exch def |
|---|
| | 616 | /xp exch def |
|---|
| | 617 | /z exch def |
|---|
| | 618 | /y exch def |
|---|
| | 619 | /x exch def |
|---|
| | 620 | x xp mul y yp mul add z zp mul add |
|---|
| | 621 | end |
|---|
| | 622 | } def |
|---|
| | 623 | |
|---|
| | 624 | %%%%% ### addv3d ### |
|---|
| | 625 | %% addition de deux vecteurs 3d |
|---|
| | 626 | /addv3d { %% x1 y1 z1 x2 y2 z2 |
|---|
| | 627 | 6 dict begin |
|---|
| | 628 | /zp exch def |
|---|
| | 629 | /yp exch def |
|---|
| | 630 | /xp exch def |
|---|
| | 631 | /z exch def |
|---|
| | 632 | /y exch def |
|---|
| | 633 | /x exch def |
|---|
| | 634 | x xp add |
|---|
| | 635 | y yp add |
|---|
| | 636 | z zp add |
|---|
| | 637 | end |
|---|
| | 638 | } def |
|---|
| | 639 | |
|---|
| | 640 | /arccos { |
|---|
| | 641 | dup |
|---|
| | 642 | dup mul neg 1 add sqrt |
|---|
| | 643 | exch |
|---|
| | 644 | atan |
|---|
| | 645 | } def |
|---|
| | 646 | |
|---|
| | 647 | %%%%% ### rotV3d ### |
|---|
| | 648 | /rotV3d { |
|---|
| | 649 | 15 dict begin |
|---|
| | 650 | % /ux 0 def /uy 41.15 sin def /uz 41.15 cos def |
|---|
| | 651 | /N2uvw ux dup mul uy dup mul add uz dup mul add def |
|---|
| | 652 | /N2uv ux dup mul uy dup mul add def |
|---|
| | 653 | /N2vw uz dup mul uy dup mul add def |
|---|
| | 654 | /N2uw uz dup mul ux dup mul add def |
|---|
| | 655 | /z exch def /y exch def /x exch def |
|---|
| | 656 | /uxvywz ux x mul uy y mul add uz z mul add def |
|---|
| | 657 | /uxvy ux x mul uy y mul add def |
|---|
| | 658 | /uxwz ux x mul uz z mul add def |
|---|
| | 659 | /vywz uy y mul uz z mul add def |
|---|
| | 660 | /_wyvz uz y mul neg uy z mul add def |
|---|
| | 661 | /wx_uz uz x mul ux z mul sub def |
|---|
| | 662 | /_vxuy uy x mul neg ux y mul add def |
|---|
| | 663 | ux uxvywz mul x N2vw mul ux vywz mul sub theta cos mul add N2uvw sqrt _wyvz mul theta sin mul add N2uvw div |
|---|
| | 664 | uy uxvywz mul y N2uw mul uy uxwz mul sub theta cos mul add N2uvw sqrt wx_uz mul theta sin mul add N2uvw div |
|---|
| | 665 | uz uxvywz mul z N2uv mul uz uxvy mul sub theta cos mul add N2uvw sqrt _vxuy mul theta sin mul add N2uvw div |
|---|
| | 666 | end |
|---|
| | 667 | } def |
|---|
| | 668 | |
|---|
| | 669 | |
|---|
| | 670 | /grand_cercle_test{ |
|---|
| | 671 | 50 dict begin |
|---|
| | 672 | /theta {180 hour 15 mul sub} bind def |
|---|
| | 673 | % direction des rayons du soleil |
|---|
| | 674 | u1 u2 u3 /u defpoint3d |
|---|
| | 675 | % vecteur normal dans le plan meridien |
|---|
| | 676 | % la latitude |
|---|
| | 677 | % /phi0 u2 neg u3 atan def |
|---|
| | 678 | u1 u2 u3 rotV3d |
|---|
| | 679 | /nZ exch def /nY exch def pop |
|---|
| | 680 | /phi0 nY neg nZ atan def |
|---|
| | 681 | % vecteur normal dans le plan equateur |
|---|
| | 682 | /theta0 u1 neg u2 atan def |
|---|
| | 683 | theta0 cos theta0 sin 0 /v defpoint3d |
|---|
| | 684 | % w tels que le trièdre u v w soit direct |
|---|
| | 685 | u v vectprod3d dupp3d norme3d 1 exch div mulv3d /w defpoint3d |
|---|
| | 686 | /TabPointsVusNeg[ |
|---|
| | 687 | -180 1 0{ % for |
|---|
| | 688 | /t exch def |
|---|
| | 689 | v t cos Rsphere mul mulv3d |
|---|
| | 690 | w t sin Rsphere mul mulv3d |
|---|
| | 691 | addv3d |
|---|
| | 692 | rotV3d |
|---|
| | 693 | /Zpoint exch def /Ypoint exch def /Xpoint exch def |
|---|
| | 694 | CalculsPointsAfterTransformations |
|---|
| | 695 | Test |
|---|
| | 696 | PS 0 gt { t } if |
|---|
| | 697 | } for |
|---|
| | 698 | ] def |
|---|
| | 699 | % |
|---|
| | 700 | /TabPointsVusPos[ |
|---|
| | 701 | 0 1 180{ % for |
|---|
| | 702 | /t exch def |
|---|
| | 703 | v t cos Rsphere mul mulv3d |
|---|
| | 704 | w t sin Rsphere mul mulv3d |
|---|
| | 705 | addv3d |
|---|
| | 706 | rotV3d |
|---|
| | 707 | /Zpoint exch def /Ypoint exch def /Xpoint exch def |
|---|
| | 708 | CalculsPointsAfterTransformations |
|---|
| | 709 | Test |
|---|
| | 710 | PS 0 gt { t } if |
|---|
| | 711 | } for |
|---|
| | 712 | ] def |
|---|
| | 713 | /t_minNeg 0 def |
|---|
| | 714 | /t_maxNeg -180 def |
|---|
| | 715 | |
|---|
| | 716 | 0 1 TabPointsVusNeg length 1 sub { % for |
|---|
| | 717 | /iPoint exch def |
|---|
| | 718 | /t TabPointsVusNeg iPoint get def |
|---|
| | 719 | t t_minNeg le {/t_minNeg t def} if |
|---|
| | 720 | } for |
|---|
| | 721 | 0 1 TabPointsVusNeg length 1 sub { % for |
|---|
| | 722 | /iPoint exch def |
|---|
| | 723 | /t TabPointsVusNeg iPoint get def |
|---|
| | 724 | t t_maxNeg ge {/t_maxNeg t def} if |
|---|
| | 725 | } for |
|---|
| | 726 | |
|---|
| | 727 | /t_minPos 180 def |
|---|
| | 728 | /t_maxPos 0 def |
|---|
| | 729 | |
|---|
| | 730 | 0 1 TabPointsVusPos length 1 sub { % for |
|---|
| | 731 | /iPoint exch def |
|---|
| | 732 | /t TabPointsVusPos iPoint get def |
|---|
| | 733 | t t_minPos le {/t_minPos t def} if |
|---|
| | 734 | } for |
|---|
| | 735 | 0 1 TabPointsVusPos length 1 sub { % for |
|---|
| | 736 | /iPoint exch def |
|---|
| | 737 | /t TabPointsVusPos iPoint get def |
|---|
| | 738 | t t_maxPos ge {/t_maxPos t def} if |
|---|
| | 739 | } for |
|---|
| | 740 | |
|---|
| | 741 | theta -90 ge theta 90 le and { |
|---|
| | 742 | v t_minNeg cos Rsphere mul mulv3d |
|---|
| | 743 | w t_minNeg sin Rsphere mul mulv3d |
|---|
| | 744 | addv3d |
|---|
| | 745 | rotV3d |
|---|
| | 746 | /Zpoint exch def /Ypoint exch def /Xpoint exch def |
|---|
| | 747 | CalculsPointsAfterTransformations |
|---|
| | 748 | CalcCoordinates |
|---|
| | 749 | moveto |
|---|
| | 750 | |
|---|
| | 751 | t_minNeg 1 t_maxPos{ |
|---|
| | 752 | /t exch def |
|---|
| | 753 | v t cos Rsphere mul mulv3d |
|---|
| | 754 | w t sin Rsphere mul mulv3d |
|---|
| | 755 | addv3d |
|---|
| | 756 | rotV3d |
|---|
| | 757 | /Zpoint exch def /Ypoint exch def /Xpoint exch def |
|---|
| | 758 | CalculsPointsAfterTransformations |
|---|
| | 759 | CalcCoordinates |
|---|
| | 760 | lineto |
|---|
| | 761 | } for |
|---|
| | 762 | %/phi0 90 phi0 sub def |
|---|
| | 763 | phi0 1 phi0 180 add { /t exch def |
|---|
| | 764 | /Xpoint 0 def |
|---|
| | 765 | /Ypoint Rsphere t cos mul def |
|---|
| | 766 | /Zpoint Rsphere t sin mul def |
|---|
| | 767 | CalculsPointsAfterTransformations |
|---|
| | 768 | CalcCoordinates |
|---|
| | 769 | lineto |
|---|
| | 770 | } for |
|---|
| | 771 | %2 setlinewidth |
|---|
| | 772 | %1 0 1 setrgbcolor |
|---|
| | 773 | %stroke |
|---|
| | 774 | closepath |
|---|
| | 775 | %gsave |
|---|
| | 776 | %pst@fill |
|---|
| | 777 | %grestore |
|---|
| | 778 | }{ |
|---|
| | 779 | v t_minPos cos Rsphere mul mulv3d |
|---|
| | 780 | w t_minPos sin Rsphere mul mulv3d |
|---|
| | 781 | addv3d |
|---|
| | 782 | rotV3d |
|---|
| | 783 | /Zpoint exch def /Ypoint exch def /Xpoint exch def |
|---|
| | 784 | CalculsPointsAfterTransformations |
|---|
| | 785 | CalcCoordinates |
|---|
| | 786 | moveto |
|---|
| | 787 | |
|---|
| | 788 | t_minPos 1 t_maxPos { |
|---|
| | 789 | /t exch def |
|---|
| | 790 | v t cos Rsphere mul mulv3d |
|---|
| | 791 | w t sin Rsphere mul mulv3d |
|---|
| | 792 | addv3d |
|---|
| | 793 | rotV3d |
|---|
| | 794 | /Zpoint exch def /Ypoint exch def /Xpoint exch def |
|---|
| | 795 | CalculsPointsAfterTransformations |
|---|
| | 796 | CalcCoordinates |
|---|
| | 797 | lineto |
|---|
| | 798 | } for |
|---|
| | 799 | t_minNeg 1 t_maxNeg { |
|---|
| | 800 | /t exch def |
|---|
| | 801 | v t cos Rsphere mul mulv3d |
|---|
| | 802 | w t sin Rsphere mul mulv3d |
|---|
| | 803 | addv3d |
|---|
| | 804 | rotV3d |
|---|
| | 805 | /Zpoint exch def /Ypoint exch def /Xpoint exch def |
|---|
| | 806 | CalculsPointsAfterTransformations |
|---|
| | 807 | CalcCoordinates |
|---|
| | 808 | lineto |
|---|
| | 809 | } for |
|---|
| | 810 | phi0 1 phi0 180 add { /t exch def |
|---|
| | 811 | /Xpoint 0 def |
|---|
| | 812 | /Ypoint Rsphere t cos mul def |
|---|
| | 813 | /Zpoint Rsphere t sin mul def |
|---|
| | 814 | CalculsPointsAfterTransformations |
|---|
| | 815 | CalcCoordinates |
|---|
| | 816 | lineto |
|---|
| | 817 | } for |
|---|
| | 818 | %2 setlinewidth |
|---|
| | 819 | %1 1 0 setrgbcolor |
|---|
| | 820 | %stroke |
|---|
| | 821 | closepath |
|---|
| | 822 | %gsave |
|---|
| | 823 | %pst@fill |
|---|
| | 824 | %grestore |
|---|
| | 825 | } ifelse |
|---|
| | 826 | end |
|---|
| | 827 | } |
|---|
| | 828 | def |
|---|
| | 829 | |
|---|
| | 830 | |
|---|
| | 831 | end |
|---|