tic();

xmin=0;
xmax=1;
ymin=0;
ymax=1;

Setangle(70,-60);
Setwindow([-0.5,2], [-1,3]);

function f=f(x,y); f=y*exp(x*y); endfunction
function F=F(x,y); F=[x, y, y*exp(x*y)]; endfunction

fd=list('z=f(x,y)', 'x=[xmin,xmax]', 'y=[ymin,ymax]', 'ewsn');
outline=Sfbdparadata(fd,100);  // 輪郭線

axis=Xyzax3data('x=[0,2]', 'y=[0,2]', 'z=[0,2]');  // 座標軸

O1=Spaceline([F(xmax,ymax)], [xmax,ymax,0], [xmax,ymin,0]);  // 輪郭線
O2=Spaceline([xmax,ymax,0], [xmin,ymax,0], [F(xmin,ymax)]);  // 輪郭線

Windisp(Projpara(outline, axis, O1, O2));


x0=0.5;
Lx=Spaceline([F(x0,ymin)], [x0,ymax,0], [F(x0,ymax)]);
Cx=Spacecurve('F(x0,t)','t=[ymin,ymax]');
XSlice=list(Lx,Cx);  // 切り口の輪郭線

//Windisp(Projpara(XSlice, outline));

pL=Listplot([ymin,f(x0,ymin)], [ymin,0], [ymax,0], [ymax,f(x0,ymax)]);
pC=Plotdata('f(x0,y)', 'y=[ymin,ymax]');
pH=Hatchdata('i', list(pL, pC), 135, 0.8);
function Em=Em(y,z)
  Em=[x0,y,z];
endfunction
XHatch=Embed(pH, Em);

Windisp(Projpara(XHatch));

sXHatch=Skeletonparadata(XHatch, list(outline), 0.4);
sXaxis=Skeletonparadata(axis, list(XHatch), 0.2);

Windisp(Projpara(outline, XSlice, O1, O2), sXaxis, sXHatch);


y0=0.6;
Ly=Spaceline([F(xmin,y0)], [xmin,y0,0], [xmax,y0,0], [F(xmax,y0)]);
Cy=Spacecurve('F(t,y0)','t=[xmin,xmax]');
//sCy=Crv3onsfparadata(Cy, outline, fd);
YSlice=list(Ly,Cy);

//Windisp(Projpara(YSlice, outline));

pL=Listplot([xmin,f(xmin,y0)], [xmin,0], [xmax,0], [xmax,f(xmax,y0)]);
pC=Plotdata('f(x,y0)','x=[xmin,xmax]');
pH=Hatchdata('i',list(pL, pC),135,0.8);
function Em=Em(x,z); Em=[x,y0,z]; endfunction
YHatch=Embed(pH,Em);

//Windisp(Projpara(YHatch));

sYHatch=Skeletonparadata(YHatch, list(outline), 0.4);
sYaxis=Skeletonparadata(axis, list(YHatch), 0.2);

Windisp(Projpara(outline, YSlice, O1, O2), sYaxis, sYHatch);


function incZ=incZ(x,y); incZ=[x,y,0]; endfunction
Mx=(xmin+xmax)/2;
My=(ymin+ymax)/2;
Ax=Arrowdata([xmin,My], [xmax,My]);
Ay=Arrowdata([Mx,ymin], [Mx,ymax]);
XArrow=Embed(Ax,incZ);
YArrow=Embed(Ay,incZ);
Lx=Spaceline([xmin,My,0], [xmax,My,0]);
Ly=Spaceline([Mx,ymin,0], [Mx,ymax,0]);


Openfile('tex/multiple_integral_sampleX.tex');
Beginpicture('1.5cm');
Drwline(Projpara(outline, O1), 1.2);
Drwline(Projpara(XSlice), sXHatch, 0.5);
Drwline(sXaxis, 0.7);
Drwline(Projpara(Lx, XArrow), 0.8);
Xyzaxparaname(axis, 'x', ' ', 'z');
Setpen(.5);
Dashline(Projpara(O2), .6);
Expr(Projpara(F(xmax,ymax)), 'n2', '\displaystyle z=ye^{xy}');
Endpicture(0);
Closefile();


Openfile('tex/multiple_integral_sampleY.tex');
Beginpicture('1.5cm');
Drwline(Projpara(outline, O1), 1.2);
Drwline(Projpara(YSlice), sYHatch, 0.5);
Drwline(sYaxis, 0.7);
Drwline(Projpara(Ly, YArrow), 0.8);
Xyzaxparaname(axis, 'x', ' ', 'z');
Setpen(.5);
Dashline(Projpara(O2), .6);
Expr(Projpara(F(xmax,ymax)), 'n2', '\displaystyle z=ye^{xy}');
Endpicture(0);
Closefile();


T=toc();
minute=floor(T/60);
second=floor(T-60*minute);
disp(strcat([string(minute), ' minutes ', string(second), ' seconds']));
