summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-12-20 22:01:27 +0000
committerKarl Berry <karl@freefriends.org>2013-12-20 22:01:27 +0000
commit3a829135ea9d1afa97670c399f06685f842d6e61 (patch)
tree17d02cbf2c649ddb8e2534c44dfc12406a7dc7a3 /Master/texmf-dist/metapost
parent5ea8fa0cef406b98d720cda6f6b87a033439987b (diff)
repere (20dec13)
git-svn-id: svn://tug.org/texlive/trunk@32455 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r--Master/texmf-dist/metapost/repere/repere.mp1944
1 files changed, 1944 insertions, 0 deletions
diff --git a/Master/texmf-dist/metapost/repere/repere.mp b/Master/texmf-dist/metapost/repere/repere.mp
new file mode 100644
index 00000000000..1d8b70c73a5
--- /dev/null
+++ b/Master/texmf-dist/metapost/repere/repere.mp
@@ -0,0 +1,1944 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% repere.mp %%
+%% Macros pour la construction de figures dans un repère %%
+%% o.peault@gmail.com %%
+%% Version 13.12 (Décembre 2013) %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% This work may be distributed and/or modified under the conditions of
+% the LaTeX Project Public License, either version 1.3 of this license
+% or (at your option) any later version. The latest version of this
+% license is in http://www.latex-project.org/lppl.txt
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+input format;
+
+warningcheck:=0;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% REPERE %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+numeric _nfig,_nbaxes,theta,taillegrad,taillepoint,taillecroix,facteurx,facteury;
+boolean flecheaxe,displayfrac,coupe;
+_nfig:=1;
+path cadre;
+numeric _diag,_largcadre,_hautcadre,_tfig;
+pair _O,_I,_J;
+transform _T;
+picture _axorlab; pair poslabO;
+
+string marque_p,fraction;
+
+facteury:=1;
+
+boolean rep_groupe;
+rep_groupe:=false;
+
+
+let oldbeginfig=beginfig;
+let oldendfig=endfig;
+
+def beginfig(expr c)=
+ oldbeginfig(c);
+ _nfig:=c;
+ rep_groupe:=true
+enddef;
+
+def endfig=
+ oldendfig;
+ _nfig:=_nfig+1;
+ rep_groupe:=false
+enddef;
+
+vardef repere@#(text t)=
+ if (str @#="") or (str @#="larg") or (str @#="orth") or (str @#="prop"):
+% _nfig:=_nfig+1;definitionrepere@#(t)
+ definitionrepere@#(t)
+ else:
+ reperenum@#(t)
+ fi
+enddef;
+
+
+vardef reperenum[]@#(text t)=
+ _nfig:=@;
+ definitionrepere@#(t)
+enddef;
+
+boolean bf;
+bf:=false;
+
+vardef definitionrepere@#(text t) =
+ save i,_def;
+ if not rep_groupe: oldbeginfig(_nfig);bf:=true fi;
+ numeric _def[],i,unitex,unitey,unite;
+ _def[7]:=90;i:=1;
+ for _i=t: _def[i]:=_i; i:=i+1; endfor;
+ Xmin:=_def1; Xmax:=_def2; Ymin:=_def4; Ymax:=_def5; theta:=_def7;
+ if str @#="larg": _def3:=(_def3-_def6*cosd(theta)/sind(theta))/(Xmax-Xmin);_def6:=_def6/((Ymax-Ymin)*sind(theta))
+ elseif str @#="orth": _def3:=_def3/(Xmax-Xmin); _def6:=_def3;theta:=90
+ elseif str @#="prop": _def3:=_def3/(Xmax-Xmin); _def6:=_def6*_def3;theta:=90
+ fi;
+ Ux:=_def3;Uy:=_def6;
+ _T:=identity xscaled Ux yscaled Uy slanted cosd(theta) yscaled sind(theta);
+ _defcadre;
+ settout(Xmin,Xmax,Ymin,Ymax);
+ _O:=_c(0,0); xO:=0 ; yO:=0;
+ _I:=_c(1,0); _J:=_c(0,1);
+ taillegrad:=0.8mm;taillepoint:=3;taillecroix:=1mm;_nbaxes:=0;_axorlab:=nullpicture;poslabO:=(0,0);
+ marque_p := "plein";displayfrac:=false;flecheaxe:=true;coupe:=true;
+ defaultscale:=1;
+ unitex:=abs(_I);unitey:=abs(_J);unite:=unitex;
+ facteurx:=1;facteury:=1;
+ string extranumx,extranumy;
+ extranumx=extranumy="";
+enddef;
+
+def setaxes(expr a,b,c,d)=
+ AxeXmin:=a;AxeXmax:=b;AxeYmin:=c;AxeYmax:=d
+enddef;
+
+def setgrad(expr a,b,c,d)=
+ GradXmin:=a;GradXmax:=b;GradYmin:=c;GradYmax:=d
+enddef;
+
+def setval(expr a,b,c,d)=
+ ValXmin:=a;ValXmax:=b;ValYmin:=c;ValYmax:=d
+enddef;
+
+def setquad(expr a,b,c,d)=
+ QuadXmin:=a;QuadXmax:=b;QuadYmin:=c;QuadYmax:=d
+enddef;
+
+def settout(expr a,b,c,d)=
+ setaxes(a,b,c,d);
+ setgrad(a,b,c,d);
+ setval(a,b,c,d);
+ setquad(a,b,c,d);
+enddef;
+
+let setall=settout;
+
+def fin =
+ if _nbaxes=1: draw _axorlab fi;
+ if coupe: clip currentpicture to cadre fi;
+ if bf: oldendfig; bf:=false;_nfig:=_nfig+1 fi;
+enddef;
+
+def _defcadre=
+ cadre:=_c(Xmin,Ymin)--_c(Xmin,Ymax)--_c(Xmax,Ymax)--_c(Xmax,Ymin)--cycle;
+ _diag:=abs(llcorner cadre - urcorner cadre);
+ _largcadre:=abs(llcorner cadre - lrcorner cadre);
+ _hautcadre:=abs(llcorner cadre - ulcorner cadre);
+ _tfig:=max(_largcadre,_hautcadre); % compatibilité geometriesyr
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% ORIGINE %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+def interaxes(expr a,b) =
+ _O:=_c(a,b);
+ xO:=a;
+ yO:=b;
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% AXES %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+pair _posgradx, _posgradx.lft, _posgradx.rt, _posgradx.ulft, _posgradx.top, _posgradx.urt, _posgradx.llft, _posgradx.bot, _posgradx.lrt;
+_posgradx=_posgradx.bot=_posgradx.lft=_posgradx.rt=-_posgradx.top=(0,-1);
+-_posgradx.llft=_posgradx.urt=(0.5,0.5);_posgradx.lrt=-_posgradx.ulft=(0.5,-0.5);
+
+
+pair _posgrady, _posgrady.lft, _posgrady.rt, _posgrady.ulft, _posgrady.top, _posgrady.urt, _posgrady.llft, _posgrady.bot, _posgrady.lrt;
+_posgrady=_posgrady.bot=_posgrady.lft=_posgrady.top=-_posgrady.rt=(-1,0);
+-_posgrady.llft=_posgrady.urt=(0.5,0.5);_posgrady.lrt=-_posgrady.ulft=(0.5,-0.5);
+
+vardef _etiqx_@#(expr ab,dec,st)= %étiquettes axe des abscisses
+ save pic;
+ picture pic;
+ if numeric st: pic:=LaTeX("$\num{" & decimal(st) & extranumx & "}$")
+ elseif string st: pic:=LaTeX(st)
+ else: pic:=st fi;
+ thelabel.@#(pic,_c(ab,yO) shifted (dec*_posgradx@#))
+enddef;
+
+vardef _etiqy_@#(expr ro,dec,st)= %étiquettes axe des ordonnées
+ save pic;
+ picture pic;
+ if numeric st: pic:=LaTeX("$\num{" & decimal(st) & extranumy & "}$")
+ elseif string st: pic:=LaTeX(st)
+ else: pic:=st fi;
+ thelabel.@#(pic,_c(xO,ro) shifted (dec*_posgrady@#))
+enddef;
+
+
+vardef graduationx(expr x)= %%%%%%% graduation axe des abscisses
+ ((0,taillegrad)--(0,-taillegrad)) rotated (theta-90) shifted _c(x,yO)
+enddef;
+
+
+vardef graduationy(expr y)= %%%%%%% graduation axe des ordonnées
+ ((taillegrad,0)--(-taillegrad,0)) shifted _c(xO,y)
+enddef;
+
+vardef etiquettex@#(expr x)=
+ _etiqx_@#(x,taillegrad,x*facteurx)
+enddef;
+
+
+vardef etiquettey@#(expr y)=
+ _etiqy_@#(y,taillegrad,y*facteury)
+enddef;
+
+
+vardef dessinaxex=_c(AxeXmin,yO)--_c(AxeXmax,yO) enddef;
+
+vardef dessinaxey=_c(xO,AxeYmin)--_c(xO,AxeYmax) enddef;
+
+
+vardef graduationsaxex(expr grad)= %%%% ensemble des graduations abscisses
+ save $;picture $;
+ $=image(%
+ imax:=floor((GradXmax-xO)/grad);imin:=ceiling((GradXmin-xO)/grad);
+ for i=imin upto imax-1:
+ draw graduationx(arrondimil(i*grad)+xO) withpen pencircle scaled 0.5bp;
+ endfor
+ % dernière graduation
+ if AxeXmax*Ux-(imax*grad+xO)*Ux>ahlength: draw graduationx(arrondimil(imax*grad)+xO) withpen pencircle scaled 0.5bp fi);
+ $
+enddef;
+
+vardef graduationsaxey(expr grad)= %%%% ensemble des graduations ordonnées
+ save $;picture $;
+ $=image(%
+ imax:=floor((GradYmax-yO)/grad);imin:=ceiling((GradYmin-yO)/grad);
+ for i=imin upto imax-1:
+ draw graduationy(arrondimil(i*grad)+yO) withpen pencircle scaled 0.5bp;
+ endfor;
+ % dernière graduation
+ if AxeYmax*Uy-(imax*grad+yO)*Uy>ahlength: draw graduationy(arrondimil(imax*grad)+yO) withpen pencircle scaled 0.5bp fi);
+ $
+enddef;
+
+
+vardef etiquettesaxex@#(expr val)= %%% ensemble des étiquettes abscisses
+ save $,imin,imax,labmin,labmax;
+ picture $,labmin,labmax;
+ numeric imin,imax;
+ $=image(%
+ imin:=ceiling((ValXmin-xO)/val);imax:=floor((ValXmax-xO)/val);
+ % définition première étiquette
+ if (imin<>0):
+ labmin:= etiquettex.@#(arrondimil(imin*val)+xO)
+ else: labmin:=nullpicture
+ fi;
+ % définition dernière étiquette
+ if (imax<>0):
+ labmax:= etiquettex.@#(arrondimil(imax*val)+xO)
+ else: labmax:=nullpicture
+ fi;
+ % tracé première étiquette
+ if xpart ((ulcorner labmin) transformed inverse _T)>=Xmin: draw labmin fi;
+ % tracé autres étiquettes
+ for i=imin+1 upto imax-1:
+ if (i<>0):
+ draw etiquettex.@#(arrondimil(i*val)+xO)
+ fi;
+ endfor;
+ % tracé dernière étiquette
+ if xpart ((lrcorner labmax) transformed inverse _T)<=Xmax: draw labmax fi;
+ );
+ $
+enddef;
+
+vardef etiquettesaxey@#(expr val)= %%% ensemble des étiquettes ordonnées
+ save $,imin,imax,labmin,labmax;
+ picture $,labmin,labmax;
+ numeric imin,imax;
+ $=image(%
+ imin:=ceiling((ValYmin-yO)/val);imax:=floor((ValYmax-yO)/val);
+ % définition première étiquette
+ if (imin<>0):
+ labmin:= etiquettey.@#(arrondimil(imin*val)+yO)
+ else: labmin:=nullpicture
+ fi;
+ % définition dernière étiquette
+ if (imax<>0):
+ labmax:= etiquettey.@#(arrondimil(imax*val)+yO)
+ else: labmax:=nullpicture
+ fi;
+ % tracé première étiquette
+ if ypart (llcorner labmin) >=ypart _c(Xmin,Ymin): draw labmin fi;
+ % tracé autres étiquettes
+ for i=imin+1 upto imax-1:
+ if (i<>0):
+ draw etiquettey.@#(arrondimil(i*val)+yO)
+ fi;
+ endfor;
+ % tracé dernière étiquette
+ if ypart (ulcorner labmax) <=ypart _c(Xmax,Ymax): draw labmax fi
+ );
+ $
+enddef;
+
+vardef _axex_@#(expr grad,val,nn)=
+ save $;
+ picture $;
+ $=image(
+ % axe
+ if flecheaxe: drawarrow else: draw fi dessinaxex;
+ % graduations
+ if grad>0: draw graduationsaxex(grad) fi;
+ % étiquettes
+ if val>0:
+ if nn=1:
+ if str @#<>"":
+ draw etiquettesaxex@#(val);
+ _axorlab:=etiquettex@#(xO)
+ else:
+ draw etiquettesaxex.bot(val);
+ _axorlab:=etiquettex.bot(xO)
+ fi;
+ poslabO:=poslabO + unitvector(0,ypart _posgradx@#);
+ if xO<>yO:
+ draw _axorlab
+ elseif _nbaxes=2:
+ draw _etiqx_(xO,0,xO) shifted (0.7*abs(llcorner _axorlab - urcorner _axorlab)*poslabO)
+ fi
+ elseif nn=2:
+ if str @#<>"":
+ draw etiquettesaxex@#(val);
+ draw etiquettex@#(xO)
+ else:
+ draw etiquettesaxex.bot(val);
+ draw etiquettex.bot(xO)
+ fi
+ else:
+ if str @#<>"":
+ draw etiquettesaxex@#(val)
+ else:
+ draw etiquettesaxex.bot(val)
+ fi
+ fi
+ fi
+ );
+ $
+enddef;
+
+vardef _axey_@#(expr grad,val,nn)=
+ save $;
+ picture $;
+ $=image(
+ % axe
+ if flecheaxe: drawarrow else: draw fi dessinaxey;
+ % graduations
+ if grad>0: draw graduationsaxey(grad) fi;
+ % étiquettes
+ if val>0:
+ if nn=1:
+ if str @#<>"":
+ draw etiquettesaxey@#(val);
+ _axorlab:=etiquettey@#(yO)
+ else:
+ draw etiquettesaxey.lft(val);
+ _axorlab:=etiquettey.lft(yO)
+ fi;
+ poslabO:=poslabO + unitvector(xpart _posgrady@#,0);
+ if xO<>yO:
+ draw _axorlab
+ elseif _nbaxes=2:
+ draw _etiqy_(yO,0,yO) shifted (0.7*abs(llcorner _axorlab - urcorner _axorlab)*poslabO)
+ fi
+ elseif nn=2:
+ if str @#<>"":
+ draw etiquettesaxey@#(val);
+ draw etiquettey@#(yO)
+ else:
+ draw etiquettesaxey.lft(val);
+ draw etiquettey.lft(yO)
+ fi
+ else:
+ if str @#<>"":
+ draw etiquettesaxey@#(val)
+ else:
+ draw etiquettesaxey.lft(val)
+ fi
+ fi
+ fi
+ );
+ $
+enddef;
+
+vardef axex@# (expr grad,val)= %%%%%%axe des abscisses avec gestion graduation origine
+ _nbaxes:=_nbaxes+1;
+ _axex_@#(grad,val,1)
+enddef;
+
+vardef axey@# (expr grad,val)= %%%%%%axe des ordonnées avec gestion graduation origine
+ _nbaxes:=_nbaxes+1;
+ _axey_@#(grad,val,1)
+enddef;
+
+vardef axexo@#(expr grad,val)= %%%%%%axe des abscisses avec graduation origine
+ _axex_@#(grad,val,2)
+enddef;
+
+vardef axeyo@#(expr grad,val)= %%%%%%axe des ordonnées avec graduation origine
+ _axey_@#(grad,val,2)
+enddef;
+
+vardef axexn@#(expr grad,val)= %%%%%%axe des abscisses sans graduation origine
+ _axex_@#(grad,val,3)
+enddef;
+
+vardef axeyn@#(expr grad,val)= %%%%%%axe des ordonnées sans graduation origine
+ _axey_@#(grad,val,3)
+enddef;
+
+vardef axes@# (expr grad,val)= %%%% les deux axes
+ save $,posx,posy;
+ picture $;
+ numeric posx,posy;
+ posx:=ypart (_posgradx@#+_posgrady@#);
+ posy:=xpart (_posgradx@#+_posgrady@#);
+ $=image(%
+ if posx>0: draw axex.top(grad,val) else: draw axex.bot(grad,val) fi;
+ if posy>0: draw axey.rt(grad,val) else: draw axey.lft(grad,val) fi
+ );
+ $
+enddef;
+
+vardef axeso@# (expr grad,val)= %%%% les deux axes avec origine
+ save $,posx,posy;
+ picture $;
+ numeric posx,posy;
+ posx:=ypart (_posgradx@#+_posgrady@#);
+ posy:=xpart (_posgradx@#+_posgrady@#);
+ $=image(%
+ if posx>0: draw axexo.top(grad,val) else: draw axexo.bot(grad,val) fi;
+ if posy>0: draw axeyo.rt(grad,val) else: draw axeyo.lft(grad,val) fi
+ );
+ $
+enddef;
+
+vardef axesn@# (expr grad,val)= %%%% les deux axes sans origine
+ save $,posx,posy;
+ picture $;
+ numeric posx,posy;
+ posx:=ypart (_posgradx@#+_posgrady@#);
+ posy:=xpart (_posgradx@#+_posgrady@#);
+ $=image(%
+ if posx>0: draw axexn.top(grad,val) else: draw axexn.bot(grad,val) fi;
+ if posy>0: draw axeyn.rt(grad,val) else: draw axeyn.lft(grad,val) fi
+ );
+ $
+enddef;
+
+% axes gradués avec multiples de pi
+
+vardef fracmulttext(expr n,d,tt)= %%%% construction de la fraction n*tt/d
+ save nn,dd,s,fr,$,fraction;
+ string s,fr,fraction;
+ picture $;
+ numeric nn,dd;
+ nn:=abs((n)/pgcd(n,d));dd:=d/pgcd(n,d);
+ if displayfrac:
+ fraction:="d"
+ else: fraction:=""
+ fi;
+ if dd=1:
+ if nn=1:
+ fr:=tt
+ else: fr:=decimal nn & tt
+ fi
+ else:
+ if nn=1:
+ fr:="\" & fraction & "frac{" & tt & "}{" & decimal dd & "}"
+ else: fr:="\" & fraction & "frac{" & decimal nn & tt & "}{" & decimal dd & "}"
+ fi
+ fi;
+ if n<0:
+ s:="-"
+ else: s:="";
+ if n=0:
+ fr:= "0"
+ fi
+ fi;
+ $=LaTeX("$" & s & fr & "$");
+ $
+enddef;
+
+vardef fracmultpi(expr n,d)=
+ fracmulttext(n,d,"\pi")
+enddef;
+
+
+vardef etiquettexpi@#(expr n,d)=
+ _etiqx_@#(n*pi/d,taillegrad,fracmultpi(n,d))
+enddef;
+
+vardef etiquetteypi@#(expr n,d)=
+ _etiqy_@#(n*pi/d,taillegrad,fracmultpi(n,d))
+enddef;
+
+
+vardef etiquettesaxexpi@#(expr n,d)= %%% ensemble des étiquettes multiples de pi abscisses
+ save $,imin,imax,labmin,labmax,val;
+ picture $,labmin,labmax;
+ numeric imin,imax,val;
+ val:=n*pi/d;
+ $=image(%
+ imin:=ceiling((ValXmin-xO)/val);imax:=floor((ValXmax-xO)/val);
+ % définition première étiquette
+ if (imin<>0):
+ labmin:= etiquettexpi.@#(imin*n,d)
+ else: labmin:=nullpicture
+ fi;
+ % définition dernière étiquette
+ if (imax<>0):
+ labmax:= etiquettexpi.@#(imax*n,d)
+ else: labmax:=nullpicture
+ fi;
+ % tracé première étiquette
+ if xpart ((ulcorner labmin) transformed inverse _T)>=Xmin: draw labmin fi;
+ % tracé autres étiquettes
+ for i=imin+1 upto imax-1:
+ if (i<>0):
+ draw etiquettexpi.@#(i*n,d)
+ fi;
+ endfor;
+ % tracé dernière étiquette
+ if xpart ((lrcorner labmax) transformed inverse _T)<=Xmax: draw labmax fi;
+ );
+ $
+enddef;
+
+vardef etiquettesaxeypi@#(expr n,d)= %%% ensemble des étiquettes multiples de pi ordonnées
+ save $,imin,imax,labmin,labmax,val;
+ picture $,labmin,labmax;
+ numeric imin,imax,val;
+ val:=n*pi/d;
+ $=image(%
+ imin:=ceiling((ValYmin-yO)/val);imax:=floor((ValYmax-yO)/val);
+ % définition première étiquette
+ if (imin<>0):
+ labmin:= etiquetteypi.@#(imin*n,d)
+ else: labmin:=nullpicture
+ fi;
+ % définition dernière étiquette
+ if (imax<>0):
+ labmax:= etiquetteypi.@#(imax*n,d)
+ else: labmax:=nullpicture
+ fi;
+ % tracé première étiquette
+ if ypart (llcorner labmin) >=ypart _c(Xmin,Ymin): draw labmin fi;
+ % tracé autres étiquettes
+ for i=imin+1 upto imax-1:
+ if (i<>0):
+ draw etiquetteypi.@#(i*n,d)
+ fi;
+ endfor;
+ % tracé dernière étiquette
+ if ypart (ulcorner labmax) <=ypart _c(Xmax,Ymax): draw labmax fi
+ );
+ $
+enddef;
+
+vardef _axexpi_@#(expr num,den,nn)=
+ save $,grad;
+ numeric grad;
+ picture $;
+ grad:=num*pi/den;
+ $=image(
+ % axe
+ if flecheaxe: drawarrow else: draw fi dessinaxex;
+ % graduations
+ if grad>0: draw graduationsaxex(grad) fi;
+ % étiquettes
+ if nn=1:
+ if str @#<>"":
+ draw etiquettesaxexpi@#(num,den);
+ _axorlab:=etiquettexpi@#(xO/pi,1)
+ else:
+ draw etiquettesaxexpi.bot(num,den);
+ _axorlab:=etiquettexpi.bot(xO/pi,1)
+ fi;
+ poslabO:=poslabO + unitvector(0,ypart _posgradx@#);
+ if xO<>yO:
+ draw _axorlab
+ elseif _nbaxes=2:
+ draw _etiqx_(xO,0,fracmultpi(xO/pi,1)) shifted (0.7*abs(llcorner _axorlab - urcorner _axorlab)*poslabO)
+ fi
+ elseif nn=2:
+ if str @#<>"":
+ draw etiquettesaxexpi@#(num,den);
+ draw etiquettexpi@#(xO/pi,1)
+ else:
+ draw etiquettesaxexpi.bot(num,den);
+ draw etiquettexpi.bot(xO/pi,1)
+ fi
+ else:
+ if str @#<>"":
+ draw etiquettesaxexpi@#(num,den)
+ else:
+ draw etiquettesaxexpi.bot(num,den)
+ fi
+ fi
+ );
+ $
+enddef;
+
+vardef _axeypi_@#(expr num,den,nn)=
+ save $,grad;
+ numeric grad;
+ picture $;
+ grad:=num*pi/den;
+ $=image(
+ % axe
+ if flecheaxe: drawarrow else: draw fi dessinaxey;
+ % graduations
+ if grad>0: draw graduationsaxey(grad) fi;
+ % étiquettes
+ if nn=1:
+ if str @#<>"":
+ draw etiquettesaxeypi@#(num,den);
+ _axorlab:=etiquetteypi@#(yO/pi,1)
+ else:
+ draw etiquettesaxeypi.lft(num,den);
+ _axorlab:=etiquetteypi.lft(yO/pi,1)
+ fi;
+ poslabO:=poslabO + unitvector(xpart _posgrady@#,0);
+ if xO<>yO:
+ draw _axorlab
+ elseif _nbaxes=2:
+ draw _etiqy_(yO,0,fracmultpi(yO/pi,1)) shifted (0.7*abs(llcorner _axorlab - urcorner _axorlab)*poslabO)
+% draw _etiqy_(yO,0,yO) shifted (0.7*abs(llcorner _axorlab - urcorner _axorlab)*poslabO)
+ fi
+ elseif nn=2:
+ if str @#<>"":
+ draw etiquettesaxeypi@#(num,den);
+ draw etiquetteypi@#(yO/pi,1)
+ else:
+ draw etiquettesaxeypi.lft(num,den);
+ draw etiquetteypi.lft(yO/pi,1)
+ fi
+ else:
+ if str @#<>"":
+ draw etiquettesaxeypi@#(num,den)
+ else:
+ draw etiquettesaxeypi.lft(num,den)
+ fi
+ fi
+ );
+ $
+enddef;
+
+vardef axexpi@# (expr n,d)= %%%%%%axe des abscisses avec gestion graduation origine mult pi
+ _nbaxes:=_nbaxes+1;
+ _axexpi_@#(n,d,1)
+enddef;
+
+vardef axeypi@# (expr n,d)= %%%%%%axe des ordonnées avec gestion graduation origine mult pi
+ _nbaxes:=_nbaxes+1;
+ _axeypi_@#(n,d,1)
+enddef;
+
+vardef axexpio@#(expr n,d)= %%%%%%axe des abscisses avec graduation origine mult pi
+ _axexpi_@#(n,d,2)
+enddef;
+
+vardef axeypio@#(expr n,d)= %%%%%%axe des ordonnées avec graduation origine mult pi
+ _axeypi_@#(n,d,2)
+enddef;
+
+vardef axexpin@#(expr n,d)= %%%%%%axe des abscisses sans graduation origine mult pi
+ _axexpi_@#(n,d,3)
+enddef;
+
+vardef axeypin@#(expr grad,val)= %%%%%%axe des ordonnées sans graduation origine mult pi
+ _axeypi_@#(n,d,3)
+enddef;
+
+vardef axespi@# (expr n,d)= %%%% les deux axes mult pi
+ save $,posx,posy;
+ picture $;
+ numeric posx,posy;
+ posx:=ypart (_posgradx@#+_posgrady@#);
+ posy:=xpart (_posgradx@#+_posgrady@#);
+ $=image(%
+ if posx>0: draw axexpi.top(n,d) else: draw axexpi.bot(n,d) fi;
+ if posy>0: draw axeypi.rt(n,d) else: draw axeypi.lft(n,d) fi
+ );
+ $
+enddef;
+
+vardef axespio@# (expr n,d)= %%%% les deux axes avec origine mult pi
+ save $,posx,posy;
+ picture $;
+ numeric posx,posy;
+ posx:=ypart (_posgradx@#+_posgrady@#);
+ posy:=xpart (_posgradx@#+_posgrady@#);
+ $=image(%
+ if posx>0: draw axexpio.top(n,d) else: draw axexpio.bot(n,d) fi;
+ if posy>0: draw axeypio.rt(n,d) else: draw axeypio.lft(n,d) fi
+ );
+ $
+enddef;
+
+vardef axespin@# (expr n,d)= %%%% les deux axes sans origine mult pi
+ save $,posx,posy;
+ picture $;
+ numeric posx,posy;
+ posx:=ypart (_posgradx@#+_posgrady@#);
+ posy:=xpart (_posgradx@#+_posgrady@#);
+ $=image(%
+ if posx>0: draw axexpin.top(n,d) else: draw axexpin.bot(n,d) fi;
+ if posy>0: draw axeypin.rt(n,d) else: draw axeypin.lft(n,d) fi
+ );
+ $
+enddef;
+
+
+%%%%%%%% graduations isolées
+
+vardef axexpart@#(text t)=
+ save $,tmp,var;
+ picture $;
+ numeric tmp;
+ boolean var;
+ var:=false;
+ $=image(%
+ for _i=t:
+ if numeric _i:
+ if var: if str @#="": draw _etiqx_.bot(tmp,taillegrad,tmp) else: draw _etiqx_@#(tmp,taillegrad,tmp) fi fi;
+% draw ((0,taillegrad)--(0,-taillegrad)) shifted _c(_i,yO) withpen pencircle scaled 0.8bp;
+ draw graduationx(_i) withpen pencircle scaled 0.8bp;
+ tmp:=_i;
+ var:=true
+ else:
+ if str @#="": draw _etiqx_.bot(tmp,taillegrad,_i) else: draw _etiqx_@#(tmp,taillegrad,_i) fi;
+ var:=false
+ fi;
+ endfor;
+ if var: if str @#="": draw _etiqx_.bot(tmp,taillegrad,tmp) else: draw _etiqx_@#(tmp,taillegrad,tmp) fi fi);
+ $
+enddef;
+
+vardef axeypart@#(text t)=
+ save $,tmp,var;
+ picture $;
+ numeric tmp;
+ boolean var;
+ var:=false;
+ $=image(%
+ for _i=t:
+ if numeric _i:
+ if var: if str @#="": draw _etiqy_.lft(tmp,taillegrad,tmp) else: draw _etiqy_@#(tmp,taillegrad,tmp) fi fi;
+ draw ((taillegrad,0)--(-taillegrad,0)) shifted _c(xO,_i) withpen pencircle scaled 0.8bp;
+ tmp:=_i;
+ var:=true
+ else:
+ if str @#="": draw _etiqy_.lft(tmp,taillegrad,_i) else: draw _etiqy_@#(tmp,taillegrad,_i) fi;
+ var:=false
+ fi;
+ endfor;
+ if var: if str @#="": draw _etiqy_.lft(tmp,taillegrad,tmp) else: draw _etiqy_@#(tmp,taillegrad,tmp) fi fi);
+ $
+enddef;
+
+
+vardef axesunit=
+ save $;
+ picture $;
+ $=image(%
+ draw axes(0,0);
+ draw axexpart(1);
+ draw axeypart(1);
+ label.llft(LaTeX("$0$"),_c(0,0));
+ % label.llft("0",_c(0,0));
+ );
+ $
+enddef;
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% POINTS - VECTEURS %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef _ccoord(expr xA,yA)=
+ (xA,yA) transformed _T
+enddef;
+
+vardef _cobjet(expr obj)=
+ obj transformed _T
+enddef;
+
+vardef _c(text t)=
+ if long_texte(t)=2: _ccoord(t)
+ else: _cobjet(t)
+ fi
+enddef;
+
+vardef pol(expr r,theta)=
+ _c(r*cos(theta),r*sin(theta))
+enddef;
+
+vardef pold(expr r,theta)=
+ _c(r*cosd(theta),r*sind(theta))
+enddef;
+
+color coulpoint,coullabel,coullabelfonc;
+coulpoint:=black;coullabel:=black;coullabelfonc:=black;
+
+
+vardef MarquePointFig(expr pp)= % compatibilité geometriesyr15
+ save $;
+ picture $;
+ if marque_p = "plein":
+ $:=image(fill fullcircle scaled taillepoint shifted pp withcolor coulpoint);
+ elseif marque_p = "creux":
+ $:=image(%
+ fill fullcircle scaled taillepoint shifted pp withcolor background;
+ draw fullcircle scaled taillepoint shifted pp withcolor coulpoint);
+ elseif marque_p = "croix":
+ $:=image(%
+ draw ((-taillecroix,0)--(taillecroix,0)) shifted pp withcolor coulpoint;
+ draw ((0,-taillecroix)--(0,taillecroix)) shifted pp withcolor coulpoint)
+ else: $:=nullpicture
+ fi;
+ $
+enddef;
+
+def MarquePoint(expr pp)= % compatibilité geometriesyr15
+ draw MarquePointFig(pp)
+enddef;
+
+
+vardef pointe(text t) = %geometriesyr15
+ for p_ = t: if pair p_: MarquePoint(p_); fi endfor;
+enddef;
+
+
+vardef nommepoint@#(text t)=
+ save $,ch,dess,latch;
+ pair $;
+ string ch,latch;
+ picture dess;
+ if long_texte(t)=1:
+ dess:=image(draw MarquePointFig(t);
+ ch:=_chaine(t);
+ label@#(LaTeX("$" & ch & "$"),t) withcolor coullabel)
+ else:
+ dess:=image(%
+ for PP=t:
+ if pair PP: MarquePoint(PP); $:=PP
+ else: if string PP: label@#(PP,$) else: label@#(PP scaled defaultscale,$) fi withcolor coullabel
+ fi;
+ endfor)
+ fi;
+ dess
+enddef;
+
+vardef nommecourbe@#(suffix p)(text t)=
+ save A,ch,dess;
+ pair A;
+ string ch;
+ picture dess;
+ if long_texte(t)=1:
+ dess:=image(ch:=_chaine(p);
+ A:=_c(t,fonccourbe.p(t));
+ label@#(LaTeX("$" & ch & "$"),A) withcolor coullabelfonc)
+ else:
+ dess:=image(%
+ for _a=t:
+ if numeric _a: A:=_c(_a,fonccourbe.p(_a))
+ else: if string _a: label@#(_a,A) else: label@#(_a scaled defaultscale,A) fi withcolor coullabelfonc
+ fi;
+ endfor)
+ fi;
+ dess
+enddef;
+
+
+
+vardef nommeobj@#(text t)=
+ save $;
+ picture $;
+ for i=t:
+ if pair i: $:=nommepoint@#(t)
+ else: $:=nommecourbe@#(t)
+ fi;
+ exitif true;
+ endfor
+ $
+enddef;
+
+def nomme = draw nommeobj enddef;
+
+
+vardef vecteur@#(expr A)(text t)=
+ save $,ch,m;
+ picture $;
+ pair m;
+ string ch;
+ $=image(%
+ if long_texte(t)=1: drawarrow A--A+t;ch:=_chaine(t);label@#(LaTeX("$\vect{" & ijmath(ch) & "}$"),A+t/2)
+ else:
+ for u=t:
+ if pair u: drawarrow A--A+u; m:=A+u/2
+ else: if string u: if u<>"": label@#(LaTeX("$\vect{" & u & "}$"),m) fi else: label@#(u,m) fi
+ fi;
+ endfor
+ fi);
+ $
+enddef;
+
+vardef marquepointcourbefig(suffix p)(text t)=
+ save $;
+ picture $;
+ $=image(%
+ for i=t:
+ MarquePoint(_c(i,fonccourbe.p(i)));
+ endfor);
+ $
+enddef;
+
+def marquepointcourbe= draw marquepointcourbefig enddef;
+
+vardef marquepointcheminfig(suffix p)(text t)=
+ save $;
+ picture $;
+ $=image(%
+ for i=t:
+ MarquePoint(point i of p);
+ endfor);
+ $
+enddef;
+
+def marquepointchemin= draw marquepointcheminfig enddef;
+
+vardef marquecheminouvertdroitefig(expr p)=
+ halfcircle shifted (0,-0.5)
+ scaled (2*taillepoint)
+ rotated (90+angle(direction infinity of p))
+ shifted (point infinity of p)
+enddef;
+
+def marquecheminouvertdroite= draw marquecheminouvertdroitefig enddef;
+
+vardef marquecheminouvertgauchefig(expr p)=
+ halfcircle shifted (0,-0.5)
+ scaled (2*taillepoint)
+ rotated (-90+angle(direction 0 of p))
+ shifted (point 0 of p)
+enddef;
+
+def marquecheminouvertgauche= draw marquecheminouvertgauchefig enddef;
+
+vardef marquecheminouvert(expr p)=
+ marquecheminouvertdroite(p);
+ marquecheminouvertgauche(p)
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% BASE %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef ijmath(suffix s)=
+ if (substring (0,1) of s)="i": s:="\imath" & substring (1,infinity) of s fi;
+ if (substring (0,1) of s)="j": s:="\jmath" & substring (1,infinity) of s fi;
+ s
+enddef;
+
+
+color coulbase;
+coulbase:=black;
+
+vardef base(suffix a,b,c)=
+ save O,I,J,$;
+ string O,I,J;
+ picture $;
+ O:=_chaine(a); I:=_chaine(b); J:=_chaine(c);
+ $:=image(%
+ draw vecteur.bot(_O,_c(1,0),ijmath(I)) withpen pencircle scaled 0.8 withcolor coulbase;
+ draw vecteur.lft(_O,_c(0,1),ijmath(J)) withpen pencircle scaled 0.8 withcolor coulbase;
+ nomme.llft(_O,LaTeX("$" & O & "$")) withcolor coulbase
+ );
+ $
+enddef;
+
+
+vardef basep(suffix a,b,c)=
+ save O,I,J,$;
+ string O,I,J;
+ picture $;
+ O:=_chaine(a); I:=_chaine(b); J:=_chaine(c);
+ $:=image(%
+ nomme.llft(_O,LaTeX("$" & O & "$")) withcolor coulbase;
+ draw axexpart(1,LaTeX("$" & I & "$")) withcolor coulbase;
+ draw axeypart(1,LaTeX("$" & J & "$")) withcolor coulbase;
+ );
+ $
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% QUADRILLAGE %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ numeric ep; color coul;
+ ep:= .2bp; %%%%%%%% épaisseur du trait
+ coul := .7white; %%%%%%%% couleur du trait
+ def quadstyle= enddef;
+
+ vardef quadrillage(expr quadx,quady) =
+ save $;
+ picture $;
+ $=image(if quadx>0:
+ for i=ceiling((QuadXmin-xO)/quadx) upto floor((QuadXmax-xO)/quadx):
+ draw _c(arrondimil(i*quadx)+xO,QuadYmin)--_c(arrondimil(i*quadx)+xO,QuadYmax) quadstyle withpen pencircle scaled ep withcolor coul;
+ endfor;
+ fi;
+ if quady>0:
+ for i=ceiling((QuadYmin-yO)/quady) upto floor((QuadYmax-yO)/quady):
+ draw _c(QuadXmin,arrondimil(i*quady)+yO)--_c(QuadXmax,arrondimil(i*quady)+yO) withpen pencircle scaled ep withcolor coul quadstyle;
+ endfor;
+ fi);
+ $
+ enddef;
+
+ vardef papierpointe(expr quadx,quady) =
+ save $;
+ picture $;
+ $=image(if (quadx>0) and (quady>0):
+ for i=ceiling(QuadXmin/quadx) upto floor(QuadXmax/quadx):
+ for j=ceiling(QuadYmin/quady) upto floor(QuadYmax/quady):
+ draw (0,0) shifted _c(i*quadx,j*quady) withpen pencircle scaled 2;
+ endfor;
+ endfor;
+ fi);
+ $
+ enddef;
+
+ numeric pm_epa, pm_epb, pm_epc;
+ color pm_coula, pm_coulb, pm_coulc;
+ pm_epa := .2bp; pm_epb := .3bp; pm_epc := .4bp; %%%%%%%%%% épaisseurs des traits
+ pm_coula := .6*white; pm_coulb := .4*white; pm_coulc := black; %%%%%%%%%% couleurs des traits
+
+vardef papiermillimetre =
+ save $;
+ picture $;
+ $=image(%
+ for i= ceiling(QuadXmin*Ux*10/cm) upto floor(QuadXmax*Ux*10/cm):
+ if i mod 5 <> 0: draw (i*cm/10,QuadYmin*Uy)--(i*cm/10,QuadYmax*Uy) withpen pencircle scaled pm_epa withcolor pm_coula fi;
+ endfor
+ for i= ceiling(QuadYmin*Uy*10/cm) upto floor(QuadYmax*Uy*10/cm):
+ if i mod 5<> 0: draw (QuadXmin*Ux,i*cm/10)--(QuadXmax*Ux,i*cm/10) withpen pencircle scaled pm_epa withcolor pm_coula fi;
+ endfor
+ %
+ for i= ceiling(QuadXmin*Ux/cm)*2+1 step 2 until floor(QuadXmax*Ux/cm)*2-1:
+ draw (i*cm/2,QuadYmin*Uy)--(i*cm/2,QuadYmax*Uy) withpen pencircle scaled pm_epb withcolor pm_coulb;
+ endfor
+ for i= ceiling(QuadYmin*Uy/cm)*2+1 step 2 until floor(QuadYmax*Uy/cm)*2-1:
+ draw (QuadXmin*Ux,i*cm/2)--(QuadXmax*Ux,i*cm/2) withpen pencircle scaled pm_epb withcolor pm_coulb;
+ endfor
+ %
+ for i= ceiling(QuadXmin*Ux/cm) upto floor(QuadXmax*Ux/cm):
+ draw (i*cm,QuadYmin*Uy)--(i*cm,QuadYmax*Uy) withpen pencircle scaled pm_epc withcolor pm_coulc;
+ endfor
+ for i= ceiling(QuadYmin*Uy/cm) upto floor(QuadYmax*Uy/cm):
+ draw (QuadXmin*Ux,i*cm)--(QuadXmax*Ux,i*cm) withpen pencircle scaled pm_epc withcolor pm_coulc;
+ endfor);
+ $
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% FONCTIONS - COURBES %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+vardef courbefonc(suffix f)(expr xmin, xmax, n) = %Courbe représentative d'une fonction
+ save $,x;
+ path $;
+ $=( _c(xmin,f(xmin))
+ for i=1 upto n-1:
+ .._c(xmin+i*(xmax-xmin)/(n-1),f(xmin+i*(xmax-xmin)/(n-1)))
+ endfor );
+ $
+enddef;
+
+%%%%%%%%%% TEST %%%%%%%%%%%%%
+vardef courbefonct@#(expr xmin, xmax, n) = %Courbe représentative d'une fonction
+ save $,x;
+ path $;
+ $=( _c(xmin,@#(xmin))
+ for i=1 upto n-1:
+ .._c(xmin+i*(xmax-xmin)/(n-1),@#(xmin+i*(xmax-xmin)/(n-1)))
+ endfor );
+ $
+enddef;
+%%%%%%%%%% FINTEST %%%%%%%%%%%%%
+
+vardef courbepoints(suffix f)(expr xmin, xmax, n) = %Points non reliés
+ save $,x;
+ picture $;
+ $=image(MarquePoint(_c(xmin,f(xmin)));
+ for i=1 upto n-1:
+ MarquePoint(_c(xmin+i*(xmax-xmin)/(n-1),f(xmin+i*(xmax-xmin)/(n-1))));
+ endfor );
+ $
+enddef;
+
+vardef fonccourbe@#(expr x)= %Ordonnée du point de la courbe @# d'abscisse x (dans le repère utilisateur)
+ ypart ((pointcourbe@#(x)) transformed inverse _T)
+enddef;
+
+vardef pointcourbe@#(expr x)= %Point de la courbe @# d'abscisse x dans le repère utilisateur
+save _P_,t;
+ numeric t; pair _P_;
+ (t,whatever)=@# intersectiontimes (_c(x,2*Ymin-Ymax)--_c(x,2*Ymax-Ymin));
+ if t=-1: _P_:=_c(x,0)
+ else: _P_:=point t of @#
+ fi;
+ _P_
+enddef;
+
+vardef der@#(expr x)= %Fonction dérivée
+ save pp,t,v,w,d;
+ path pp;
+ pair v,w;
+ pp:=@#;
+ (t,whatever) = pp intersectiontimes (_c(x,2*Ymin-Ymax)--_c(x,2*Ymax-Ymin));
+ v:=direction t of pp;
+ w:=unitvector(v transformed inverse _T);
+ if xpart w = 0: d:=0 else: d:= (ypart w)/(xpart w) fi;
+ d
+enddef;
+
+vardef intercourbes(suffix P)(expr p,q)= %renvoie les points d'intersections de p et q dans P[]
+ save i,pp;
+ numeric i;
+ path pp;
+ pp:=p;
+ i:=1;
+ forever:
+ exitif xpart(pp intersectiontimes q)=-1;
+ P[i]:=point xpart(pp intersectiontimes q) of pp;
+ pp:=subpath(xpart(pp intersectiontimes q)+0.01,length pp) of pp;
+ %0.01(?!) pour que le point trouvé ne soit pas dans le sous-chemin...
+ i:=i+1;
+ endfor;
+enddef;
+
+vardef ptantecedents(suffix P)(expr y,p)=
+ intercourbes(P,_c(Xmin,y)--_c(Xmax,y),p)
+enddef;
+
+vardef antecedents(suffix P)(expr y,p)=
+ pair PP[];
+ ptantecedents(PP,y,p);
+ for i=1 upto 10: P[i]:=xpart (PP[i] transformed inverse _T); endfor
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% TANGENTES %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+numeric longtan;
+longtan:=20;
+
+vardef tangentefleche@# (suffix p)(text tt) =
+ save t,$,pp,i,N;
+pair senstan.gauche,senstan.droite,senstan.double;
+senstan.gauche=(1,0);senstan.droite=(0,1);senstan.double=(1,1);
+ numeric N[],i;
+ i:=0;
+ pair _v,M;
+ picture $;
+ for n=tt: i:=incr i ; N[i]:=n; endfor;
+ if i=1: N2:=longtan fi;
+ (t,whatever) = p intersectiontimes (_c(N1,Ymin)--_c(N1,Ymax));
+ M:=point t of p;
+ _v:=N2*unitvector(direction t of p);
+ $=image(%
+ MarquePoint(M);
+ if (xpart senstan@#) <> 0: drawarrow M--M-_v*(xpart senstan@#) fi;
+ if (ypart senstan@#) <> 0: drawarrow M--M+_v*(ypart senstan@#) fi;
+ );
+ $
+enddef;
+
+vardef tangentedroite(expr p,a) =
+ save $,m,M,t;
+ path $;
+ numeric m,t;
+ pair M;
+ (t,whatever) = p intersectiontimes (_c(a,Ymin)--_c(a,Ymax));
+ M:=point t of p;
+ $=M-_diag*unitvector(direction t of p)--M+_diag*unitvector(direction t of p);
+ $
+enddef;
+
+vardef tangente@#(suffix p)(text tt) =
+ if str @#="": tangentedroite(p)(tt)
+ else: tangentefleche@#(p)(tt)
+ fi
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% CALCUL INTÉGRAL %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+vardef entrecourbes(expr p,q,xmin,xmax)=
+ buildcycle(droiteeqx(xmax),p,droiteeqx(xmin),q)
+enddef;
+
+vardef souscourbe(expr p,xmin,xmax)=
+ buildcycle(droiteeqx(xmax),p,droiteeqx(xmin),_c(Xmin,0)--_c(Xmax,0))
+enddef;
+
+
+vardef rectangles@#(suffix p)(expr a,b,n)= %Riemann, renvoie un chemin fermé
+ save pas,_rect_;
+ numeric pas;
+ path _rect_;
+ pas=(b-a)/n;
+ _rect_ =
+ for i=0 upto n-1:
+ _c(a+i*pas,yO)--_segmrect_@#(p,a+i*pas,pas)--
+ endfor
+ _c(b,yO)--cycle;
+ _rect_
+enddef;
+
+numeric _typerect.min,_typerect.max,_typerect.droite,_typerect.gauche;
+_typerect.min=1;_typerect.max=2;_typerect.droite=3;_typerect.gauche=4;
+
+vardef _segmrect_@#(suffix p)(expr a,pas)=
+ save _sousp;
+ path _sousp;
+ _sousp=subpath (xpart(p intersectiontimes droiteeqx(a)),xpart(p intersectiontimes droiteeqx(a+pas))) of p;
+ if _typerect@#=1: llcorner _sousp -- lrcorner _sousp
+ elseif _typerect@#=2: ulcorner _sousp -- urcorner _sousp
+ elseif _typerect@#=3: (pointcourbe.p(a))--(pointcourbe.p(a) shifted _c(pas,0))
+ elseif _typerect@#=4: (pointcourbe.p(a+pas) shifted _c(-pas,0))--(pointcourbe.p(a+pas))
+ fi
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% DROITES %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef droiteeqred(expr a,b)=
+ save $;
+ path $;
+ if (-(Ymax-Ymin)/(Xmax-Xmin)<a) and ((Ymax-Ymin)/(Xmax-Xmin)>a):
+ $:=_c(Xmin,a*Xmin+b)--_c(Xmax,a*Xmax+b);
+ else:
+ $:=_c(Ymin/a-b/a,Ymin)--_c(Ymax/a-b/a,Ymax);
+ fi;
+ $
+enddef;
+
+vardef droiteeqx(expr c)=
+ _c(c,2*Ymin-Ymax)--_c(c,2*Ymax-Ymin)
+enddef;
+
+vardef droiteeqcart(expr a,b,c)=
+ save $;
+ path $;
+ if b=0:
+ $=droiteeqx(-c/a)
+ else:
+ $:=droiteeqred(-a/b,-c/b)
+ fi;
+ $
+enddef;
+
+vardef droiteeq(text t)=
+ save $;
+ path $;
+ if long_texte(t)=1: $:= droiteeqx(t) fi;
+ if long_texte(t)=2: $:= droiteeqred(t) fi;
+ if long_texte(t)=3: $:= droiteeqcart(t) fi;
+ $
+enddef;
+
+
+vardef droitept(expr A,B)= %geometrie15syr
+ (_diag/abs(A-B))[B,A]--(_diag/abs(A-B))[A,B]
+enddef;
+
+vardef droite(text t)=
+ save $;
+ path $;
+ for i=t:
+ if pair i: $:=droitept(t) else: $:=droiteeq(t) fi;
+ exitif true;
+ endfor;
+ $
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% DEMI-PLANS %%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+vardef demiplaninf(expr d)=
+ save $,A,B;
+ path $;
+ pair A,B;
+ if (point 0 of d) yscaled -1 < (point infinity of d) yscaled -1:
+ A:=point 0 of d; B:= point infinity of d
+ else: B:=point 0 of d; A:= point infinity of d
+ fi;
+ $=A--
+ if ypart A>=ypart _c(Xmin,Ymax): _c(Xmin,Ymax)-- fi
+ if ypart A>ypart _c(Xmin,Ymin): _c(Xmin,Ymin)-- fi
+ if ypart B>ypart _c(Xmax,Ymin): _c(Xmax,Ymin)-- fi
+ if ypart B>=ypart _c(Xmax,Ymax): _c(Xmax,Ymax)-- fi
+ B--cycle;
+ $
+enddef;
+
+vardef demiplansup(expr d)=
+ save $,A,B;
+ path $;
+ pair A,B;
+ if (point 0 of d) yscaled -1 < (point infinity of d) yscaled -1:
+ A:=point 0 of d; B:= point infinity of d
+ else: B:=point 0 of d; A:= point infinity of d
+ fi;
+ $=A--
+ if ypart A<=ypart _c(Xmin,Ymin): _c(Xmin,Ymin)-- fi
+ if ypart A<ypart _c(Xmin,Ymax): _c(Xmin,Ymax)-- fi
+ if ypart B<ypart _c(Xmax,Ymax): _c(Xmax,Ymax)-- fi
+ if ypart B<=ypart _c(Xmax,Ymin): _c(Xmax,Ymin)-- fi
+ B--cycle;
+ $
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% PROJECTIONS %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef projetex(expr A)=
+ _c(xpart (A transformed inverse _T),yO)
+enddef;
+
+vardef projetey(expr A)=
+ _c(xO,ypart (A transformed inverse _T))
+enddef;
+
+vardef projectionx@#(text t)=
+ save $,_a,_fg,dec;
+ picture $,_fg;_fg:=nullpicture;
+ numeric dec;dec=0;
+ pair _a;
+ $=image(%
+ for i=t:
+ if pair i: draw i--projetex(i);_a:=i elseif numeric i: dec:=i else: _fg:=thelabel.@#(i,projetex(_a)) fi;
+ endfor;
+ draw _fg shifted (0,dec));
+ $
+enddef;
+
+vardef projectiony@#(text t)=
+ save $,_a,_fg,dec;
+ picture $,_fg;_fg:=nullpicture;
+ numeric dec;dec=0;
+ pair _a;
+ $=image(%
+ for i=t:
+ if pair i: draw i--projetey(i);_a:=i elseif numeric i: dec:=i else: _fg:=thelabel.@#(i,projetey(_a)) fi;
+ endfor;
+ draw _fg shifted (dec,0));
+ $
+enddef;
+
+
+vardef projectionaxes(text t)=
+ save $,_A,n;
+ picture $,_fg[];_fg1=_fg2=nullpicture;
+ pair _A;
+ numeric n,dd;n=1;dd=0;
+ $=image(%
+ for i=t: if numeric i: dd:=i fi; endfor
+ for i=t:
+ if not numeric i:
+ if pair i: _A:=i;
+ elseif n=1: if ypart _A > ypart _O: draw projectionx.bot(_A,i,-dd) else: draw projectionx.top(_A,i,dd) fi;n:=n+1
+ else: if xpart _A > xpart _O: draw projectiony.lft(_A,i,-dd) else: draw projectiony.rt(_A,i,dd) fi;n:=n+1
+ fi;
+ fi;
+ endfor;
+ if n<=2: draw projectiony(_A) fi; if n=1: draw projectionx(_A) fi);
+ $
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%% SUITES %%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef suite(suffix u)(expr deb,fin)=
+ save $;
+ picture $;
+ $=courbepoints(u,deb,fin,fin-deb+1);
+ $
+enddef;
+
+vardef _suiterecfonc_(expr x)=0 enddef;
+numeric _suiterecdeb_, _suiterecfin_, _suiterecinit_;
+
+vardef suiterec(suffix f)(expr deb,fin,init)= %escalier un+1=f(un), u_deb=init
+ vardef _suiterecfonc_(expr x)=f(x) enddef;
+ _suiterecdeb_:=deb;_suiterecfin_:=fin;_suiterecinit_:=init; %stocke les valeurs pour réutilisation
+ save $,un;
+ path $;
+ numeric un;
+ un=init;
+ $=_c(un,yO)
+ for i=deb upto fin-1:
+ --_c(un,f(un))--_c(f(un),f(un))
+ hide(un:=f(un))
+ endfor;
+ $
+enddef;
+
+vardef suiterecprojx@#(text t)= %projections et étiquettes sur axe x, utilise les valeurs de suiterec
+ save $,deb,fin,nom,_qw_,un;
+ picture $,lab;
+ string nom;
+ numeric deb,fin,_qw_,un,_prec;
+ deb:=_suiterecdeb_;fin:=_suiterecfin_;un:=_suiterecinit_;
+ _qw_:=1;
+ for i=t: %récupère les éventuelles nouvelles valeurs pour deb et fin
+ if _qw_ =1: if string i: nom:=i else: nom:="_val";_prec:=i fi;
+ elseif _qw_=2:
+ deb:=i;
+ for j=_suiterecdeb_ upto i-1:
+ un:=_suiterecfonc_(un);
+ endfor
+ elseif _qw_=3: fin:=i
+ fi;
+ _qw_:=_qw_+1;
+ endfor;
+ $=image(%
+ if nom="":
+ if deb=_suiterecdeb_:
+ deb:=deb+1;un:=_suiterecfonc_(un)
+ fi;
+ for i=deb upto fin:
+ draw projectionx.@#(_c(un,un));
+ un:=_suiterecfonc_(un);
+ endfor
+ elseif nom="_val":
+ if deb=_suiterecdeb_:
+% label.@#(format("%10f",arrondi(10**_prec,un)),_c(un,yO));
+ draw etiquettex.@#(arrondi(10**_prec,un));
+ deb:=deb+1;un:=_suiterecfonc_(un)
+ fi;
+ for i=deb upto fin:
+% draw projectionx.@#(_c(un,un),format("%10f",arrondi(10**_prec,un)));
+ lab:=LaTeX("$\num{" & decimal(arrondi(10**_prec,un)) & "}$");
+ draw projectionx.@#(_c(un,un),lab,-taillegrad);
+ un:=_suiterecfonc_(un);
+ endfor
+ else:
+ if deb=_suiterecdeb_:
+ label.@#(LaTeX("$" & nom & "_{" & decimal(deb) & "}" & "$"),_c(un,yO));
+ deb:=deb+1;un:=_suiterecfonc_(un)
+ fi;
+ for i=deb upto fin:
+ lab:=LaTeX("$" & nom & "_{" & decimal(i) & "}" & "$");
+ draw projectionx.@#(_c(un,un),lab);
+ un:=_suiterecfonc_(un);
+ endfor
+ fi);
+ $
+enddef;
+
+vardef suiterecprojy@#(text t)= %projections et étiquettes sur axe y, utilise les valeurs de suiterec
+ save $,deb,fin,nom,_qw_,un;
+ picture $,lab;
+ string nom;
+ numeric deb,fin,_qw_,un,_prec;
+ deb:=_suiterecdeb_;fin:=_suiterecfin_;un:=_suiterecinit_;
+ _qw_:=1;
+ for i=t: %récupère les éventuelles nouvelles valeurs pour deb et fin
+ if _qw_ =1: if string i: nom:=i else: nom:="_val";_prec:=i fi;
+ elseif _qw_=2:
+ deb:=i;
+ for j=_suiterecdeb_ upto i-2:
+ un:=_suiterecfonc_(un);
+ endfor
+ elseif _qw_=3: fin:=i
+ fi;
+ _qw_:=_qw_+1;
+ endfor;
+ $=image(%
+ if nom="":
+ if deb=_suiterecdeb_:
+ deb:=deb+1;
+ fi;
+ for i=deb-1 upto fin-1:
+ draw projectiony.@#(_c(un,_suiterecfonc_(un)));
+ un:=_suiterecfonc_(un);
+ endfor
+ elseif nom="_val":
+ if deb=_suiterecdeb_:
+ deb:=deb+1;
+ fi;
+ for i=deb-1 upto fin-1:
+ lab:=LaTeX("$\num{" & decimal(arrondi(10**_prec,un)) & "}$");
+ draw projectiony.@#(_c(un,_suiterecfonc_(un)),lab,-taillegrad);
+ un:=_suiterecfonc_(un);
+ endfor
+ else:
+ if deb=_suiterecdeb_:
+ deb:=deb+1;
+ fi;
+ for i=deb-1 upto fin-1:
+ lab:=LaTeX("$" & nom & "_{" & decimal(i+1) & "}" & "$");
+ draw projectiony.@#(_c(un,_suiterecfonc_(un)),lab);
+ un:=_suiterecfonc_(un);
+ endfor
+ fi);
+ $
+enddef;
+
+
+vardef suiterecproj(text t)=
+ save $;
+ picture $;
+ $=image(%
+ draw suiterecprojx.bot(t);
+ draw suiterecprojy.lft(t));
+ $
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% INTERVALLES %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef bornex[](expr val)=
+ ((1mm,-2mm)--(0,-2mm)--(0,2mm)--(1mm,2mm)) if @<0: xscaled -1 fi shifted _c(val,xO)
+enddef;
+
+vardef borney[](expr val)=
+ ((2mm,1mm)--(2mm,0)--(-2mm,0)--(-2mm,1mm)) if @<0: yscaled -1 fi shifted _c(yO,val)
+enddef;
+
+pair sensborne.FF,sensborne.FO,sensborne.OF,sensborne.OO;
+sensborne.FF=-sensborne.OO=(1,-1);sensborne.FO=-sensborne.OF=(1,1);
+
+vardef intervallex@#(expr vmin,vmax)=
+ save $;
+ picture $;
+ $=image(%
+ draw _c(vmin,xO)--_c(vmax,xO) withpen pencircle scaled 2pt;
+ draw bornex[xpart sensborne@#](vmin) withpen pencircle scaled 2pt;
+ draw bornex[ypart sensborne@#](vmax) withpen pencircle scaled 2pt);
+ $
+enddef;
+
+vardef intervalley@#(expr vmin,vmax)=
+ save $;
+ picture $;
+ $=image(%
+ draw _c(yO,vmin)--_c(yO,vmax) withpen pencircle scaled 2pt;
+ draw borney[xpart sensborne@#](vmin) withpen pencircle scaled 2pt;
+ draw borney[ypart sensborne@#](vmax) withpen pencircle scaled 2pt);
+ $
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%% STATISTIQUES %%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+numeric _decboitemoustache_,_largboitemoustache_;
+
+
+vardef boitemoustache(text t)=
+ _decboitemoustache_:=1.5cm;
+ _largboitemoustache_:=1cm;
+ save $,n;
+ picture $;
+ numeric n,_valeursboitemoustache_[];
+ n:=1;
+ for i=t:
+ _valeursboitemoustache_[n]:=i;
+ n:=n+1;
+ endfor;
+ if known _valeursboitemoustache_[6]: _decboitemoustache_:=_valeursboitemoustache_[6] fi;
+ if known _valeursboitemoustache_[7]: _largboitemoustache_:=_valeursboitemoustache_[7] fi;
+ $=image(%
+ fill fullcircle scaled 3 shifted _c(_valeursboitemoustache_[1],yO);
+ draw _c(_valeursboitemoustache_[1],yO)--_c(_valeursboitemoustache_[2],yO);
+ draw _c(_valeursboitemoustache_[2],yO) shifted (0,-_largboitemoustache_/2)--_c(_valeursboitemoustache_[2],yO) shifted (0,_largboitemoustache_/2)--_c(_valeursboitemoustache_[4],yO) shifted (0,_largboitemoustache_/2)--_c(_valeursboitemoustache_[4],yO) shifted (0,-_largboitemoustache_/2)--cycle;
+ draw _c(_valeursboitemoustache_[3],yO) shifted (0,-_largboitemoustache_/2)--_c(_valeursboitemoustache_[3],yO) shifted (0,_largboitemoustache_/2);
+ draw _c(_valeursboitemoustache_[4],yO)--_c(_valeursboitemoustache_[5],yO);
+ fill fullcircle scaled 3 shifted _c(_valeursboitemoustache_[5],yO)%
+ ) shifted (0,_decboitemoustache_);
+ $
+enddef;
+
+vardef projboitemoustache@#(text t)=
+ save $,n,_lab_,_comp_,A,tmp;
+ pair A;
+ picture $,_lab_[];
+ numeric n_comp_,tmp;
+ n:=long_texte(t);
+ if n=0:
+ _lab_[1]:=LaTeX("$X_{min}$");
+ _lab_[2]:=LaTeX("$Q_1$");
+ _lab_[3]:=LaTeX("$M_e$");
+ _lab_[4]:=LaTeX("$Q_3$");
+ _lab_[5]:=LaTeX("$X_{max}$");
+ elseif n=1:
+ if t=0: for i=1 upto 5: _lab_[i]:=nullpicture; endfor
+ else:
+ tmp:=floor(t);
+ for i=1 upto 5:
+ _lab_[i]:=LaTeX("\num{" & decimal(arrondi(10**tmp,_valeursboitemoustache_[i])) & "}");
+ endfor
+ fi
+ else: _comp_:=1; for i=t:
+ if numeric i: _lab_[_comp_]:=LaTeX("\num{" & decimal(i) & "}")
+ elseif string i: _lab_[_comp_]:=LaTeX(i)
+ else: _lab_[_comp_]:=i
+ fi;
+ _comp_:=_comp_+1;
+ endfor
+ fi;
+ $=image(%
+ for i=1 upto 5:
+ if (i=1) or (i=5):
+ A:=_c(_valeursboitemoustache_[i],yO) shifted(0,_decboitemoustache_)
+ else: A:=_c(_valeursboitemoustache_[i],yO) shifted(0,_decboitemoustache_-_largboitemoustache_/2)
+ fi;
+ draw projectionx@#(A,_lab_[i]);
+ endfor);
+ $
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% FONCTIONS USUELLES %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+pi:=3.141592654;
+e:=2.718281828;
+
+vardef sin(expr x) = sind(180*x/pi) enddef;
+
+vardef cos(expr x) = cosd(180*x/pi) enddef;
+
+vardef tan(expr x) = sin(x)/cos(x) enddef;
+
+vardef exp(expr x) = mexp(x*256) enddef;
+
+vardef ln(expr x) = mlog(x)/256 enddef;
+
+vardef ch(expr x)=(exp(x)+exp(-x))/2 enddef;
+
+vardef sh(expr x)=(exp(x)-exp(-x))/2 enddef;
+
+vardef Arctan(expr x)= pi*angle(1,x)/180 enddef;
+
+vardef Arcsin(expr x)= Arctan(x/sqrt(1-x**2)) enddef;
+
+vardef Arccos(expr x)= pi/2-Arcsin(x) enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% REMPLISSAGE %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+let _fill_ = fill;
+
+def fill expr c=
+if path c: _fill_ c else: draw c fi
+enddef;
+
+numeric largbriques,hautbriques,decbriques;
+largbriques=12;hautbriques=6;decbriques=6;
+
+vardef briques(text t)=
+ if long_texte(t)=0:
+ repbriques(largbriques,hautbriques,decbriques)
+ else:
+ repbriques(t)
+ fi
+enddef;
+
+
+
+vardef repbriques(expr larg,haut,dec)=
+ numeric d;d=0;
+ image(%
+ for j=0 upto _hautcadre/haut:
+ draw ((0,0)--(_largcadre,0)) shifted (0,j*haut);
+ d:=d+dec;if d>larg: d:=d-larg fi;
+ for i=0 upto _largcadre/larg:
+ draw ((0,0)--(0,haut)) shifted (i*larg+d,j*haut);
+ endfor;
+ endfor) shifted llcorner cadre
+enddef;
+
+
+numeric pashach,anglehach;
+pashach=5;anglehach=60;
+
+vardef hachures(text t)=
+ if long_texte(t)=0:
+ rephachures(pashach,anglehach)
+ else:
+ rephachures(t)
+ fi
+enddef;
+
+vardef rephachures(expr pas,angle)=
+ image(%
+ for i=floor(-_diag/(2*pas)) upto ceiling(_diag/(2*pas)):
+ draw ((-_diag/2,0)--(_diag/2,0)) shifted (0,i*pas);
+ endfor) rotated angle shifted center cadre
+enddef;
+
+numeric pervagues,ampvagues,decvagues;
+pervagues=20;ampvagues=3;decvagues=10;
+
+vardef vagues(text t)=
+ if long_texte(t)=0:
+ repvagues(pervagues,ampvagues,decvagues)
+ else:
+ repvagues(t)
+ fi
+enddef;
+
+
+vardef repvagues(expr per,amp,dec)= %D'après le manuel de l'utilisateur de MetaPost
+ image(%
+ for j=0 upto _hautcadre/dec:
+ for i=0 upto _largcadre/amp:
+ draw ((0,0){curl 0}..(per/4,-amp)..(per/2,0){curl 0}..(3*per/4,amp)..(per,0){curl 0}) shifted (i*per,j*dec);
+ endfor;
+ endfor) shifted llcorner cadre
+enddef;
+
+
+primarydef p avec c =
+ begingroup
+ save _des_;
+ picture _des_;
+ _des_:=c;
+ clip _des_ to p;
+ _des_
+ endgroup
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% DIVERS %%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string LaTeX_packages[],LaTeX_preamble,LaTeX_inputenc;
+LaTeX_preamble:="";LaTeX_inputenc:="";
+
+numeric n_packages;
+n_packages:=0;
+
+def LaTeX_AjoutPackage(expr t)=
+ if known latexmp_module:
+ latexmp_packages:=latexmp_packages & "," & t
+ else:
+ n_packages:=n_packages+1;
+ LaTeX_packages[n_packages]:=t
+ fi
+enddef;
+
+def LaTeX_AjoutCommande(expr t)=
+ LaTeX_preamble:=LaTeX_preamble & t
+enddef;
+
+def LaTeX_Encodage(expr t)=
+ LaTeX_inputenc:= t
+enddef;
+
+
+
+boolean LaTeXprem;
+LaTeXprem:=true;
+
+def LaTeXsetup =
+ if LaTeXprem:
+ LaTeXprem:=false;
+ latexmp_preamble:=LaTeX_preamble;
+ latexmp_inputenc:=LaTeX_inputenc;
+ if latexmp_inputenc="": latexmp_inputenc:="utf8" fi;
+ if latexmp_packages="": latexmp_packages:="fourier" fi;
+ latexmp_packages:=latexmp_packages & ",textcomp,mathtools,mathrsfs,esvect[e],siunitx[output-decimal-marker={,}],babel[frenchb]";
+ latexmp_preamble:=latexmp_preamble & "\newcommand{\vect}[1]{\vv{#1}}" & "\newcommand{\calc}{\mathscr{C}}" & "\newcommand{\calp}{\mathscr{P}}" & "\DecimalMathComma" ;
+ fi
+enddef;
+
+vardef LaTeX primary sc = %D'après TEX.mp
+ if known latexmp_module: LaTeXsetup; textext(sc) scaled defaultscale
+ else:
+ save n_p;
+ numeric n_p;
+ write "verbatimtex" to "mptextmp.mp";
+ write "%&latex" to "mptextmp.mp";
+ write "\documentclass[10pt]{article}" to "mptextmp.mp";
+ if LaTeX_inputenc="":
+ write "\usepackage[utf8]{inputenc}" to "mptextmp.mp"
+ else:
+ write "\usepackage[" & LaTeX_inputenc &"]{inputenc}" to "mptextmp.mp"
+ fi;
+ write "\usepackage[T1]{fontenc}" to "mptextmp.mp";
+ if known LaTeX_packages[1]:
+ n_p:=1;
+ forever: exitunless known LaTeX_packages[n_p];
+ write "\usepackage{" & LaTeX_packages[n_p] &"}" to "mptextmp.mp";
+ n_p:=n_p+1;
+ endfor
+ else:
+ write "\usepackage{fourier}" to "mptextmp.mp"
+ fi;
+ write "\usepackage{amsmath}" to "mptextmp.mp";
+ write "\usepackage{mathrsfs}" to "mptextmp.mp";
+ write "\usepackage[e]{esvect}" to "mptextmp.mp";
+ write "\usepackage[output-decimal-marker={,}]{siunitx}" to "mptextmp.mp";
+ write "\usepackage[frenchb]{babel}" to "mptextmp.mp";
+ write LaTeX_preamble to "mptextmp.mp";
+ write "\newcommand{\vect}[1]{\vv{#1}}" to "mptextmp.mp";
+ write "\newcommand{\calc}{\mathscr{C}}" to "mptextmp.mp";
+ write "\newcommand{\calp}{\mathscr{P}}" to "mptextmp.mp";
+ write "\begin{document}" to "mptextmp.mp";
+ write "etex" to "mptextmp.mp";
+ write "btex "& sc &" etex" to "mptextmp.mp";
+ write EOF to "mptextmp.mp";
+ scantokens "input mptextmp" scaled defaultscale
+ fi
+enddef;
+
+%%%%%%%%%%%%%%%Figure intermédiaire%%%%%%%%%%%%%%%%%%%
+def figureinter=
+ clip currentpicture to cadre;
+ shipit;
+ _nfig:=_nfig+1;
+ charcode:=charcode+1;
+enddef;
+
+
+vardef arrowhead expr p = %redéfinition flèches
+ save q,e; path q; pair e;
+ e = point length p of p;
+ q = gobble(p shifted -e cutafter makepath(pencircle scaled 2ahlength))
+ cuttings;
+ (q rotated .5ahangle & reverse q rotated -.5ahangle -- 0.5*(point 0 of q)-- cycle) shifted e
+enddef;
+
+def epaisseur=withpen pencircle scaled enddef;
+def couleur=withcolor enddef;
+
+
+vardef long_texte(text t)=
+ save i;
+ numeric i;
+ i:=0;
+ for n=t: i:=i+1; endfor
+ i
+enddef;
+
+vardef _chaine(suffix s)= %met les termes en indice si le 2e est un chiffre
+ save c,d;
+ string c,d;
+ d:= str s;
+ if length(d)=1:
+ c:=d
+ elseif isdigit (substring (1,2) of d):
+ c:= (substring (0,1) of d) & "_{" & substring (1,infinity) of d & "}"
+ else: c:=str s
+ fi;
+ c
+enddef;
+
+
+vardef arrondi(expr p,x)= %arrondi de x au p-ième
+ round((x-floor(x))*p)/p+floor(x)
+enddef;
+
+vardef arrondimil(expr x)=
+ arrondi(1000,x)
+enddef;
+
+vardef pgcd(expr a,b)=
+ save r_,a_,b_;
+ numeric r_,a_,b_;
+ a_=a;b_=b;
+ forever:
+ r_:=a_ mod b_;
+ exitif r_=0;
+ a_:=b_;
+ b_:=r_;
+ endfor;
+ b_
+enddef;
+
+%%%%%%%%%%%%%%% COULEURS %%%%%%%%%%%%%%%%%%%
+cmykcolor Rouge,Vert,Bleu,Marron,Lime,Orange,Rose,Pourpre,Violet,Cyan,Magenta,Jaune,Olive,Noir,Grisfonce,Gris,Grisclair,Blanc,Beige,Marine,Moutarde,Vertfonce;
+
+Rouge:=(0,1,1,0);
+Vert:=(1,0,1,0);
+Bleu:=(1,1,0,0);
+Marron:=(0,0.53,1,0.65);
+Lime:=(0.38,0,0.78,0.01);
+Orange:=(0,0.5,1,0);
+Rose:=(0,0.57,0.38,0.01);
+Pourpre:=(0,0.91,0.59,0.38);
+Violet:=(0.5,1,0,0.4);
+Cyan:=(1,0,0,0);
+Magenta:=(0,1,0,0);
+Jaune:=(0,0,1,0);
+Olive:=(0.21,0,0.75,0.45);
+Noir:=(0,0,0,1);
+Grisfonce:=(0,0,0,0.75);
+Gris:=(0,0,0,0.5);
+Grisclair:=(0,0,0,0.25);
+Blanc:=(0,0,0,0);
+Beige:=(0,0.14,0.37,0.22);
+Marine:=(1,1,0,0.5);
+Moutarde:=(0.04,0,1,0.19);
+Vertfonce:=(1,0,1,0.5);
+
+
+vardef conversion_cmyn_rvb(expr coul)=
+ ((1-cyanpart coul)*(1-blackpart coul),(1-magentapart coul)*(1-blackpart coul),(1-yellowpart coul)*(1-blackpart coul))
+enddef;
+
+color rouge,vert,bleu,marron,lime,orange,rose,pourpre,violet,cyan,magenta,jaune,olive,noir,grisfonce,gris,grisclair,blanc,beige,marine,moutarde,vertfonce;
+
+rouge:=conversion_cmyn_rvb(Rouge);
+vert:=conversion_cmyn_rvb(Vert);
+bleu:=conversion_cmyn_rvb(Bleu);
+marron:=conversion_cmyn_rvb(Marron);
+lime:=conversion_cmyn_rvb(Lime);
+orange:=conversion_cmyn_rvb(Orange);
+rose:=conversion_cmyn_rvb(Rose);
+pourpre:=conversion_cmyn_rvb(Pourpre);
+violet:=conversion_cmyn_rvb(Violet);
+cyan:=conversion_cmyn_rvb(Cyan);
+magenta:=conversion_cmyn_rvb(Magenta);
+jaune:=conversion_cmyn_rvb(Jaune);
+olive:=conversion_cmyn_rvb(Olive);
+noir:=conversion_cmyn_rvb(Noir);
+grisfonce:=conversion_cmyn_rvb(Grisfonce);
+gris:=conversion_cmyn_rvb(Gris);
+grisclair:=conversion_cmyn_rvb(Grisclair);
+blanc:=conversion_cmyn_rvb(Blanc);
+beige:=conversion_cmyn_rvb(Beige);
+marine:=conversion_cmyn_rvb(Marine);
+moutarde:=conversion_cmyn_rvb(Moutarde);
+vertfonce:=conversion_cmyn_rvb(Vertfonce);
+