From 8c61583f287fdb41a4feeae16e896e365a2d09a5 Mon Sep 17 00:00:00 2001 From: Jean-Michel Sarlat Date: Thu, 11 Aug 2011 09:31:38 +0200 Subject: [PATCH 1/1] =?utf8?q?R=C3=A9initialisation=20du=20projet?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README | 2 + gdd-arc.mp | 13 +++ gdd-c2d.mp | 32 ++++++ gdd-fct.mp | 22 ++++ gdd-lbl.mp | 72 ++++++++++++ gdd-plt.mp | 65 +++++++++++ gdd-rep.mp | 98 ++++++++++++++++ gdd-tra.mp | 44 +++++++ gdd.mp | 328 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 676 insertions(+) create mode 100644 README create mode 100644 gdd-arc.mp create mode 100644 gdd-c2d.mp create mode 100644 gdd-fct.mp create mode 100644 gdd-lbl.mp create mode 100644 gdd-plt.mp create mode 100644 gdd-rep.mp create mode 100644 gdd-tra.mp create mode 100644 gdd.mp diff --git a/README b/README new file mode 100644 index 0000000..b251799 --- /dev/null +++ b/README @@ -0,0 +1,2 @@ + + * jeu. 11 août 2011 09:31:08 CEST : Réinitialisation du projet. \ No newline at end of file diff --git a/gdd-arc.mp b/gdd-arc.mp new file mode 100644 index 0000000..8558c54 --- /dev/null +++ b/gdd-arc.mp @@ -0,0 +1,13 @@ +if unknown Pi: input gdd-fct; fi; + +%%% -------------------------------------------------------------------------- +%%% Arcs de cercles +%%% -------------------------------------------------------------------------- + +vardef Arc(expr c,r,a,b) = + save centre, pas; pair centre; centre = PairImp(c); pas =(b-a)/10; + (centre+r*(cos(a),sin(a))) for i=0 upto 10: .. (centre+r*(cos(a+i*pas),sin(a+i*pas))) endfor +enddef; + + +endinput \ No newline at end of file diff --git a/gdd-c2d.mp b/gdd-c2d.mp new file mode 100644 index 0000000..e2a0035 --- /dev/null +++ b/gdd-c2d.mp @@ -0,0 +1,32 @@ +%%% -------------------------------------------------------------------------- +%%% mp-gdd %%% Courbes du second degré +%%% -------------------------------------------------------------------------- + +if unknown Pi: input gdd-fct; fi; + +%%% -------------------------------------------------------------------------- +%%% Paraboles +%%% -------------------------------------------------------------------------- + +% Parabole par Foyer-Directrice. + +gddParabolePar := 15; + +vardef ParaboleFD(expr F,D) = + save u, v, w, d, i; + (u,v,w) = EquationDroite(D); + d := u * gddA[F] + v * gddB[F] + w; + i := -gddParabolePar-1; + ( + (i*(v,-u)+((i*i-d*d)/(2d))*(u,v)) + for i:= -gddParabolePar upto gddParabolePar: + ..(i*(v,-u)+((i*i-d*d)/(2d))*(u,v)) + endfor + ) shifted PairImp(F) +enddef; + +% Parabole par Foyer-Sommet +vardef ParaboleFS(expr F,S) = +enddef; + +endinput \ No newline at end of file diff --git a/gdd-fct.mp b/gdd-fct.mp new file mode 100644 index 0000000..5ce866c --- /dev/null +++ b/gdd-fct.mp @@ -0,0 +1,22 @@ +numeric Pi; +numeric E; + +Pi := 3.14159265; +E := 2.71828183; + +vardef sin(expr x) = sind(x/Pi*180) enddef; +vardef cos(expr x) = cosd(x/Pi*180) enddef; +vardef tan(expr x) = sin(x)/cos(x) enddef; + +vardef exp(expr x) = E**x enddef; + +vardef ln(expr x) = mlog(x)/256 enddef; +vardef ch(expr x) = (E**x + E**(-x))/2 enddef; +vardef sh(expr x) = (E**x - E**(-x))/2 enddef; +vardef th(expr x) = (E**(2*x) - 1)/(E**(2*x) + 1) enddef; + +vardef arcsin(expr t) = angle((sqrt(1-t**2),t)) / 180 * Pi enddef; +vardef arccos(expr t) = angle(t,(sqrt(1-t**2))) / 180 * Pi enddef; +vardef arctan(expr t) = angle(1,t) / 180 * Pi enddef; + +endinput \ No newline at end of file diff --git a/gdd-lbl.mp b/gdd-lbl.mp new file mode 100644 index 0000000..f9b4a74 --- /dev/null +++ b/gdd-lbl.mp @@ -0,0 +1,72 @@ +string lblPreambule, lblLocal; +lblPreambule := "\usepackage[frenchb]{babel}\usepackage[garamond]{mathdesign}\usepackage{amsmath}\usepackage{mflogo}"; +lblLocal := ""; + +string lblS[]; +lblS[0] = "alpha"; +lblS[1] = "beta"; +lblS[2] = "gamma"; +lblS[3] = "delta"; +lblN = 3; + +vardef scanchaine_label(expr s) = + save d,m,f,c,l,flag,i; string d,m,f,c; + d := ""; m := ""; f := ""; + l = length(s); flag := 0; + for i:=0 upto l: + c := substring (i,i+1) of s; + if c = "'": + f := f & c; flag := 2; + elseif c = "_": + flag := 1; + else: + if flag = 0: + d := d & c + else: + m := m & c + fi; + fi + endfor; + for i:=0 upto lblN: + if d = lblS[i]: d := "\" & d fi + endfor; + d := d & "_{" & m & "}" & f; d +enddef; + +vardef lTEX primary s = + write "verbatimtex" to "mptextmp.mp"; + write "%&latex" to "mptextmp.mp"; + write "\documentclass{article}" to "mptextmp.mp"; + write lblPreambule to "mptextmp.mp"; + write lblLocal to "mptextmp.mp"; + write "\begin{document}" to "mptextmp.mp"; + write "etex" to "mptextmp.mp"; + write "btex $"& scanchaine_label(s) &"$ etex" to "mptextmp.mp"; + write EOF to "mptextmp.mp"; + scantokens "input mptextmp" +enddef; + +vardef TEX primary s = + write "verbatimtex" to "mptextmp.mp"; + write "%&latex" to "mptextmp.mp"; + write "\documentclass{article}" to "mptextmp.mp"; + write lblPreambule to "mptextmp.mp"; + write lblLocal to "mptextmp.mp"; + write "\begin{document}" to "mptextmp.mp"; + write "etex" to "mptextmp.mp"; + write "btex "& s &" etex" to "mptextmp.mp"; + write EOF to "mptextmp.mp"; + scantokens "input mptextmp" +enddef; + + +vardef Etiquette.@#(expr s,t,p) = label.@#(TEX(s) scaled t,p gddEnPlace) enddef; + + + +vardef FICHIER primary s = + save _s; string _s; _s = "input " & s; + scantokens _s +enddef; + +endinput \ No newline at end of file diff --git a/gdd-plt.mp b/gdd-plt.mp new file mode 100644 index 0000000..8e8d288 --- /dev/null +++ b/gdd-plt.mp @@ -0,0 +1,65 @@ +if unknown Pi: input gdd-fct; fi; +if unknown repSavePict: input gdd-rep; fi; + +% +% Courbe paramétrée +% ------------------------------------------------------------------------------ +vardef Courbe(suffix fx)(suffix fy)(expr ti,tf,n) = + save fpas; fpas := (tf-ti)/n; + (fx(ti),fy(ti)) for i=1 upto n: ..(fx(ti+i*fpas),fy(ti+i*fpas)) endfor +enddef; + +% +% Représentation de fonction +% ------------------------------------------------------------------------------ +vardef Representation(suffix f)(expr ti,tf,n) = + save fpas; + fpas := (tf-ti)/n; + (ti,f(ti)) for i=1 upto n: ..(ti+i*fpas,f(ti+i*fpas)) endfor +enddef; + +% +% Courbe en polaire +% ------------------------------------------------------------------------------ +vardef CourbeEnPolaires(suffix r)(expr ti,tf,n) = + save fpas,t; + fpas := (tf-ti)/n; + r(ti)*(cos(ti),sin(ti)) + for i=1 upto n: hide(t:=ti+i*fpas) .. r(t)*(cos(t),sin(t)) endfor +enddef; + +% +% Champs de vecteurs +% ------------------------------------------------------------------------------ +vardef ChampVecteurs(suffix f)(expr x,y,px,py,dx,couleur) = + for i = 0 upto (x - repXmin)/px: + for j = 0 upto (y - repYmin)/py: + drawarrow + (((0,0)--dx*unitvector((1,f(x-i*px,y-j*py)))) + shifted (x-i*px,y-j*py)) gddEnPlace + withcolor couleur; + endfor + for j = 0 upto (repYmax - y)/py: + drawarrow + (((0,0)--dx*unitvector((1,f(x-i*px,y+j*py)))) + shifted (x-i*px,y+j*py)) gddEnPlace + withcolor couleur; + endfor + endfor + for i = 0 upto (repXmax - x)/px: + for j = 0 upto (y - repYmin)/py: + drawarrow + (((0,0)--dx*unitvector((1,f(x+i*px,y-j*py)))) + shifted (x+i*px,y-j*px)) gddEnPlace + withcolor couleur; + endfor + for j = 0 upto (repYmax - y)/py: + drawarrow + (((0,0)--dx*unitvector((1,f(x+i*px,y+j*py)))) + shifted (x+i*px,y+j*py)) gddEnPlace + withcolor couleur; + endfor + endfor +enddef; + +endinput; \ No newline at end of file diff --git a/gdd-rep.mp b/gdd-rep.mp new file mode 100644 index 0000000..92bbf9d --- /dev/null +++ b/gdd-rep.mp @@ -0,0 +1,98 @@ +picture repSavePict; +string repSaveW; + +def Repere(expr l,h,ox,oy,ux,uy) = + repLargeur := l; repHauteur := h; + repOX := ox ; repOY := oy; + repXmin := - ox / ux; repXmax := repXmin + l / ux; + repYmin := - oy / uy; repYmax := repYmin + h / uy; + repUX := ux; repUY := uy; + repSaveW := gddW; + gddW := "xscaled repUX yscaled repUY shifted (repOX,repOY) scaled gddU"; +enddef; + +def Debut = + repSavePict := currentpicture; currentpicture := nullpicture; +enddef; + +def repClip = + clip currentpicture to + ((0,0)--(repLargeur,0)--(repLargeur,repHauteur)--(0,repHauteur)--cycle) + scaled gddU; +enddef; + +def repStroke (expr c) = + draw ((0,0)--(repLargeur,0)--(repLargeur,repHauteur)--(0,repHauteur)--cycle) + scaled gddU withcolor c; +enddef; + +def Fin = + repClip; addto repSavePict also currentpicture; currentpicture := repSavePict; + gddW := repSaveW; +enddef; + +def Axes = + drawarrow ((repXmin,0)--(repXmax,0)) gddEnPlace; + drawarrow ((0,repYmin)--(0,repYmax)) gddEnPlace; + label.lrt(TEX("$x$"),(repXmax,0) gddEnPlace); + label.ulft(TEX("$y$"),(0,repYmax) gddEnPlace); +enddef; + +vardef Graduations = + save xmin, xmax, ymin, ymax; + xmin = floor(repXmin); xmax = floor(repXmax) + 1; + ymin = floor(repYmin); ymax = floor(repYmax) + 1; + SequenceTirets((xmin,0),(1,0),(0,-4),xmax-xmin+1); + SequenceTirets((xmin+0.5,0),(1,0),(0,-2),xmax-xmin); + SequenceTirets((0,ymin),(0,1),(-4,0),ymax-ymin+1); + SequenceTirets((0,ymin+0.5),(0,1),(-2,0),ymax-ymin); +enddef; + +def ClipRepere = + extra_endfig := extra_endfig & "repClip;"; +enddef; + +% +% SequenceTirets +% ------------------------------------------------------------------------------ +vardef SequenceTirets(expr o,p,t,n) text a= + save ot; pair ot; ot := o gddEnPlace; + for i:=1 upto n: + % tiret + draw ot -- (ot shifted t) a; + % avancement + ot := (o + i*p) gddEnPlace; + endfor +enddef; + +vardef Unites(expr t) = + if t=1: + label.bot(TEX("$+1$"),(1,-(3/gddU/repUY)) gddEnPlace); + label.ulft(TEX("$+1$"),(-(3/gddU/repUX),1) gddEnPlace); + fi +enddef; + +%%% ---------------------------------------------------------------------------- +%%% Grille +%%% ---------------------------------------------------------------------------- + +def GrilleRepere = + save xmin, xmax, ymin, ymax; + xmin = floor(repXmin); xmax = floor(repXmax) + 1; + ymin = floor(repYmin); ymax = floor(repYmax) + 1; + for i:=xmin upto xmax: + draw ((i,ymin)--(i,ymax)) gddEnPlace; + endfor; + for i:=ymin upto ymax: + draw ((xmin,i)--(xmax,i)) gddEnPlace; + endfor; +enddef; + +%%% ---------------------------------------------------------------------------- +%%% CadreRepere +%%% ---------------------------------------------------------------------------- +def CadreRepere = + (repXmin,repYmin)--(repXmin,repYmax)--(repXmax,repYmax)--(repXmax,repYmin)--cycle +enddef; + +endinput \ No newline at end of file diff --git a/gdd-tra.mp b/gdd-tra.mp new file mode 100644 index 0000000..48801cd --- /dev/null +++ b/gdd-tra.mp @@ -0,0 +1,44 @@ +%% === Pseudo-transparence ===================================================== +%% Code emprunté à Anthony Phan : +%% http://www-math.univ-poitiers.fr/~phan/metalpha.html + +color gdd_tc; +numeric gdd_ta; +picture gdd_ap; + +def gdd_AlphaFill expr c = + gdd_ap := nullpicture; + gdd_AlphaPicture(currentpicture,c); + addto currentpicture also gdd_ap; +enddef; + +vardef gdd_AlphaPicture(expr p,c) = + save p_; picture p_; + p_ := nullpicture; + addto p_ contour c withcolor gdd_ta[background,gdd_tc]; + for p__ within p: + if (not clipped p__) and (not bounded p__): + addto p_ also p__ withcolor + gdd_ta[(redpart p__,greenpart p__,bluepart p__), gdd_tc]; + else: + begingroup save gdd_ap; + picture gdd_ap; gdd_ap = nullpicture; + gdd_AlphaPicture(p__,pathpart p__); + addto p_ also gdd_ap; + endgroup; + fi + endfor; + clip p_ to c; + addto gdd_ap also p_; +enddef; + +vardef ColorieAvecTransparence(expr p,c,a) = + gdd_tc := c; gdd_ta := a; + if path p: + gdd_AlphaFill (p gddEnPlace) + else: + gdd_AlphaFill ((gddTraceObjet p) gddEnPlace) + fi +enddef; + +endinput; \ No newline at end of file diff --git a/gdd.mp b/gdd.mp new file mode 100644 index 0000000..4cd4fe2 --- /dev/null +++ b/gdd.mp @@ -0,0 +1,328 @@ +input graph; + +%%% ---------------------------------------------------------------------------- +%%% Déclarations +%%% ---------------------------------------------------------------------------- + +numeric gddA[]; +numeric gddB[]; +numeric gddC[]; +numeric gddD[]; +numeric gddE[]; +numeric gddF[]; +picture gddL[]; % Table des labels TeX (btex .. etex) +numeric gddO; % Compteur des objets +path gddP[]; % Table des chemins (paths internes) +string gddS[]; % Table des chaînes (noms de fichiers) +string gddT[]; % Table des types +numeric gddU; % Unité graphique +string gddW; % Chaîne spécifiant le placement des objets + +%%% ---------------------------------------------------------------------------- +%%% Initialisations +%%% ---------------------------------------------------------------------------- + +% Initialisation de gddO ------------------------------------------------------- +gddO := 0; + +% Valeur par défaut de gddU ---------------------------------------------------- +gddU := 1cm; + +% Initialisation de gddW et procédure associée --------------------------------- +gddW = "scaled gddU"; +def gddEnPlace = scantokens gddW enddef; + +%%% ---------------------------------------------------------------------------- +%%% Définition des objets +%%% ---------------------------------------------------------------------------- + +% Point ------------------------------------------------------------------------ +vardef Point(expr a,b) = + gddT[incr gddO] = "point"; + gddA[gddO] = a; gddB[gddO] = b; gddO +enddef; + +vardef PointDansRepere(expr x,y,o,i,j) = + gddT[incr gddO] = "point"; + gddA[gddO] = gddA[o] + x*(gddA[i]-gddA[o]) + y*(gddA[j]-gddA[o]); + gddB[gddO] = gddB[o] + x*(gddB[i]-gddB[o]) + y*(gddB[j]-gddB[o]); + gddO +enddef; + +vardef CoordonneesRepere(expr m,o,i,j) = + save x,y; numeric x,y; + gddA[m] = (gddA[i]-gddA[o])*x + (gddA[j]-gddA[o])*y + gddA[o]; + gddB[m] = (gddB[i]-gddB[o])*x + (gddB[j]-gddB[o])*y + gddB[o]; + (x,y) +enddef; + +vardef Milieu(expr a,b) = + gddT[incr gddO] = "point"; + gddA[gddO] = 0.5*(gddA[a]+gddA[b]); + gddB[gddO] = 0.5*(gddB[a]+gddB[b]); + gddO +enddef; + +% Transformations pair <-> Point ----------------------------------------------- +def PointTOPair(expr a) = (gddA[a],gddB[a]) enddef; +def PairTOPoint(expr p) = Point(xpart p,ypart p) enddef; +def PairImp(expr a) = if pair a: a else: PointTOPair(a) fi enddef; +def PointImp(expr a) = if pair a: PairTOPoint(a) else: a fi enddef; +def Pt(expr a) = (gddA[a],gddB[a]) enddef; +def PtR(expr a) = (gddA[a],gddB[a]) gddEnPlace enddef; + + +% Addition --------------------------------------------------------------------- +vardef AdditionAbscisses(expr a,b) = if pair a: xpart a else: gddA[a] fi + if pair b: xpart b else: gddA[b] fi enddef; +vardef AdditionOrdonnees(expr a,b) = if pair a: ypart a else: gddB[a] fi + if pair b: ypart b else: gddB[b] fi enddef; +vardef Addition(expr a,b) = + gddT[incr gddO] = "paire"; + gddA[gddO] = AdditionAbscisses(a,b); + gddB[gddO] = AdditionOrdonnees(a,b); + gddO +enddef; + +% Vecteur ---------------------------------------------------------------------- +vardef Vecteur (expr a,b) = + save n; n = incr gddO; + gddT[n] = "vecteur"; gddA[n] = PointImp(a); gddB[n] = PointImp(b); n +enddef; + + +% Segment ---------------------------------------------------------------------- +vardef Segment (expr a,b) = + save n; n = incr gddO; + gddT[n] = "segment"; gddA[n] = PointImp(a); gddB[n] = PointImp(b); n +enddef; + +% Triangle --------------------------------------------------------------------- +vardef Triangle (expr a,b,c) = + save n; n = incr gddO; gddT[n] = "triangle"; + gddA[n] = PointImp(a); gddB[n] = PointImp(b); gddC[n] = PointImp(c); n +enddef; + +% Droite ----------------------------------------------------------------------- +vardef Droite (expr a,b) = + save n; n = incr gddO; + gddT[n] = "droite"; gddA[n] = PointImp(a); gddB[n] = PointImp(b); n +enddef; + +% Équation de droite : triplet (u,v,w) tel que ux+vy+w=0 ----------------------- +% L'équation rendue est normalisée ! +vardef EquationDroite(expr d) = + save u, v, w, n; + u := gddB[gddB[d]] - gddB[gddA[d]]; + v := gddA[gddA[d]] - gddA[gddB[d]]; + w := - u * gddA[gddA[d]] - v * gddB[gddA[d]]; + n := u ++ v; + (u/n,v/n,w/n) +enddef; + +% Ordonnée relative à une droite orientée -------------------------------------- +vardef OrdonneeRelativePointDroite(expr p, d) = + savec u, v, w; + (u,v,w) = EquationDroite(d); + u * gddA[p] + v * gddB[p] + w +enddef; + +% Distance d'un point à une droite --------------------------------------------- +def DistancePointDroite(expr p, d) = + abs(OrdonneeRelativePointDroite(p, d)) +enddef; + +% Projection d'un point sur une droite ----------------------------------------- +vardef ProjectionPointSurDroite(expr p, d) = + save u,v,w, l; + (u,v,w) = EquationDroite(d); + l := - u * gddA[p] - v * gddB[p] - w; + Point(gddA[p] + l * u, gddB[p] + l * v) +enddef; + +% Cercles ---------------------------------------------------------------------- +vardef Cercle (expr a,b) = + save n; n = incr gddO; + gddT[n] = "cercle"; gddA[n] = PointImp(a); gddB[n] = b; n +enddef; + +vardef CercleCP(expr a,b) = Cercle(a,abs(Pt(a)-Pt(b))) enddef; +vardef CercleD(expr a,b) = CercleCP(Milieu(a,b),a) enddef; + +% Tangente commune extérieure à deux cercles ----------------------------------- +vardef TangenteCommuneExterieure(expr a, b) = + save O, A, d, f; pair O, A; + O = (gddB[a]/(gddB[a]-gddB[b]))[Pt(gddA[a]),Pt(gddA[b])]; % Centre de l'homothétie + d = abs(O-Pt(gddA[a])); + f := if gddA[a] < gddA[b] : 1 else: -1 fi; + A = Pt(gddA[a]) rotatedaround(O,angle(d+-+gddB[a],f*gddB[a])); + Droite(O,A) +enddef; + +% Intersection de deux cercles ------------------------------------------------- +vardef IntersectionCercles(expr a, b) = + save d, x, y, u; pair u; + u = unitvector(Pt(gddA[b])-Pt(gddA[a])); + d = abs(Pt(gddA[a])-Pt(gddA[b])); + x = (gddB[a]**2-gddB[b]**2+d**2)/(2d); + y = gddB[a]+-+x; + PairTOPoint(Pt(gddA[a])+x*u+y*(u rotated 90)) +enddef; + + +% Chemin ----------------------------------------------------------------------- +vardef Chemin (expr p) = + gddT[incr gddO] = "chemin"; gddP[gddO] = p; gddO +enddef; + +% Courbe ----------------------------------------------------------------------- +vardef Courbe (expr s) = + gddT[incr gddO] = "courbe"; gddS[gddO] = s; gddO +enddef; + +%%% ---------------------------------------------------------------------------- +%%% Définitions liées au repère +%%% ---------------------------------------------------------------------------- + +% Définition de l'origine ------------------------------------------------------ +origine = Point(0,0); + +% Définition des axes ---------------------------------------------------------- +AxeOx = Droite(origin,right); +AxeOy = Droite(origin,up); + +%%% ---------------------------------------------------------------------------- +%%% Calculs MetaPost +%%% ---------------------------------------------------------------------------- + +vardef mpIntersectionDroites (expr a,b,c,d) = + save t; pair t; t = whatever [a,b]; t = whatever [c,d]; t +enddef; + +%%% -------------------------------------------------------------------------- +%%% Tracés des courbes +%%% -------------------------------------------------------------------------- +vardef gddTraceCourbe (expr f) = + save s; gdata(f, s, if i>1:..fi (scantokens s1,scantokens s2)) +enddef; + +%%% ---------------------------------------------------------------------------- +%%% Tracés des objets +%%% ---------------------------------------------------------------------------- + +gddExtensionDroite := 10; + +def gddTraceObjet expr o = + if gddT[o] = "triangle": + PointTOPair(gddA[o])--PointTOPair(gddB[o])-- + PointTOPair(gddC[o])--cycle + elseif (gddT[o] = "segment") or (gddT[o] = "vecteur"): + PointTOPair(gddA[o])--PointTOPair(gddB[o]) + elseif gddT[o] = "droite": + (gddExtensionDroite [ PointTOPair(gddA[o]), PointTOPair(gddB[o]) ]) -- + (gddExtensionDroite [ PointTOPair(gddB[o]), PointTOPair(gddA[o]) ]) + elseif gddT[o] = "cercle": + fullcircle scaled (gddB[o]*2) shifted PointTOPair(gddA[o]) + elseif gddT[o] = "chemin": + gddP[o] + elseif gddT[o] = "courbe": + gddTraceCourbe (gddS[o] & ".dta") + fi +enddef; + +def trace expr p = + if path p or picture p or pair p: draw (p) + elseif gddT[p] = "vecteur": drawarrow (gddTraceObjet p) + else: draw (gddTraceObjet p) + fi gddEnPlace +enddef; + +def fleche expr p = + if path p or picture p: drawarrow (p) + elseif gddT[p] = "vecteur": drawarrow (gddTraceObjet p) + else: drawarrow (gddTraceObjet p) + fi gddEnPlace +enddef; + +def colorie expr p = + if path p: fill p else: fill (gddTraceObjet p) fi gddEnPlace +enddef; + +def fermeture expr p = + if path p: p else: (gddTraceObjet p) fi -- cycle +enddef; + + +%%% -------------------------------------------------------------------------- +%%% Marque et label des points +%%% -------------------------------------------------------------------------- +gddTaillePoint := 3; % Diamètre des cercles marquant un point. +color gddCouleurPoint; % Couleur de fond de la marque d'un point. +gddCouleurPoint := white; +gddTailleLabel := 1.5; % Taille d'un label. + + +def gddPointe(expr p) = + fill (fullcircle scaled gddTaillePoint) shifted (p gddEnPlace) + withcolor gddCouleurPoint; + draw (fullcircle scaled gddTaillePoint) shifted (p gddEnPlace) +enddef; + +def pointe expr p = gddPointe(if pair p: p else: PointTOPair(p) fi) enddef; + +vardef m_arque.@# expr p = + pointe p; + label.@#(gddL[p] scaled gddTailleLabel,PointTOPair(p) gddEnPlace); +enddef; + +vardef m_a_rque.@# expr p = + pointe(scantokens p); + label.@#(lTEX(p),PointTOPair(scantokens p) gddEnPlace); +enddef; + +vardef marque.@# expr p = + if string p: m_a_rque.@# p else: m_arque.@# p fi +enddef; + +%%% -------------------------------------------------------------------------- +%%% Signes +%%% -------------------------------------------------------------------------- +def SigneOrtho(expr a,b,c,x) = + (_point_(b) + x * unitvector(_point_(a)-_point_(b))) + -- (_point_(b) + x * unitvector(_point_(a) - _point_(b)) + + x * unitvector(_point_(c) - _point_(b))) + -- (_point_(b) + x * unitvector(_point_(c) - _point_(b))) +enddef; + +picture gdd_marque[]; +gdd_marque1 = image(draw (-7,-7)--(7,7)); +gdd_marque2 = image(draw (-7,-7)--(7,7); draw (-7,7)--(7,-7)); +gdd_marque3 = image(draw (-9,-7)--(5,7); draw (-5,-7)--(9,7); + draw (-7,7)--(7,-7)); +gdd_marque4 = image(draw (-9,-7)--(5,7); draw (-5,-7)--(9,7); + draw (-9,7)--(5,-7); draw (-5,7)--(9,-7)); + +def Marque(expr a,b,n) = + gdd_marque[n] rotated angle(PairImp(b)-PairImp(a)) scaled (0.5/gddU) + shifted 0.5[PairImp(a),PairImp(b)] +enddef; + +%%% -------------------------------------------------------------------------- +%%% Fenêtrage +%%% -------------------------------------------------------------------------- + +def Fenetre(expr xg,yg,xd,yd) = + gddXG := xg; + gddYB := yg; + gddXD := xd; + gddYH := yd; + extra_endfig := "gddFenetre;" & extra_endfig; +enddef; + +def gddFenetre = + clip currentpicture to + ((gddXG,gddYB)--(gddXG,gddYH)--(gddXD,gddYH)--(gddXD,gddYB)--cycle) + gddEnPlace; + draw ((gddXG,gddYB)--(gddXG,gddYH)--(gddXD,gddYH)--(gddXD,gddYB)--cycle) + gddEnPlace withpen pencircle scaled 1 withcolor white; +enddef; + +endinput \ No newline at end of file -- 2.20.1