pls.cont( z, clevelpos, xg, yg, 0 );
pls.cont( z, clevelpos, xg, yg, 2 );
    final void potential()    // Shielded potential contour plot example.    {	int i,j;	double rmax, xmin, xmax, x0, ymin, ymax, y0, zmin, zmax;	double peps, xpmin, xpmax, ypmin, ypmax;	double eps, q1, d1, q1i, d1i, q2, d2, q2i, d2i;	double div1, div1i, div2, div2i;	double [][] xg = new double[PRPTS][PPERIMETERPTS] ;	double [][] yg = new double[PRPTS][PPERIMETERPTS] ;	double [][] z = new double[PRPTS][PPERIMETERPTS] ;	int nlevelneg, nlevelpos;	double dz, clevel;	double [] clevelneg_store = new double[PNLEVEL];	double [] clevelpos_store = new double[PNLEVEL];	double [] clevelneg = new double[PNLEVEL/2];	double [] clevelpos = new double[PNLEVEL/2];	int  ncollin, ncolbox, ncollab;	double [] px = new double[PPERIMETERPTS];	double [] py = new double[PPERIMETERPTS];	double t, r, theta;       // Create data to be contoured.       //java wants r unambiguously initialized for rmax below.	r = 0.; 	for (i = 0; i < PRPTS; i++) {            r = 0.5 + (double) i;            for (j = 0; j < PTHETAPTS; j++) {                theta = (2.*Math.PI/(double)(PTHETAPTS-1))*(0.5 + (double) j);                xg[i][j] = r*Math.cos(theta);                yg[i][j] = r*Math.sin(theta);            }	}	rmax = r;        f2mnmx( xg, PRPTS, PTHETAPTS );        xmin = fmin;        xmax = fmax;        f2mnmx( yg, PRPTS, PTHETAPTS );        ymin = fmin;        ymax = fmax;	x0 = (xmin + xmax)/2.;	y0 = (ymin + ymax)/2.;    // Expanded limits	peps = 0.05;	xpmin = xmin - Math.abs(xmin)*peps;	xpmax = xmax + Math.abs(xmax)*peps;	ypmin = ymin - Math.abs(ymin)*peps;	ypmax = ymax + Math.abs(ymax)*peps;         // Potential inside a conducting cylinder (or sphere) by method of images.    // Charge 1 is placed at (d1, d1), with image charge at (d2, d2).    // Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2).    // Also put in smoothing term at small distances.	eps = 2.;		q1 = 1.;	d1 = rmax/4.;	q1i = - q1*rmax/d1;	d1i = Math.pow(rmax,2)/d1;	q2 = -1.;	d2 = rmax/4.;	q2i = - q2*rmax/d2;	d2i = Math.pow(rmax,2)/d2;	for (i = 0; i < PRPTS; i++) {            for (j = 0; j < PTHETAPTS; j++) {                div1 = Math.sqrt(Math.pow(xg[i][j]-d1,2) + Math.pow(yg[i][j]-d1,2) + Math.pow(eps,2));                div1i = Math.sqrt(Math.pow(xg[i][j]-d1i,2) + Math.pow(yg[i][j]-d1i,2) + Math.pow(eps,2));                div2 = Math.sqrt(Math.pow(xg[i][j]-d2,2) + Math.pow(yg[i][j]+d2,2) + Math.pow(eps,2));                div2i = Math.sqrt(Math.pow(xg[i][j]-d2i,2) + Math.pow(yg[i][j]+d2i,2) + Math.pow(eps,2));                z[i][j] = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i;            }	}        f2mnmx( z, PRPTS, PTHETAPTS );        zmin = fmin;        zmax = fmax;    /*	printf("%.15g %.15g %.15g %.15g %.15g %.15g %.15g %.15g \n",        q1, d1, q1i, d1i, q2, d2, q2i, d2i);	System.out.println(xmin);	System.out.println(xmax);	System.out.println(ymin);	System.out.println(ymax);	System.out.println(zmin);	System.out.println(zmax); */    // Positive and negative contour levels.	dz = (zmax-zmin)/(double) PNLEVEL;	nlevelneg = 0;	nlevelpos = 0;	for (i = 0; i < PNLEVEL; i++) {            clevel = zmin + ((double) i + 0.5)*dz;            if (clevel <= 0.)                clevelneg_store[nlevelneg++] = clevel;            else                clevelpos_store[nlevelpos++] = clevel;	}       // The point here is to copy results into an array of the correct size.       // This only works if nlevelneg = nlevelpos = PNLEVEL/2, the size       // of the pre-allocated space for clevelpos and clevelneg.  A much       // better approach would be to use a dynamic object such as a vector,       // but AWI cannot find a clear tutorial about using them, and it is       // also not clear (to AWI) whether vectors would work as plcont       // arguments.  Over to you Geoffrey!	System.arraycopy(clevelneg_store, 0, clevelneg, 0, nlevelneg);	System.arraycopy(clevelpos_store, 0, clevelpos, 0, nlevelpos);    // Colours!	ncollin = 11;	ncolbox = 1;	ncollab = 2;    // Finally start plotting this page!	pls.adv(0);	pls.col0(ncolbox);	pls.vpas(0.1, 0.9, 0.1, 0.9, 1.0);	pls.wind(xpmin, xpmax, ypmin, ypmax);	pls.box("", 0., 0, "", 0., 0);	pls.col0(ncollin);	if(nlevelneg >0) {        // Negative contours            pls.lsty(2);            pls.cont( z, clevelneg, xg, yg, 0 );	}	if(nlevelpos >0) {        // Positive contours            pls.lsty(1);            pls.cont( z, clevelpos, xg, yg, 0 );	}		     // Draw outer boundary	for (i = 0; i < PPERIMETERPTS; i++) {            t = (2.*Math.PI/(PPERIMETERPTS-1))*(double)i;            px[i] = x0 + rmax*Math.cos(t);            py[i] = y0 + rmax*Math.sin(t);	}	pls.col0(ncolbox);	pls.line(PPERIMETERPTS, px, py);	       	pls.col0(ncollab);	pls.lab("", "", "Shielded potential of charges in a conducting sphere");    }