summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/repere
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-06-21 21:24:54 +0000
committerKarl Berry <karl@freefriends.org>2016-06-21 21:24:54 +0000
commitc83263c0db8d6eb3405f292769f552707219383e (patch)
tree34182c683d981c4f863fa04f10e5762b8c5c0873 /Master/texmf-dist/metapost/repere
parent4db63e6af3cfba060d6736542b3d5e9d69650280 (diff)
repere (21jun16)
git-svn-id: svn://tug.org/texlive/trunk@41513 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/repere')
-rw-r--r--Master/texmf-dist/metapost/repere/repere.mp793
1 files changed, 557 insertions, 236 deletions
diff --git a/Master/texmf-dist/metapost/repere/repere.mp b/Master/texmf-dist/metapost/repere/repere.mp
index 1d8b70c73a5..2b6d86e5b8b 100644
--- a/Master/texmf-dist/metapost/repere/repere.mp
+++ b/Master/texmf-dist/metapost/repere/repere.mp
@@ -1,8 +1,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% repere.mp %%
%% Macros pour la construction de figures dans un repère %%
-%% o.peault@gmail.com %%
-%% Version 13.12 (Décembre 2013) %%
+%% o.peault@openmailbox.org %%
+%% Version 16.06 (Juin 2016) %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This work may be distributed and/or modified under the conditions of
@@ -13,18 +13,20 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input format;
+if not known mplib: input latexmp fi;
warningcheck:=0;
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% REPERE %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
numeric _nfig,_nbaxes,theta,taillegrad,taillepoint,taillecroix,facteurx,facteury;
-boolean flecheaxe,displayfrac,coupe;
+boolean flecheaxe,displayfrac,coupe,boolgradxpart,boolgradypart;
_nfig:=1;
path cadre;
numeric _diag,_largcadre,_hautcadre,_tfig;
-pair _O,_I,_J;
+pair _O,_I,_J,_O_;
transform _T;
picture _axorlab; pair poslabO;
@@ -35,10 +37,35 @@ facteury:=1;
boolean rep_groupe;
rep_groupe:=false;
+%%%%%%%%%%% Sauvegarde macros plain
let oldbeginfig=beginfig;
let oldendfig=endfig;
+let olddraw = draw;
+let olddrawarrow = drawarrow;
+let olddrawdblarrow = drawdblarrow;
+let oldfill = fill;
+vardef theoldlabel@#(expr s,z) = % Position s near z
+ save p; picture p;
+ if picture s: p=s
+ else: p = s infont defaultfont scaled defaultscale
+ fi;
+ p shifted (z + labeloffset*laboff@# -
+ (labxf@#*lrcorner p + labyf@#*ulcorner p
+ + (1-labxf@#-labyf@#)*llcorner p
+ )
+ )
+enddef;
+vardef oldbbox primary p =
+ llcorner p-(bboxmargin,bboxmargin) -- lrcorner p+(bboxmargin,-bboxmargin)
+ -- urcorner p+(bboxmargin,bboxmargin) -- ulcorner p+(-bboxmargin,bboxmargin)
+ -- cycle
+enddef;
+
+
+%%%%%%% Redéfinition beginfig
+
def beginfig(expr c)=
oldbeginfig(c);
_nfig:=c;
@@ -51,9 +78,11 @@ def endfig=
rep_groupe:=false
enddef;
+
+%%%%%%%%%% Définition du repère
+
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)
@@ -84,15 +113,73 @@ vardef definitionrepere@#(text t) =
_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);
+ _O:=_cart(0,0); xO:=0 ; yO:=0;_O_:=(0,0);
+ _I:=_cart(1,0); _J:=_cart(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;
+ boolgradxpart:=true;boolgradypart:=true;
defaultscale:=1;
unitex:=abs(_I);unitey:=abs(_J);unite:=unitex;
facteurx:=1;facteury:=1;
string extranumx,extranumy;
extranumx=extranumy="";
+ init_traces;
+enddef;
+
+%%%% Initialisations tracés (redéfinition draw etc.)
+def init_traces =
+ %% draw
+ def draw expr p =
+ addto currentpicture
+ if picture p:
+ also p
+ else:
+ doublepath p transformed _T withpen currentpen
+ fi
+ _op_
+ enddef;
+ %% fill
+ def fill expr c =
+ if path c:
+ addto currentpicture contour (c transformed _T) _op_
+ else:
+ olddraw c
+ fi
+ enddef;
+ %% thelabel
+ vardef thelabel@#(expr s,z) = % Position s near z
+ save p; picture p;
+ if picture s: p=s
+ else: p = s infont defaultfont scaled defaultscale
+ fi;
+ p shifted (_cart(z) + labeloffset*laboff@# -
+ (labxf@#*lrcorner p + labyf@#*ulcorner p
+ + (1-labxf@#-labyf@#)*llcorner p
+ )
+ )
+ enddef;
+ %% drawarrow
+ def drawarrow expr p = _apth:=p transformed _T; _finarr enddef;
+ def drawdblarrow expr p = _apth:=p transformed _T; _findarr enddef;
+ %% bbox
+ vardef bbox primary p =
+ if picture p: oldbbox p transformed inverse _T
+ else: oldbbox p
+ fi
+ enddef;
+enddef;
+
+def _finarr text t =
+ olddraw _apth t;
+ filldraw arrowhead _apth t
+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 setaxes(expr a,b,c,d)=
@@ -121,16 +208,19 @@ enddef;
let setall=settout;
def fin =
- if _nbaxes=1: draw _axorlab fi;
- if coupe: clip currentpicture to cadre fi;
+ if _nbaxes=1: olddraw _axorlab fi;
+ if coupe: clip currentpicture to (cadre transformed _T) 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;
+ cadre:=(Xmin,Ymin)--(Xmin,Ymax)--(Xmax,Ymax)--(Xmax,Ymin)--cycle;
_diag:=abs(llcorner cadre - urcorner cadre);
+ _diag_:=abs(llcorner _cart(cadre) - urcorner _cart(cadre));
_largcadre:=abs(llcorner cadre - lrcorner cadre);
+ _largcadre_:=abs(llcorner _cart(cadre) - lrcorner _cart(cadre));
_hautcadre:=abs(llcorner cadre - ulcorner cadre);
+ _hautcadre_:=abs(llcorner _cart(cadre) - ulcorner _cart(cadre));
_tfig:=max(_largcadre,_hautcadre); % compatibilité geometriesyr
enddef;
@@ -139,7 +229,7 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def interaxes(expr a,b) =
- _O:=_c(a,b);
+ _O:=_cart(a,b);_O_:=(a,b);
xO:=a;
yO:=b;
enddef;
@@ -163,7 +253,7 @@ vardef _etiqx_@#(expr ab,dec,st)= %étiquettes axe des abscisses
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@#))
+ theoldlabel.@#(pic,_cart(ab,yO) shifted (dec*_posgradx@#))
enddef;
vardef _etiqy_@#(expr ro,dec,st)= %étiquettes axe des ordonnées
@@ -172,17 +262,17 @@ vardef _etiqy_@#(expr ro,dec,st)= %étiquettes axe des ordonnées
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@#))
+ theoldlabel.@#(pic,_cart(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)
+ ((0,taillegrad)--(0,-taillegrad)) rotated (theta-90) shifted _cart(x,yO)
enddef;
vardef graduationy(expr y)= %%%%%%% graduation axe des ordonnées
- ((taillegrad,0)--(-taillegrad,0)) shifted _c(xO,y)
+ ((taillegrad,0)--(-taillegrad,0)) shifted _cart(xO,y)
enddef;
vardef etiquettex@#(expr x)=
@@ -195,9 +285,9 @@ vardef etiquettey@#(expr y)=
enddef;
-vardef dessinaxex=_c(AxeXmin,yO)--_c(AxeXmax,yO) enddef;
+vardef dessinaxex=_cart(AxeXmin,yO)--_cart(AxeXmax,yO) enddef;
-vardef dessinaxey=_c(xO,AxeYmin)--_c(xO,AxeYmax) enddef;
+vardef dessinaxey=_cart(xO,AxeYmin)--_cart(xO,AxeYmax) enddef;
vardef graduationsaxex(expr grad)= %%%% ensemble des graduations abscisses
@@ -205,10 +295,10 @@ vardef graduationsaxex(expr grad)= %%%% ensemble des graduations abscisses
$=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;
+ olddraw 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);
+ if AxeXmax*Ux-(imax*grad+xO)*Ux>ahlength: olddraw graduationx(arrondimil(imax*grad)+xO) withpen pencircle scaled 0.5bp fi);
$
enddef;
@@ -217,10 +307,10 @@ vardef graduationsaxey(expr grad)= %%%% ensemble des graduations ordonnées
$=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;
+ olddraw 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);
+ if AxeYmax*Uy-(imax*grad+yO)*Uy>ahlength: olddraw graduationy(arrondimil(imax*grad)+yO) withpen pencircle scaled 0.5bp fi);
$
enddef;
@@ -242,15 +332,15 @@ vardef etiquettesaxex@#(expr val)= %%% ensemble des étiquettes abscisses
else: labmax:=nullpicture
fi;
% tracé première étiquette
- if xpart ((ulcorner labmin) transformed inverse _T)>=Xmin: draw labmin fi;
+ if xpart ((ulcorner labmin) transformed inverse _T)>=Xmin: olddraw labmin fi;
% tracé autres étiquettes
for i=imin+1 upto imax-1:
if (i<>0):
- draw etiquettex.@#(arrondimil(i*val)+xO)
+ olddraw etiquettex.@#(arrondimil(i*val)+xO)
fi;
endfor;
% tracé dernière étiquette
- if xpart ((lrcorner labmax) transformed inverse _T)<=Xmax: draw labmax fi;
+ if xpart ((lrcorner labmax) transformed inverse _T)<=Xmax: olddraw labmax fi;
);
$
enddef;
@@ -272,15 +362,15 @@ vardef etiquettesaxey@#(expr val)= %%% ensemble des étiquettes ordonnées
else: labmax:=nullpicture
fi;
% tracé première étiquette
- if ypart (llcorner labmin) >=ypart _c(Xmin,Ymin): draw labmin fi;
+ if ypart (llcorner labmin) >=ypart _cart(Xmin,Ymin): olddraw labmin fi;
% tracé autres étiquettes
for i=imin+1 upto imax-1:
if (i<>0):
- draw etiquettey.@#(arrondimil(i*val)+yO)
+ olddraw etiquettey.@#(arrondimil(i*val)+yO)
fi;
endfor;
% tracé dernière étiquette
- if ypart (ulcorner labmax) <=ypart _c(Xmax,Ymax): draw labmax fi
+ if ypart (ulcorner labmax) <=ypart _cart(Xmax,Ymax): olddraw labmax fi
);
$
enddef;
@@ -290,38 +380,38 @@ vardef _axex_@#(expr grad,val,nn)=
picture $;
$=image(
% axe
- if flecheaxe: drawarrow else: draw fi dessinaxex;
+ if flecheaxe: olddrawarrow else: olddraw fi dessinaxex;
% graduations
- if grad>0: draw graduationsaxex(grad) fi;
+ if grad>0: olddraw graduationsaxex(grad) fi;
% étiquettes
if val>0:
if nn=1:
if str @#<>"":
- draw etiquettesaxex@#(val);
+ olddraw etiquettesaxex@#(val);
_axorlab:=etiquettex@#(xO)
else:
- draw etiquettesaxex.bot(val);
+ olddraw etiquettesaxex.bot(val);
_axorlab:=etiquettex.bot(xO)
fi;
poslabO:=poslabO + unitvector(0,ypart _posgradx@#);
if xO<>yO:
- draw _axorlab
+ olddraw _axorlab
elseif _nbaxes=2:
- draw _etiqx_(xO,0,xO) shifted (0.7*abs(llcorner _axorlab - urcorner _axorlab)*poslabO)
+ olddraw _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)
+ olddraw etiquettesaxex@#(val);
+ olddraw etiquettex@#(xO)
else:
- draw etiquettesaxex.bot(val);
- draw etiquettex.bot(xO)
+ olddraw etiquettesaxex.bot(val);
+ olddraw etiquettex.bot(xO)
fi
else:
if str @#<>"":
- draw etiquettesaxex@#(val)
+ olddraw etiquettesaxex@#(val)
else:
- draw etiquettesaxex.bot(val)
+ olddraw etiquettesaxex.bot(val)
fi
fi
fi
@@ -334,38 +424,38 @@ vardef _axey_@#(expr grad,val,nn)=
picture $;
$=image(
% axe
- if flecheaxe: drawarrow else: draw fi dessinaxey;
+ if flecheaxe: olddrawarrow else: olddraw fi dessinaxey;
% graduations
- if grad>0: draw graduationsaxey(grad) fi;
+ if grad>0: olddraw graduationsaxey(grad) fi;
% étiquettes
if val>0:
if nn=1:
if str @#<>"":
- draw etiquettesaxey@#(val);
+ olddraw etiquettesaxey@#(val);
_axorlab:=etiquettey@#(yO)
else:
- draw etiquettesaxey.lft(val);
+ olddraw etiquettesaxey.lft(val);
_axorlab:=etiquettey.lft(yO)
fi;
poslabO:=poslabO + unitvector(xpart _posgrady@#,0);
if xO<>yO:
- draw _axorlab
+ olddraw _axorlab
elseif _nbaxes=2:
- draw _etiqy_(yO,0,yO) shifted (0.7*abs(llcorner _axorlab - urcorner _axorlab)*poslabO)
+ olddraw _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)
+ olddraw etiquettesaxey@#(val);
+ olddraw etiquettey@#(yO)
else:
- draw etiquettesaxey.lft(val);
- draw etiquettey.lft(yO)
+ olddraw etiquettesaxey.lft(val);
+ olddraw etiquettey.lft(yO)
fi
else:
if str @#<>"":
- draw etiquettesaxey@#(val)
+ olddraw etiquettesaxey@#(val)
else:
- draw etiquettesaxey.lft(val)
+ olddraw etiquettesaxey.lft(val)
fi
fi
fi
@@ -535,7 +625,7 @@ vardef etiquettesaxeypi@#(expr n,d)= %%% ensemble des étiquettes multiple
else: labmax:=nullpicture
fi;
% tracé première étiquette
- if ypart (llcorner labmin) >=ypart _c(Xmin,Ymin): draw labmin fi;
+ if ypart (llcorner labmin) >=ypart _cart(Xmin,Ymin): draw labmin fi;
% tracé autres étiquettes
for i=imin+1 upto imax-1:
if (i<>0):
@@ -543,7 +633,7 @@ vardef etiquettesaxeypi@#(expr n,d)= %%% ensemble des étiquettes multiple
fi;
endfor;
% tracé dernière étiquette
- if ypart (ulcorner labmax) <=ypart _c(Xmax,Ymax): draw labmax fi
+ if ypart (ulcorner labmax) <=ypart _cart(Xmax,Ymax): draw labmax fi
);
$
enddef;
@@ -555,7 +645,7 @@ vardef _axexpi_@#(expr num,den,nn)=
grad:=num*pi/den;
$=image(
% axe
- if flecheaxe: drawarrow else: draw fi dessinaxex;
+ if flecheaxe: olddrawarrow else: olddraw fi dessinaxex;
% graduations
if grad>0: draw graduationsaxex(grad) fi;
% étiquettes
@@ -599,7 +689,7 @@ vardef _axeypi_@#(expr num,den,nn)=
grad:=num*pi/den;
$=image(
% axe
- if flecheaxe: drawarrow else: draw fi dessinaxey;
+ if flecheaxe: olddrawarrow else: olddraw fi dessinaxey;
% graduations
if grad>0: draw graduationsaxey(grad) fi;
% étiquettes
@@ -715,8 +805,9 @@ vardef axexpart@#(text t)=
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;
+ if boolgradxpart:
+ draw graduationx(_i) withpen pencircle scaled 0.8bp
+ fi;
tmp:=_i;
var:=true
else:
@@ -738,7 +829,7 @@ vardef axeypart@#(text t)=
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;
+ draw ((taillegrad,0)--(-taillegrad,0)) shifted _cart(xO,_i) withpen pencircle scaled 0.8bp;
tmp:=_i;
var:=true
else:
@@ -758,8 +849,8 @@ vardef axesunit=
draw axes(0,0);
draw axexpart(1);
draw axeypart(1);
- label.llft(LaTeX("$0$"),_c(0,0));
- % label.llft("0",_c(0,0));
+ label.llft(LaTeX("$0$"),_cart(0,0));
+ % label.llft("0",_cart(0,0));
);
$
enddef;
@@ -773,22 +864,33 @@ vardef _ccoord(expr xA,yA)=
(xA,yA) transformed _T
enddef;
+vardef _coord(expr xA,yA)=
+ (xA,yA)
+enddef;
+
vardef _cobjet(expr obj)=
obj transformed _T
enddef;
-vardef _c(text t)=
+vardef _cart(text t)=
if long_texte(t)=2: _ccoord(t)
else: _cobjet(t)
fi
enddef;
+vardef _c(text t)=
+ if long_texte(t)=2: _coord(t)
+ else: t
+ fi
+enddef;
+
+
vardef pol(expr r,theta)=
- _c(r*cos(theta),r*sin(theta))
+ (r*cos(theta),r*sin(theta))
enddef;
vardef pold(expr r,theta)=
- _c(r*cosd(theta),r*sind(theta))
+ (r*cosd(theta),r*sind(theta))
enddef;
color coulpoint,coullabel,coullabelfonc;
@@ -799,15 +901,15 @@ vardef MarquePointFig(expr pp)= % compatibilité geometriesyr15
save $;
picture $;
if marque_p = "plein":
- $:=image(fill fullcircle scaled taillepoint shifted pp withcolor coulpoint);
+ $:=image(oldfill fullcircle scaled taillepoint shifted _cart(pp) withcolor coulpoint);
elseif marque_p = "creux":
$:=image(%
- fill fullcircle scaled taillepoint shifted pp withcolor background;
- draw fullcircle scaled taillepoint shifted pp withcolor coulpoint);
+ oldfill fullcircle scaled taillepoint shifted _cart(pp) withcolor background;
+ olddraw fullcircle scaled taillepoint shifted _cart(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)
+ olddraw ((-taillecroix,0)--(taillecroix,0)) shifted _cart(pp) withcolor coulpoint;
+ olddraw ((0,-taillecroix)--(0,taillecroix)) shifted _cart(pp) withcolor coulpoint)
else: $:=nullpicture
fi;
$
@@ -850,12 +952,12 @@ vardef nommecourbe@#(suffix p)(text t)=
picture dess;
if long_texte(t)=1:
dess:=image(ch:=_chaine(p);
- A:=_c(t,fonccourbe.p(t));
+ A:=(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))
+ if numeric _a: A:=(_a,fonccourbe.p(_a))
else: if string _a: label@#(_a,A) else: label@#(_a scaled defaultscale,A) fi withcolor coullabelfonc
fi;
endfor)
@@ -868,12 +970,15 @@ enddef;
vardef nommeobj@#(text t)=
save $;
picture $;
+ if long_texte(t)=4: $:=nommeangle@#(t)
+ else:
for i=t:
if pair i: $:=nommepoint@#(t)
else: $:=nommecourbe@#(t)
fi;
exitif true;
endfor
+ fi;
$
enddef;
@@ -886,11 +991,11 @@ vardef vecteur@#(expr A)(text t)=
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)
+ if long_texte(t)=1: drawarrow A--A+t;ch:=_chaine(t);label@#(LaTeX("$\vv{" & 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
+ else: if string u: if u<>"": label@#(LaTeX("$\vv{" & u & "}$"),m) fi else: label@#(u,m) fi
fi;
endfor
fi);
@@ -902,7 +1007,7 @@ vardef marquepointcourbefig(suffix p)(text t)=
picture $;
$=image(%
for i=t:
- MarquePoint(_c(i,fonccourbe.p(i)));
+ MarquePoint((i,fonccourbe.p(i)));
endfor);
$
enddef;
@@ -924,24 +1029,24 @@ 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)
+ rotated (90+angle(direction infinity of _cart(p)))
+ shifted (point infinity of _cart(p))
enddef;
-def marquecheminouvertdroite= draw marquecheminouvertdroitefig enddef;
+def marquecheminouvertdroite= olddraw 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)
+ rotated (-90+angle(direction 0 of _cart(p)))
+ shifted (point 0 of _cart(p))
enddef;
-def marquecheminouvertgauche= draw marquecheminouvertgauchefig enddef;
+def marquecheminouvertgauche= olddraw marquecheminouvertgauchefig enddef;
-vardef marquecheminouvert(expr p)=
- marquecheminouvertdroite(p);
- marquecheminouvertgauche(p)
+def marquecheminouvert(expr p) text t=
+ marquecheminouvertdroite(p) t;
+ marquecheminouvertgauche(p) t
enddef;
@@ -964,9 +1069,9 @@ vardef base(suffix a,b,c)=
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
+ draw vecteur.bot(_O_,(1,0),ijmath(I)) withpen pencircle scaled 0.8 withcolor coulbase;
+ draw vecteur.lft(_O_,(0,1),ijmath(J)) withpen pencircle scaled 0.8 withcolor coulbase;
+ nomme.llft(_O_,LaTeX("$" & O & "$")) withcolor coulbase
);
$
enddef;
@@ -978,7 +1083,7 @@ vardef basep(suffix a,b,c)=
picture $;
O:=_chaine(a); I:=_chaine(b); J:=_chaine(c);
$:=image(%
- nomme.llft(_O,LaTeX("$" & O & "$")) withcolor coulbase;
+ nomme.llft(_O_,LaTeX("$" & O & "$")) withcolor coulbase;
draw axexpart(1,LaTeX("$" & I & "$")) withcolor coulbase;
draw axeypart(1,LaTeX("$" & J & "$")) withcolor coulbase;
);
@@ -990,7 +1095,7 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
numeric ep; color coul;
- ep:= .2bp; %%%%%%%% épaisseur du trait
+ ep:= .3bp; %%%%%%%% épaisseur du trait
coul := .7white; %%%%%%%% couleur du trait
def quadstyle= enddef;
@@ -999,12 +1104,12 @@ enddef;
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;
+ olddraw _cart(arrondimil(i*quadx)+xO,QuadYmin)--_cart(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;
+ olddraw _cart(QuadXmin,arrondimil(i*quady)+yO)--_cart(QuadXmax,arrondimil(i*quady)+yO) withpen pencircle scaled ep withcolor coul quadstyle;
endfor;
fi);
$
@@ -1016,7 +1121,7 @@ enddef;
$=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;
+ olddraw (0,0) shifted _cart(i*quadx,j*quady) withpen pencircle scaled 2;
endfor;
endfor;
fi);
@@ -1033,24 +1138,24 @@ vardef papiermillimetre =
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;
+ if i mod 5 <> 0: olddraw (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;
+ if i mod 5<> 0: olddraw (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;
+ olddraw (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;
+ olddraw (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;
+ olddraw (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;
+ olddraw (QuadXmin*Ux,i*cm)--(QuadXmax*Ux,i*cm) withpen pencircle scaled pm_epc withcolor pm_coulc;
endfor);
$
enddef;
@@ -1060,47 +1165,51 @@ enddef;
%%%%%%%%%% FONCTIONS - COURBES %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-vardef courbefonc(suffix f)(expr xmin, xmax, n) = %Courbe représentative d'une fonction
+vardef courbef_(suffix f)(expr xmin, xmax, n) = %Courbe représentative d'une fonction
save $,x;
path $;
- $=( _c(xmin,f(xmin))
+ $=((xmin,f(xmin))
for i=1 upto n-1:
- .._c(xmin+i*(xmax-xmin)/(n-1),f(xmin+i*(xmax-xmin)/(n-1)))
+ ..(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 );
- $
+
+vardef courbefonc(suffix f)(text t)=
+ save cc;path cc;
+ save k,Val;numeric k,Val[];
+ Val[1]:=Xmin;Val[2]:=Xmax;Val[3]:=60;
+ k:=1;
+ for i=t:
+ Val[k]:=i;
+ k:=k+1;
+ endfor
+ courbef_(f,Val[1],Val[2],Val[3])
enddef;
-%%%%%%%%%% FINTEST %%%%%%%%%%%%%
+
+
+
vardef courbepoints(suffix f)(expr xmin, xmax, n) = %Points non reliés
save $,x;
picture $;
- $=image(MarquePoint(_c(xmin,f(xmin)));
+ $=image(MarquePoint((xmin,f(xmin)));
for i=1 upto n-1:
- MarquePoint(_c(xmin+i*(xmax-xmin)/(n-1),f(xmin+i*(xmax-xmin)/(n-1))));
+ MarquePoint((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)
+ ypart pointcourbe@#(x)
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)
+ (t,whatever)=@# intersectiontimes ((x,2*Ymin-Ymax)--(x,2*Ymax-Ymin));
+ if t=-1: _P_:=(x,0)
else: _P_:=point t of @#
fi;
_P_
@@ -1111,10 +1220,10 @@ vardef der@#(expr x)= %Fonction dérivée
path pp;
pair v,w;
pp:=@#;
- (t,whatever) = pp intersectiontimes (_c(x,2*Ymin-Ymax)--_c(x,2*Ymax-Ymin));
+ (t,whatever) = pp intersectiontimes ((x,2*Ymin-Ymax)--(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;
+% w:=unitvector(v transformed inverse _T);
+ if xpart v = 0: d:=0 else: d:= (ypart v)/(xpart v) fi;
d
enddef;
@@ -1134,13 +1243,13 @@ vardef intercourbes(suffix P)(expr p,q)= %renvoie les points d'intersections de
enddef;
vardef ptantecedents(suffix P)(expr y,p)=
- intercourbes(P,_c(Xmin,y)--_c(Xmax,y),p)
+ intercourbes(P,(Xmin,y)--(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
+ for i=1 upto 10: P[i]:=xpart (PP[i]); endfor
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1160,13 +1269,13 @@ senstan.gauche=(1,0);senstan.droite=(0,1);senstan.double=(1,1);
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));
+ (t,whatever) = p intersectiontimes ((N1,Ymin)--(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;
+ if (xpart senstan@#) <> 0: olddrawarrow _cart(M)--_cart(M)-_v*(xpart senstan@#) fi;
+ if (ypart senstan@#) <> 0: olddrawarrow _cart(M)--_cart(M)+_v*(ypart senstan@#) fi;
);
$
enddef;
@@ -1176,7 +1285,7 @@ vardef tangentedroite(expr p,a) =
path $;
numeric m,t;
pair M;
- (t,whatever) = p intersectiontimes (_c(a,Ymin)--_c(a,Ymax));
+ (t,whatever) = p intersectiontimes ((a,Ymin)--(a,Ymax));
M:=point t of p;
$=M-_diag*unitvector(direction t of p)--M+_diag*unitvector(direction t of p);
$
@@ -1198,7 +1307,7 @@ vardef entrecourbes(expr p,q,xmin,xmax)=
enddef;
vardef souscourbe(expr p,xmin,xmax)=
- buildcycle(droiteeqx(xmax),p,droiteeqx(xmin),_c(Xmin,0)--_c(Xmax,0))
+ buildcycle(droiteeqx(xmax),p,droiteeqx(xmin),(Xmin,0)--(Xmax,0))
enddef;
@@ -1209,9 +1318,9 @@ vardef rectangles@#(suffix p)(expr a,b,n)= %Riemann, renvoie un chemin fermé
pas=(b-a)/n;
_rect_ =
for i=0 upto n-1:
- _c(a+i*pas,yO)--_segmrect_@#(p,a+i*pas,pas)--
+ (a+i*pas,yO)--_segmrect_@#(p,a+i*pas,pas)--
endfor
- _c(b,yO)--cycle;
+ (b,yO)--cycle;
_rect_
enddef;
@@ -1224,8 +1333,8 @@ vardef _segmrect_@#(suffix p)(expr a,pas)=
_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))
+ elseif _typerect@#=3: (pointcourbe.p(a))--(pointcourbe.p(a) shifted (pas,0))
+ elseif _typerect@#=4: (pointcourbe.p(a+pas) shifted (-pas,0))--(pointcourbe.p(a+pas))
fi
enddef;
@@ -1236,15 +1345,15 @@ 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);
+ $:=(Xmin,a*Xmin+b)--(Xmax,a*Xmax+b);
else:
- $:=_c(Ymin/a-b/a,Ymin)--_c(Ymax/a-b/a,Ymax);
+ $:=(Ymin/a-b/a,Ymin)--(Ymax/a-b/a,Ymax);
fi;
$
enddef;
vardef droiteeqx(expr c)=
- _c(c,2*Ymin-Ymax)--_c(c,2*Ymax-Ymin)
+ (c,2*Ymin-Ymax)--(c,2*Ymax-Ymin)
enddef;
vardef droiteeqcart(expr a,b,c)=
@@ -1296,10 +1405,10 @@ vardef demiplaninf(expr 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
+ if ypart A>=ypart (Xmin,Ymax): (Xmin,Ymax)-- fi
+ if ypart A>ypart (Xmin,Ymin): (Xmin,Ymin)-- fi
+ if ypart B>ypart (Xmax,Ymin): (Xmax,Ymin)-- fi
+ if ypart B>=ypart (Xmax,Ymax): (Xmax,Ymax)-- fi
B--cycle;
$
enddef;
@@ -1313,10 +1422,10 @@ vardef demiplansup(expr 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
+ if ypart A<=ypart (Xmin,Ymin): (Xmin,Ymin)-- fi
+ if ypart A<ypart (Xmin,Ymax): (Xmin,Ymax)-- fi
+ if ypart B<ypart (Xmax,Ymax): (Xmax,Ymax)-- fi
+ if ypart B<=ypart (Xmax,Ymin): (Xmax,Ymin)-- fi
B--cycle;
$
enddef;
@@ -1325,11 +1434,11 @@ enddef;
%%%%%%%%%% PROJECTIONS %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef projetex(expr A)=
- _c(xpart (A transformed inverse _T),yO)
+ (xpart (A),yO)
enddef;
vardef projetey(expr A)=
- _c(xO,ypart (A transformed inverse _T))
+ (xO,ypart (A))
enddef;
vardef projectionx@#(text t)=
@@ -1369,8 +1478,8 @@ vardef projectionaxes(text t)=
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
+ 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;
@@ -1391,16 +1500,16 @@ 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 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)
+ $=(un,yO)
for i=deb upto fin-1:
- --_c(un,f(un))--_c(f(un),f(un))
+ --(un,f(un))--(f(un),f(un))
hide(un:=f(un))
endfor;
$
@@ -1430,29 +1539,27 @@ vardef suiterecprojx@#(text t)= %projections et étiquettes sur axe x, utilis
deb:=deb+1;un:=_suiterecfonc_(un)
fi;
for i=deb upto fin:
- draw projectionx.@#(_c(un,un));
+ draw projectionx.@#((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);
+ draw projectionx.@#((un,un),lab,-taillegrad);
un:=_suiterecfonc_(un);
endfor
else:
if deb=_suiterecdeb_:
- label.@#(LaTeX("$" & nom & "_{" & decimal(deb) & "}" & "$"),_c(un,yO));
+ label.@#(LaTeX("$" & nom & "_{" & decimal(deb) & "}" & "$"),(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);
+ draw projectionx.@#((un,un),lab);
un:=_suiterecfonc_(un);
endfor
fi);
@@ -1483,7 +1590,7 @@ vardef suiterecprojy@#(text t)= %projections et étiquettes sur axe y, utilis
deb:=deb+1;
fi;
for i=deb-1 upto fin-1:
- draw projectiony.@#(_c(un,_suiterecfonc_(un)));
+ draw projectiony.@#((un,_suiterecfonc_(un)));
un:=_suiterecfonc_(un);
endfor
elseif nom="_val":
@@ -1492,7 +1599,7 @@ vardef suiterecprojy@#(text t)= %projections et étiquettes sur axe y, utilis
fi;
for i=deb-1 upto fin-1:
lab:=LaTeX("$\num{" & decimal(arrondi(10**_prec,un)) & "}$");
- draw projectiony.@#(_c(un,_suiterecfonc_(un)),lab,-taillegrad);
+ draw projectiony.@#((un,_suiterecfonc_(un)),lab,-taillegrad);
un:=_suiterecfonc_(un);
endfor
else:
@@ -1501,7 +1608,7 @@ vardef suiterecprojy@#(text t)= %projections et étiquettes sur axe y, utilis
fi;
for i=deb-1 upto fin-1:
lab:=LaTeX("$" & nom & "_{" & decimal(i+1) & "}" & "$");
- draw projectiony.@#(_c(un,_suiterecfonc_(un)),lab);
+ draw projectiony.@#((un,_suiterecfonc_(un)),lab);
un:=_suiterecfonc_(un);
endfor
fi);
@@ -1523,11 +1630,11 @@ enddef;
%%%%%%%%%% INTERVALLES %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef bornex[](expr val)=
- ((1mm,-2mm)--(0,-2mm)--(0,2mm)--(1mm,2mm)) if @<0: xscaled -1 fi shifted _c(val,xO)
+ ((1mm,-2mm)--(0,-2mm)--(0,2mm)--(1mm,2mm)) if @<0: xscaled -1 fi shifted _cart(val,xO)
enddef;
vardef borney[](expr val)=
- ((2mm,1mm)--(2mm,0)--(-2mm,0)--(-2mm,1mm)) if @<0: yscaled -1 fi shifted _c(yO,val)
+ ((2mm,1mm)--(2mm,0)--(-2mm,0)--(-2mm,1mm)) if @<0: yscaled -1 fi shifted _cart(yO,val)
enddef;
pair sensborne.FF,sensborne.FO,sensborne.OF,sensborne.OO;
@@ -1537,9 +1644,9 @@ 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);
+ olddraw _cart(vmin,xO)--_cart(vmax,xO) withpen pencircle scaled 2pt;
+ olddraw bornex[xpart sensborne@#](vmin) withpen pencircle scaled 2pt;
+ olddraw bornex[ypart sensborne@#](vmax) withpen pencircle scaled 2pt);
$
enddef;
@@ -1547,9 +1654,9 @@ 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);
+ olddraw _cart(yO,vmin)--_cart(yO,vmax) withpen pencircle scaled 2pt;
+ olddraw borney[xpart sensborne@#](vmin) withpen pencircle scaled 2pt;
+ olddraw borney[ypart sensborne@#](vmax) withpen pencircle scaled 2pt);
$
enddef;
@@ -1574,12 +1681,12 @@ vardef boitemoustache(text t)=
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)%
+ oldfill fullcircle scaled 3 shifted _cart(_valeursboitemoustache_[1],yO);
+ olddraw _cart(_valeursboitemoustache_[1],yO)--_cart(_valeursboitemoustache_[2],yO);
+ olddraw _cart(_valeursboitemoustache_[2],yO) shifted (0,-_largboitemoustache_/2)--_cart(_valeursboitemoustache_[2],yO) shifted (0,_largboitemoustache_/2)--_cart(_valeursboitemoustache_[4],yO) shifted (0,_largboitemoustache_/2)--_cart(_valeursboitemoustache_[4],yO) shifted (0,-_largboitemoustache_/2)--cycle;
+ olddraw _cart(_valeursboitemoustache_[3],yO) shifted (0,-_largboitemoustache_/2)--_cart(_valeursboitemoustache_[3],yO) shifted (0,_largboitemoustache_/2);
+ olddraw _cart(_valeursboitemoustache_[4],yO)--_cart(_valeursboitemoustache_[5],yO);
+ oldfill fullcircle scaled 3 shifted _cart(_valeursboitemoustache_[5],yO)%
) shifted (0,_decboitemoustache_);
$
enddef;
@@ -1615,15 +1722,232 @@ vardef projboitemoustache@#(text t)=
$=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)
+ A:=_cart(_valeursboitemoustache_[i],yO) shifted(0,_decboitemoustache_)
+ else: A:=_cart(_valeursboitemoustache_[i],yO) shifted(0,_decboitemoustache_-_largboitemoustache_/2)
fi;
- draw projectionx@#(A,_lab_[i]);
+ draw projectionx@#(A transformed inverse _T,_lab_[i]);
endfor);
$
enddef;
+numeric diampointsbatons;
+diampointsbatons:=5;
+
+vardef diagrammebatons(text t) =
+ save $;
+ picture $;
+ numeric tmp_taillepoint;
+ string tmp_marque_p;
+ tmp_taillepoint:=taillepoint;
+ tmp_marque_p := marque_p;
+ $=image(%
+ interim linecap:=butt;
+ marque_p:="plein";
+ taillepoint:=diampointsbatons*0.5;
+ for i=t:
+ draw i--projetex(i);
+ MarquePoint(i);
+ endfor
+ );
+ taillepoint:=tmp_taillepoint;
+ marque_p := tmp_marque_p;
+ $
+enddef;
+
+
+numeric largbarres;
+largbarres := 20;
+
+def barrei(expr p)=
+ (projetex(_cart(p)-0.5(largbarres,0))--(_cart(p)-0.5(largbarres,0))--(_cart(p)+0.5(largbarres,0))--projetex(_cart(p)+0.5(largbarres,0))) transformed inverse _T
+enddef;
+
+vardef diagrammebarres(text t)=
+ save $;
+ path $;
+ $:= for i=t: barrei(i)-- endfor cycle;
+ $
+enddef;
+
+
+vardef diagrammebinomiale(expr n,p)=
+ save $,Abin;
+ picture $;
+ pair Abin[];
+ $:=scantokens("diagrammebatons("&
+ "(0," & decimal(binomiale(n,p,0)) & ")" &
+ for i=0 upto n: ",(" & decimal(i) & "," & decimal(binomiale(n,p,i)) & ")" &
+ endfor
+ ")");
+ $
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%% POLYGONES %%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+vardef polygone(text t)=
+ save poly;
+ path poly;
+ poly :=
+ for i=t:
+ i--
+ endfor
+ cycle;
+ poly
+enddef;
+
+if not known typetrace:
+ vardef triangle(expr A,B,C)=
+ polygone(A,B,C)
+ enddef;
+fi
+
+vardef parallelogramme(expr A,O,B)=
+ O--A--(A+B-O)--B--cycle
+enddef;
+
+vardef polygoneregulier(expr A,B,n)=
+ save poly,centre;
+ path poly;pair centre;
+ _cart(B)-centre = (_cart(A)-centre) rotated (360/n);
+ poly:= _cart(A)
+ for i = 1 upto n-1:
+ -- (_cart(A) rotatedaround(centre,(i*360)/n))
+ endfor
+ --cycle;
+ poly transformed inverse _T
+enddef;
+
+vardef equilateral(expr A,B)=
+ polygoneregulier(A,B,3)
+enddef;
+
+vardef carre(expr A,B)=
+ polygoneregulier(A,B,4)
+enddef;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%% CERCLES ET ARCS %%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+vardef arccercle(expr A,O,B)=
+ path tmp,arc;
+ tmp:=fullcircle scaled (2*(abs(_cart(A)-_cart(O)))) rotated angle(_cart(A)-_cart(O)) shifted _cart(O);
+ if angle(_cart(B)-_cart(O))>angle(_cart(A)-_cart(O)):
+ arc:=subpath(0,(angle(_cart(B)-_cart(O))-angle(_cart(A)-_cart(O)))*(length tmp)/360) of tmp;
+ else:
+ arc:=subpath(0,(360-(angle(_cart(A)-_cart(O))-angle(_cart(B)-_cart(O))))*(length tmp)/360) of tmp;
+ fi
+ arc transformed inverse _T
+enddef;
+
+vardef cerclecr(expr O,r)=
+ fullcircle scaled (2*r*Ux) shifted _cart(O) transformed inverse _T
+enddef;
+
+vardef cerclecp(expr O,A)=
+ fullcircle scaled (2*abs(_cart(A)-_cart(O))) shifted _cart(O) transformed inverse _T
+enddef;
+
+vardef cerclecir(expr A,B,C)=
+ save O;pair O;
+ _cart(O)-0.5[_cart(A),_cart(B)]=whatever * (_cart(B)-_cart(A)) rotated 90;
+ _cart(O)-0.5[_cart(A),_cart(C)]=whatever * (_cart(C)-_cart(A)) rotated 90;
+ cerclecp(O,A)
+enddef;
+
+vardef cercle(text t)=
+ save $;path $;
+ save r;boolean r;
+ r:=false;
+ if long_texte(t)=3:
+ $:=cerclecir(t)
+ else:
+ for i=t:
+ if numeric i: r:=true fi;
+ endfor
+ if r: $:=cerclecr(t) else: $:=cerclecp(t) fi;
+ fi;
+ $
+enddef;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%% MARQUES ANGLES, SEGMENTS... %%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+taille_marque_a:=0.4cm;
+sep_marque_a:=1.5;
+
+
+vardef arc_marqueangle(expr A,O,B,t)=
+ arccercle((_cart(O)+t*unitvector(_cart(A)-_cart(O))) transformed inverse _T,O,(_cart(O)+t*unitvector(_cart(B)-_cart(O))) transformed inverse _T)
+enddef;
+
+vardef marqueanglegeo(expr A,O,B,n)=
+ O--arc_marqueangle(A,O,B,taille_marque_a-(n-1)*sep_marque_a/2)
+ for i=1 upto n-1:
+ --reverse arc_marqueangle(A,O,B,taille_marque_a-(n-1)*sep_marque_a/2+(i-1)*sep_marque_a)--
+ arc_marqueangle(A,O,B,taille_marque_a-(n-1)*sep_marque_a/2+i*sep_marque_a)
+ endfor
+ --cycle
+enddef;
+
+
+vardef marqueangleor(expr A,O,B)=
+ arc_marqueangle(A,O,B,taille_marque_a)
+enddef;
+
+vardef marqueangle(text t)=
+ if long_texte(t)=4: marqueanglegeo(t)
+ else: marqueangleor(t)
+ fi
+enddef;
+
+vardef nommeangle@#(expr A,O,B,p)=
+ save P,a;pair P;path a;
+ a:=arc_marqueangle(A,O,B,taille_marque_a);
+ P:= point (arctime 0.5*arclength a of a) of a;
+ if string p: thelabel@#(p,P)
+ else: thelabel@#(p scaled defaultscale,P)
+ fi
+enddef;
+
+
+
+taille_marque_ad:=0.3cm;
+
+vardef marqueangledroit(expr A,O,B)=
+ parallelogramme((_cart(O)+taille_marque_ad*unitvector(_cart(A)-_cart(O))) transformed inverse _T,O,(_cart(O)+taille_marque_ad*unitvector(_cart(B)-_cart(O))) transformed inverse _T)
+enddef;
+
+taille_marque_s:=0.3cm;
+angle_marque_s:=60;
+sep_marque_s:=2;
+
+vardef milieu(expr A,B)=
+ 0.5[A,B]
+enddef;
+
+vardef marqueunique_s(expr A,B)=
+ ((-taille_marque_s*unitvector(_cart(A)-_cart(B))/2)--(taille_marque_s*unitvector(_cart(A)-_cart(B))/2)) rotated angle_marque_s
+enddef;
+
+vardef marquesegment(expr A,B,n)=
+ save $;
+ picture $;
+ $=image(
+ for i=1 upto n:
+ draw marqueunique_s(A,B) shifted ((i-1-(n-1)/2)*sep_marque_s*unitvector(_cart(B)-_cart(A))) transformed inverse _T;
+ endfor
+ );
+ $ shifted milieu(_cart(A),_cart(B))
+enddef;
+
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% FONCTIONS USUELLES %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1677,13 +2001,13 @@ 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);
+ for j=0 upto _hautcadre_/haut:
+ olddraw ((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);
+ for i=0 upto _largcadre_/larg:
+ olddraw ((0,0)--(0,haut)) shifted (i*larg+d,j*haut);
endfor;
- endfor) shifted llcorner cadre
+ endfor) shifted llcorner _cart(cadre)
enddef;
@@ -1700,9 +2024,9 @@ 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
+ for i=floor(-_diag_/(2*pas)) upto ceiling(_diag_/(2*pas)):
+ olddraw ((-_diag_/2,0)--(_diag_/2,0)) shifted (0,i*pas);
+ endfor) rotated angle shifted center _cart(cadre)
enddef;
numeric pervagues,ampvagues,decvagues;
@@ -1719,11 +2043,11 @@ 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);
+ for j=0 upto _hautcadre_/dec:
+ for i=0 upto _largcadre_/amp:
+ olddraw ((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
+ endfor) shifted llcorner _cart(cadre)
enddef;
@@ -1732,7 +2056,7 @@ primarydef p avec c =
save _des_;
picture _des_;
_des_:=c;
- clip _des_ to p;
+ clip _des_ to (p transformed _T);
_des_
endgroup
enddef;
@@ -1749,12 +2073,7 @@ 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)=
@@ -1777,67 +2096,29 @@ def LaTeXsetup =
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_packages:=latexmp_packages & ",textcomp,mathtools,mathrsfs,esvect[e],siunitx[output-decimal-marker={,}],babel[french]";
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
+vardef LaTeX primary sc =
+ if known mplib: textext(sc) scaled defaultscale
+ else: LaTeXsetup; textext(sc) scaled defaultscale
fi
enddef;
+%vardef LaTeX primary sc =
+% LaTeXsetup; textext(sc) scaled defaultscale
+%enddef;
%%%%%%%%%%%%%%%Figure intermédiaire%%%%%%%%%%%%%%%%%%%
def figureinter=
- clip currentpicture to cadre;
+ clip currentpicture to (cadre transformed _T);
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;
@@ -1865,6 +2146,8 @@ vardef _chaine(suffix s)= %met les termes en indice si le 2e est un chiffre
enddef;
+%%%%%%%%%%%%%%% MATHS %%%%%%%%%%%%%%%%%
+
vardef arrondi(expr p,x)= %arrondi de x au p-ième
round((x-floor(x))*p)/p+floor(x)
enddef;
@@ -1886,6 +2169,44 @@ vardef pgcd(expr a,b)=
b_
enddef;
+vardef factorielle(expr n)= % Calcul de n!
+ save $;
+ numeric $;
+ $:= 1 for i=1 upto n: * i endfor;
+ $
+enddef;
+
+vardef binom(expr n,k)= % calcul du coefficient binomial k parmi n
+ save $,p;
+ numeric $,p;
+ p:= min(k,n-k);
+ $:=1;
+ for i=1 upto p:
+ $:= ($*(n-i+1))/i;
+ endfor
+ $
+enddef;
+
+vardef binomiale(expr n,p,k)=
+ save $,ktmp,ptmp;
+ numeric $,ktmp,ptmp;
+ if k>n-k:
+ ktmp:=n-k;
+ ptmp:=1-p
+ else:
+ ktmp:=k;
+ ptmp:=p
+ fi;
+ $:=1;
+ for i=1 upto ktmp:
+ $:=((n-i+1)/i)*ptmp*$;
+ endfor
+ for i=1 upto n-ktmp:
+ $:=$*(1-ptmp);
+ endfor
+ $
+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;