diff options
Diffstat (limited to 'macros/latex/contrib/profcollege/latex/PfCBillard.tex')
-rw-r--r-- | macros/latex/contrib/profcollege/latex/PfCBillard.tex | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/macros/latex/contrib/profcollege/latex/PfCBillard.tex b/macros/latex/contrib/profcollege/latex/PfCBillard.tex index 1dcde0e4c4..6faf803803 100644 --- a/macros/latex/contrib/profcollege/latex/PfCBillard.tex +++ b/macros/latex/contrib/profcollege/latex/PfCBillard.tex @@ -1,21 +1,31 @@ %%% % Billard %%% -\setKVdefault[ClesBillard]{Longueur=8cm,Largeur=5cm,Solution=false,Angle=70,Depart=0.5,Vrai=false} +\newtoks\tokPfCMotBillard{}% + +\def\UpdateTokBillard#1\nil{\addtotok\tokPfCMotBillard{"#1"}}% + +\setKVdefault[ClesBillard]{Longueur=8cm,Largeur=5cm,Solution=false,Angle=70,Depart=0.5,Vrai=false,Nom=JeuA,Creation=false} \NewDocumentCommand\Billard{o m}{% \useKVdefault[ClesBillard]% \setKV[ClesBillard]{#1}% + \tokPfCMotBillard{}% + \ifboolKV[ClesBillard]{Creation}{% + \expandafter\UpdateTokBillard#2\nil% + }{\tokPfCMotBillard{#2}}% \ifboolKV[ClesBillard]{Solution}{% - \MPBillardSolution{#2}{\useKV[ClesBillard]{Depart}}{\useKV[ClesBillard]{Angle}}% - }{% - \MPBillard{#2}{\useKV[ClesBillard]{Depart}}{\useKV[ClesBillard]{Angle}}% - }% + \MPBillardSolution{\the\tokPfCMotBillard}{\useKV[ClesBillard]{Depart}}{\useKV[ClesBillard]{Angle}}% + }{% + \MPBillard{\the\tokPfCMotBillard}{\useKV[ClesBillard]{Depart}}{\useKV[ClesBillard]{Angle}}% + }% }% \def\MPBillard#1#2#3{% - \mplibcodeinherit{disable}% - \begin{Geometrie}[CoinHD={(\useKV[ClesBillard]{Longueur}+2cm,\useKV[ClesBillard]{Largeur}+3cm)}] + \xdef\PfCNomBillard{\useKV[ClesBillard]{Nom}} + \mplibforcehmode + \begin{mplibcode}[\PfCNomBillard] + _tfig:=20cm; boolean Vrai; Vrai:=\useKV[ClesBillard]{Vrai}; % On définit la liste des 25 lettres alphabétiques dans laquelle on choisit autant de lettres que la longueur du mot @@ -113,6 +123,7 @@ cote4=segment(M4,M1); trace rec; pair Pt[],FauxPt[]; + numeric nbfaux,l[],angleref,angledepart,tourne; nbfaux=0; l1=#2; Pt[1]=point(l1) of rec; @@ -123,21 +134,22 @@ dotlabel.lft(TEX(substring(0,1) of #1),Pt[1]); elseif l1>2: angledepart=180+angleref; - Pt[2]=demidroite(Pt[1],rotation(M4,Pt1,angledepart)) intersectionpoint ((subpath(3,4) of rec)--(subpath(0,2) of rec)); + Pt[2]=demidroite(Pt[1],rotation(M3,Pt1,angledepart)) intersectionpoint ((subpath(3,4) of rec)--(subpath(0,2) of rec)); dotlabel.top(TEX(substring(0,1) of #1),Pt[1]); elseif l1>1: angledepart=angleref-90; - Pt[2]=demidroite(Pt[1],rotation(M3,Pt1,angledepart)) intersectionpoint ((subpath(2,4) of rec)--(subpath(0,1) of rec)); + Pt[2]=demidroite(Pt[1],rotation(M2,Pt1,angledepart)) intersectionpoint ((subpath(2,4) of rec)--(subpath(0,1) of rec)); dotlabel.rt(TEX(substring(0,1) of #1),Pt[1]); else: angledepart=angleref; Pt[2]=demidroite(Pt[1],rotation(M2,Pt1,angledepart)) intersectionpoint (subpath(1,4) of rec); dotlabel.bot(TEX(substring(0,1) of #1),Pt[1]); fi; + drawarrow Pt[1]--(Pt[1]+1.5cm*unitvector(Pt[2]-Pt[1])) withpen pencircle scaled 1.25; tourne=90; numeric Blong; BLong:=length #1; - % Détermination des points. + %% Détermination des points. if Vrai: for k=3 upto BLong: Intermed:=symetrie(Pt[k-2],Pt[k-1],Pt[k-1]+M2-M3); @@ -159,7 +171,7 @@ fi; endfor; fi; - % Ajout des faux points + %% Ajout des faux points path SPath[]; cpt[1]:=1; cpt[BLong+1]:=BLong+1; @@ -182,7 +194,7 @@ drawoptions(); % Tracés drawarrow Pt[1]--(Pt[1]+1.5cm*unitvector(Pt[2]-Pt[1])) withpen pencircle scaled 1.25; - % Labelisation + %% Labelisation for k=2 upto BLong: if (demidroite(1/1000[Pt[k-1],Pt[k]],Pt[k]) intersectiontimes cote[1])<>(-1,-1): dotlabel.bot(TEX(substring(k-1,k) of #1),Pt[k]); @@ -209,14 +221,17 @@ Reponse=image( trace segment((0,0),(7*BLong*mm-2mm,0)) dashed dashpattern(on5mm off2mm); ); - trace Reponse shifted((xpart(Co),5mm)-center Reponse); - \end{Geometrie}% + trace Reponse shifted((xpart(Co),5mm)-center Reponse); + clip currentpicture to polygone((0,0),(\useKV[ClesBillard]{Longueur}+2cm,0),(\useKV[ClesBillard]{Longueur}+2cm,\useKV[ClesBillard]{Largeur}+3cm),(0,\useKV[ClesBillard]{Largeur}+3cm)); + \end{mplibcode}% }% \def\MPBillardSolution#1#2#3{% - \mplibcodeinherit{enable}% - \begin{mplibcode}% - Figure(0,0,\useKV[ClesBillard]{Longueur}+2cm,\useKV[ClesBillard]{Largeur}+3cm); + % \mplibcodeinherit{enable}% + \mplibforcehmode + \xdef\PfCNomBillard{\useKV[ClesBillard]{Nom}} + \begin{mplibcode}[\PfCNomBillard] +% Figure(0,0,\useKV[ClesBillard]{Longueur}+2cm,\useKV[ClesBillard]{Largeur}+3cm); trace rec; % Tracés drawarrow Pt[1]--(Pt[1]+1.5cm*unitvector(Pt[2]-Pt[1])) withpen pencircle scaled 1.25; @@ -255,5 +270,5 @@ label.top(TEX(substring(k-1,k) of #1),((xpart(Co),5mm)-center Reponse)+(k-1)*(7mm,0)+(2.5mm,0)); endfor; \end{mplibcode}% - \mplibcodeinherit{disable}% +% \mplibcodeinherit{disable}% }%
\ No newline at end of file |