Première contribution après deux années passées sur ce forum et qui n'est pas vraiment personnelle puisqu'on en avait parlé là, là et là. En hommage aux surfaces type "bac ES".
Code : Tout sélectionner
import grid3;
import palette;
import contour;
currentprojection=orthographic(-3,-3,1);
size3(7cm,7cm,7cm,IgnoreAspect);
real xmin=0,
ymin=0,
zmin=0,
xmax=10,
ymax=10,
zmax=6;
limits((xmin,ymin,zmin),(xmax,ymax,zmax));
real Dx=1, Dy=1, Dz=1;
real Nb=zmax/Dz;
// Définition de la fonction
real f(pair z) {return log(2*z.x^2+z.y^2+1);}
surface s=surface(f, (xmin,ymin), (xmax,ymax), nx=150, ny=150, Spline);
// Couleurs ; Lignes de niveau
pen[] pal=Rainbow();
real[] lignesdeniveau;
for (int i=1; i<=Nb; ++i) {real ligne=Dz*i ;
lignesdeniveau.push(ligne);
}
s.colors(palette(s.map(new real(triple v) {return find(lignesdeniveau > v.z);}),pal));
draw(s);
draw(lift(f,contour(f,(xmin,ymin),(xmax,ymax),lignesdeniveau)),1.5bp+blue);
for (int i=1; i<= xmax/Dx; ++i) {
real x1(real t) {return i*Dx;}
real y1(real t) {return t;}
real z1(real t) {pair z=(i*Dx,t); return f(z);}
path3 lx=graph(x1,y1,z1,ymin,ymax);
draw(lx, black);
}
for (int i=1; i<= ymax/Dy; ++i) {
real x1(real t) {return t;}
real y1(real t) {return i*Dy;}
real z1(real t) {pair z=(t,i*Dy); return f(z);}
path3 lx=graph(x1,y1,z1,xmin,xmax);
draw(lx, black);
}
// Axes et grilles
grid3(XYgrid, Step=Dx);
grid3(YXgrid, Step=Dy);
grid3(ZXgrid(Relative(1)), Step=Dz);
grid3(YZgrid(Relative(1)), Step=Dy);
grid3(XZgrid(Relative(1)), Step=Dx);
grid3(ZYgrid(Relative(1)), Step=Dz);
xaxis3(Label("$x$",MidPoint,align=-Z),
Bounds(Both,Min),OutTicks(Step=Dx,endlabel=true),p=blue);
yaxis3(Label("$y$",MidPoint,align=-Z),
Bounds(Both,Min),OutTicks(Step=Dy, step=0),p=red);
zaxis3(Label("$z$" ,MidPoint,align=-X),XYEquals(xmin,ymax),InTicks(Step=Dz, step=0,Label(align=Y)),p=1bp+.5green);