From: Maxime Chupin (escudo) Date: Sun, 1 Oct 2017 09:54:45 +0000 (+0200) Subject: Mobdification de Courbe en CourbeDat dans gdd.mp, ajout des variable gddXlabel et... X-Git-Url: https://melusine.eu.org/syracuse/G/git/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=mp-gdd.git Mobdification de Courbe en CourbeDat dans gdd.mp, ajout des variable gddXlabel et gddYlabel, ajout de la fonction ChampVecteurDD (dans R^2) --- diff --git a/gdd-plt.mp b/gdd-plt.mp index 8e8d288..4a64056 100644 --- a/gdd-plt.mp +++ b/gdd-plt.mp @@ -24,7 +24,7 @@ enddef; vardef CourbeEnPolaires(suffix r)(expr ti,tf,n) = save fpas,t; fpas := (tf-ti)/n; - r(ti)*(cos(ti),sin(ti)) + r(ti)*(cos(ti),sin(ti)) for i=1 upto n: hide(t:=ti+i*fpas) .. r(t)*(cos(t),sin(t)) endfor enddef; @@ -48,13 +48,13 @@ vardef ChampVecteurs(suffix f)(expr x,y,px,py,dx,couleur) = endfor for i = 0 upto (repXmax - x)/px: for j = 0 upto (y - repYmin)/py: - drawarrow + 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 + drawarrow (((0,0)--dx*unitvector((1,f(x+i*px,y+j*py)))) shifted (x+i*px,y+j*py)) gddEnPlace withcolor couleur; @@ -62,4 +62,39 @@ vardef ChampVecteurs(suffix f)(expr x,y,px,py,dx,couleur) = endfor enddef; -endinput; \ No newline at end of file + +% +% Champs de vecteurs f R^2 -> R^2 +% ------------------------------------------------------------------------------ +vardef ChampVecteursDD(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(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(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(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(f(x+i*px,y+j*py))) + shifted (x+i*px,y+j*py)) gddEnPlace + withcolor couleur; + endfor + endfor +enddef; + +endinput; diff --git a/gdd-rep.mp b/gdd-rep.mp index 92bbf9d..401e36a 100644 --- a/gdd-rep.mp +++ b/gdd-rep.mp @@ -1,6 +1,12 @@ picture repSavePict; string repSaveW; +% x and y labels +string gddXlabel; +gddXlabel := "$x$"; +string gddYlabel; +gddYlabel := "$y$"; + def Repere(expr l,h,ox,oy,ux,uy) = repLargeur := l; repHauteur := h; repOX := ox ; repOY := oy; @@ -34,8 +40,8 @@ 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); + label.lrt(TEX(gddXlabel),(repXmax,0) gddEnPlace); + label.ulft(TEX(gddYlabel),(0,repYmax) gddEnPlace); enddef; vardef Graduations = @@ -91,8 +97,8 @@ enddef; %%% ---------------------------------------------------------------------------- %%% CadreRepere %%% ---------------------------------------------------------------------------- -def CadreRepere = +def CadreRepere = (repXmin,repYmin)--(repXmin,repYmax)--(repXmax,repYmax)--(repXmax,repYmin)--cycle enddef; -endinput \ No newline at end of file +endinput diff --git a/gdd.mp b/gdd.mp index 4cd4fe2..bf6bfb2 100644 --- a/gdd.mp +++ b/gdd.mp @@ -174,7 +174,7 @@ vardef Chemin (expr p) = enddef; % Courbe ----------------------------------------------------------------------- -vardef Courbe (expr s) = +vardef CourbeDat (expr s) = gddT[incr gddO] = "courbe"; gddS[gddO] = s; gddO enddef; @@ -224,7 +224,8 @@ def gddTraceObjet expr o = elseif gddT[o] = "chemin": gddP[o] elseif gddT[o] = "courbe": - gddTraceCourbe (gddS[o] & ".dta") + %message "This is a debug message."; + gddTraceCourbe (gddS[o] & ".dat") fi enddef; @@ -261,7 +262,7 @@ gddTailleLabel := 1.5; % Taille d'un label. def gddPointe(expr p) = - fill (fullcircle scaled gddTaillePoint) shifted (p gddEnPlace) + fill (fullcircle scaled gddTaillePoint) shifted (p gddEnPlace) withcolor gddCouleurPoint; draw (fullcircle scaled gddTaillePoint) shifted (p gddEnPlace) enddef; @@ -273,7 +274,7 @@ vardef m_arque.@# expr p = label.@#(gddL[p] scaled gddTailleLabel,PointTOPair(p) gddEnPlace); enddef; -vardef m_a_rque.@# expr p = +vardef m_a_rque.@# expr p = pointe(scantokens p); label.@#(lTEX(p),PointTOPair(scantokens p) gddEnPlace); enddef; @@ -287,7 +288,7 @@ enddef; %%% -------------------------------------------------------------------------- def SigneOrtho(expr a,b,c,x) = (_point_(b) + x * unitvector(_point_(a)-_point_(b))) - -- (_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; @@ -325,4 +326,4 @@ def gddFenetre = gddEnPlace withpen pencircle scaled 1 withcolor white; enddef; -endinput \ No newline at end of file +endinput