11.82 Sample ‘mirror

Example of using options.

MGL code:

new a 31 41 '-pi*x*exp(-(y+1)^2-4*x^2)'
subplot 2 2 0:title 'Options for coordinates':alpha on:light on:rotate 40 60:box
surf a 'r';yrange 0 1:surf a 'b';yrange 0 -1
subplot 2 2 1:title 'Option "meshnum"':rotate 40 60:box
mesh a 'r'; yrange 0 1:mesh a 'b';yrange 0 -1; meshnum 5
subplot 2 2 2:title 'Option "alpha"':rotate 40 60:box
surf a 'r';yrange 0 1; alpha 0.7:surf a 'b';yrange 0 -1; alpha 0.3
subplot 2 2 3 '<_':title 'Option "legend"'
fplot 'x^3' 'r'; legend 'y = x^3':fplot 'cos(pi*x)' 'b'; legend 'y = cos \pi x'
box:axis:legend 2

C++ code:

void smgl_mirror(mglGraph *gr)	// flag #
{
	mglData a(31,41);
	gr->Fill(a,"-pi*x*exp(-(y+1)^2-4*x^2)");

	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Options for coordinates");	}
	gr->Alpha(true);	gr->Light(true);
	gr->Rotate(40,60);	gr->Box();
	gr->Surf(a,"r","yrange 0 1"); gr->Surf(a,"b","yrange 0 -1");
	if(big==3)	return;
	gr->SubPlot(2,2,1);	gr->Title("Option 'meshnum'");
	gr->Rotate(40,60);	gr->Box();
	gr->Mesh(a,"r","yrange 0 1"); gr->Mesh(a,"b","yrange 0 -1; meshnum 5");
	gr->SubPlot(2,2,2);	gr->Title("Option 'alpha'");
	gr->Rotate(40,60);	gr->Box();
	gr->Surf(a,"r","yrange 0 1; alpha 0.7"); gr->Surf(a,"b","yrange 0 -1; alpha 0.3");
	gr->SubPlot(2,2,3,"<_");	gr->Title("Option 'legend'");
	gr->FPlot("x^3","r","legend 'y = x^3'"); gr->FPlot("cos(pi*x)","b","legend 'y = cos \\pi x'");
	gr->Box();	gr->Axis();	gr->Legend(2,"");
}
Sample mirror