11.31 Sample ‘conts

Function conts get contour coordinate as data array.

MGL code:

new a 10 10 'sin(2*pi*x*y)'
title 'Conts sample':rotate 40 60:box
dens a '#'
cont [0,0] a 'r'
conts r 0 a
plot 2*r(0)-1 2*r(1)-1 1+r(2) '2c'

C++ code:

void smgl_conts(mglGraph *gr)	// test conts
{
	mglData a(10,10);	gr->Fill(a,"sin(2*pi*x*y)");
	mglData v, r=a.Conts(0);
	if(big!=3)	{	gr->Title("Conts sample");	}
	gr->Rotate(40,60);	gr->Box();
	gr->Dens(a,"#");	gr->Cont(v,a,"r");
	mglData x(r.ny),y(r.ny),z(r.ny);
	for(long i=0;i<x.nx;i++)	{	x[i]=r[r.nx*i]*2-1;	y[i]=r[r.nx*i+1]*2-1;	z[i]=1;	}
	gr->Plot(x,y,z,"2c");
}
Sample conts