Dans le code ci-dessous (merci pour les scripts !), est-il possible de "rogner" les tangentes à la zone du graphique ?
Merci.
Fabrice
Code : Tout sélectionner
import graph;
import interpolate;
import geometry;
usepackage("esvect");
unitsize(1.5cm,1.5cm);
defaultpen(fontsize(9pt));
real n=4;
real[] x={-4,-3,0,2,4};
real[] y={1,3,-1,0,4};
real[] dy={4,0,-1,3/2,5/2};
add(shift(-5,-2)*grid(10,8,gray(0.8)));
real f(real t)
{ return pwhermite(x,y,dy)(t);
}
path Cf=graph(f,-4,4,n=4000);
draw(Cf,black+1bp);
void tangente(int k,real lg=1,real ld=lg, pen p=dashed, arrowbar arr=None) {
draw(((x[k],y[k])-lg*unit((1,dy[k])))
--((x[k],y[k])+ld*unit((1,dy[k]))),
p,
arr);
}
xlimits(-5,5);
ylimits(-2,6,Crop);
pen thin=linewidth(0.5*linewidth());
xaxis(Label("$x$",align=Align),axis=YZero,RightTicks(begin=false,end=false,extend=false,ptick=thin,NoZero,Step=1,beginlabel=false,endlabel=false,Size=1mm),p=linewidth(1bp),above=true);
yaxis(Label("$y$",align=Align),axis=XZero,RightTicks(begin=false,end=false,extend=false,ptick=thin,NoZero,Step=1,beginlabel=false,endlabel=false,Size=1mm),p=linewidth(1bp),above=true);
draw((0,0)--(1,0),red+1bp,Arrow(5bp));
draw((0,0)--(0,1),red+1bp,Arrow(5bp));
tangente(0,lg=2,ld=5,p=1bp+blue);
tangente(1,lg=1,ld=2,p=1bp+blue);
tangente(2,lg=3,ld=1,p=1bp+blue);
tangente(4,lg=6.4,ld=1,p=1bp+blue);
for(int i=0; i <= 2; ++i)
dot((x[i],y[i]),3bp+black);
dot((x[4],y[4]),3bp+black);
label("$D$",(4,f(4)),NW);
label("$C$",(0,f(0)),NE);
label("$B$",(-3,f(-3)),N);
label("$A$",(-4,f(-4)),NW);
label("$O$",(0,0),SW);
label("$\vv{i}$",(0.5,0),red,align=S);
label("$\vv{j}$",(0,0.5),red,align=W);