Premier chargement des fichiers
[mp-geo.git] / doc / exemplemanuel.mp
1 %j'ai du modifier main_memory
2 %sous Debian Etch
3 %modifier /etc/texmf/texmf.d/95NonPath.cnf
4 %main_memory:1500000->40000000 !!!!
5 %puis update-texmf
6 %puis fmtutil-sys --refresh
7 % ->not ok :( "independent variables" pose problème.
8 % solution: réduction du nombre de points placés.
9 % pb suivant : lorsque l'on a une position de l'observateur avec un
10 % phi>90, rien ne s'affiche->réglé
11
12 % autre solution envisagée ici : lecture des données dans un fichier
13 % extérieur au format dat par exemple
14
15 % il faut changer aussi le path size :) >2000 pour une version avec ..
16 % au lieu de -- mais cette version marche pas :(
17 % modifier /etc/texmf/texmf.d/95NonPath.cnf
18 % path_size.mpost=10000
19
20 % readfrom files=30. Comment changer ? Pas la peine : inclusion d'un
21 % closefrom (présent dans metapost depuis 0.64) pour clotûrer vraiment
22 % chaque fichier en fin de lecture. quand readfrom lit une ligne d'un
23 % fichier, il ne passe pas de suite à la prochaine ligne, il attend
24 % simplement le prochain ordre "readfrom".
25
26 % ajout de LectureMultiple pour les iles (utilisable pour les lacs :
27 % dépassement metapost ?)
28
29 prologues:=2;
30
31 input geometriesyr16;
32
33 vardef Projgeo(expr X)=
34   pair $;
35   numeric Xobs,Yobs,Zobs,XProj,YProj;
36   Xobs = -redpart(X)*Aux1 + greenpart(X)*Aux3;
37   Yobs = -redpart(X)*Aux5 - greenpart(X)*Aux6 + bluepart(X)*Aux4;
38   Zobs = -redpart(X)*Aux7 - greenpart(X)*Aux8 - bluepart(X)*Aux2 + Rho;
39   XProj = DE*Xobs/Zobs;
40   YProj = DE*Yobs/Zobs;
41   $=(XProj,YProj);
42   $
43 enddef;
44
45 vardef FX(expr t,v)=ray*cosd(c*t)*cosd(c*v)
46 enddef;
47
48 vardef FY(expr t,v)=ray*cosd(c*t)*sind(c*v)
49 enddef;
50
51 vardef FZ(expr t,v)=ray*sind(c*t)
52 enddef;
53
54 vardef arcsind(expr x)=%Définition mathématique en degré ici :)
55   angle((sqrt(1-x**2),x))
56 enddef;
57
58 numeric nbpts;
59
60 vardef lecture(expr nomfichier,fond)=
61   color Coord[];
62   numeric ll;
63   ll:=0;
64   color Pays[];
65   nbpts:=scantokens readfrom nomfichier;
66   for k=1 upto nbpts:
67     pair latlon;
68     latlon=scantokens readfrom nomfichier;
69     Coord[k]=ray*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),
70         cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
71     if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
72       if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
73         ll:=ll+1;
74         Pays[k]=Coord[k];
75       else:
76         Pays[k]=2*Coord[k];
77       fi;
78     else:
79       Pays[k]=2*Coord[k];
80     fi;
81   endfor;
82   closefrom nomfichier;
83   path pays;
84   if ll>0:
85     pays=Projgeo(Pays[1])
86     for l=2 upto nbpts:
87       --Projgeo(Pays[l])
88     endfor;
89     remplis pays--cycle withcolor fond;
90     trace pays;
91     clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
92   fi;
93 enddef;
94
95 vardef lecturemanuel(expr nomfichier,fond)=
96   color Coord[];
97   numeric ll;
98   ll:=0;
99   color Pays[];
100   nbpts:=scantokens readfrom nomfichier;
101   for k=1 upto nbpts:
102     pair latlon;
103     latlon=scantokens readfrom nomfichier;
104     Coord[k]=ray*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),
105         cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
106     if ((xpart(latlon/60)>phim) and (xpart(latlon/60)<phip)):
107       if ProduitScalaire(Coord[k]-pte3,Oeil-pte3)>0:
108         ll:=ll+1;
109         Pays[k]=Coord[k];
110       else:
111         Pays[k]=2*Coord[k];
112       fi;
113     else:
114       Pays[k]=2*Coord[k];
115     fi;
116   endfor;
117   closefrom nomfichier;
118   path pays;
119   if ll>0:
120     pays=Projgeo(Pays[1])
121     for l=2 upto nbpts:
122       --Projgeo(Pays[l])
123     endfor;
124     remplis pays--cycle withcolor fond;
125     trace pays;
126     %clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
127   fi;
128 enddef;
129
130 vardef lectureexemple(expr nomfichier,fond)=
131   color Coord[];
132   numeric ll;
133   ll:=0;
134   color Pays[];
135   nbpts:=scantokens readfrom nomfichier;
136   for k=1 upto nbpts:
137     pair latlon;
138     latlon=scantokens readfrom nomfichier;
139     Coord[k]=ray*(cosd(xpart(latlon/60))*cosd(ypart(latlon/60)),
140         cosd(xpart(latlon/60))*sind(ypart(latlon/60)),sind(xpart(latlon/60)));
141   endfor;
142   closefrom nomfichier;
143   path pays;
144   pays=Projgeo(Coord[1])
145     for l=2 upto nbpts:
146       --Projgeo(Coord[l])
147     endfor;
148     trace pays dashed evenly;
149     %clip currentpicture to cercles(pte3,pte1,pte3,pte1,pte4);
150 enddef;
151
152
153 ray:=2;
154
155 figureespace(-100u,-100u,100u,100u);
156 Initialisation(5,-115,-10,750);
157 numeric phim,phip,phii;%phi moins -- phi plus - phi intermédiaire
158 phim=Phi+arcsind(ray/Rho)-90;
159 phip=Phi+90-arcsind(ray/Rho);
160 color pte[];
161 pte1=ray*(cosd(phim)*cosd(Theta),cosd(phim)*sind(Theta),sind(phim));
162 pte2=ray*(cosd(phip)*cosd(Theta),cosd(phip)*sind(Theta),sind(phip));
163 pte3=iso(pte1,pte2);
164 pte4-pte3=Normal((0,0,0),pte1,pte2);
165 if (Phi>90):
166   phip:=180-phip;
167   phii:=180-phim;
168   phim:=phip;
169   phip:=phii;
170 fi;
171 if (Phi<-90):
172   phip:=-180-phip;
173   phii:=-180-phim;
174   phim:=phip;
175   phip:=phii;
176 fi;
177 remplis cercles(pte3,pte1,pte3,pte1,pte4) withcolor ciel;
178 %%amerique du sud :) Manque l'arctique.
179 lecturemanuel("../DATA/bresil.dat",vert);
180 trace cercles(pte3,pte1,pte3,pte1,pte4);
181 finespace;
182
183 figureespace(-100u,-100u,100u,100u);
184 Initialisation(5,-115,-10,750);
185 numeric phim,phip,phii;%phi moins -- phi plus - phi intermédiaire
186 phim=Phi+arcsind(ray/Rho)-90;
187 phip=Phi+90-arcsind(ray/Rho);
188 color pte[];
189 pte1=ray*(cosd(phim)*cosd(Theta),cosd(phim)*sind(Theta),sind(phim));
190 pte2=ray*(cosd(phip)*cosd(Theta),cosd(phip)*sind(Theta),sind(phip));
191 pte3=iso(pte1,pte2);
192 pte4-pte3=Normal((0,0,0),pte1,pte2);
193 if (Phi>90):
194   phip:=180-phip;
195   phii:=180-phim;
196   phim:=phip;
197   phip:=phii;
198 fi;
199 if (Phi<-90):
200   phip:=-180-phip;
201   phii:=-180-phim;
202   phim:=phip;
203   phip:=phii;
204 fi;
205 remplis cercles(pte3,pte1,pte3,pte1,pte4) withcolor ciel;
206 %%amerique du sud :) Manque l'arctique.
207 lecture("../DATA/bresil.dat",vert);
208 lectureexemple("../DATA/bresil.dat",noir);
209 trace cercles(pte3,pte1,pte3,pte1,pte4);
210 finespace;
211 end

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.