home *** CD-ROM | disk | FTP | other *** search
- /* Demonstration of 3-d plotting */
-
- #include "plplot.h"
- #include <math.h>
-
- #define NPTS 41
-
- static int opt[] = {1, 2, 3, 3};
-
- static float alt[] = {60.0,20.0,60.0,60.0};
-
- static float az[] = {30.0,60.0,120.0,160.0};
-
- static char *title[4] = {
- "#frPLPLOT Example 8 - Alt=60, Az=30, Opt=1",
- "#frPLPLOT Example 8 - Alt=20, Az=60, Opt=2",
- "#frPLPLOT Example 8 - Alt=60, Az=120, Opt=3",
- "#frPLPLOT Example 8 - Alt=60, Az=160, Opt=3"
- };
-
- static float x[NPTS], y[NPTS], z[NPTS][NPTS];
-
- main()
- {
- int i, j, k;
-
- float xx, yy, r;
-
- for (i=0; i<NPTS; i++) {
- x[i] = (i-(NPTS/2))/(double)(NPTS/2);
- y[i] = (i-(NPTS/2))/(double)(NPTS/2);
- }
-
- for (i=0; i<NPTS; i++) {
- xx = x[i];
- for (j=0; j<NPTS; j++) {
- yy = y[j];
- r = sqrt(xx*xx + yy*yy);
- z[i][j] = exp(-r*r) * cos(2.0*3.141592654*r);
- }
- }
-
- plstar(1,1);
-
- for (k=0; k<4; k++) {
- pladv(0);
- plvpor(0.0,1.0,0.0,0.9);
- plwind(-1.0,1.0,-0.9,1.1);
- plcol(1);
- plw3d(1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,alt[k],az[k]);
- plbox3("bnstu","x axis",0.0,0,"bnstu","y axis",0.0,0,
- "bcdmnstuv","z axis",0.0,0);
- plcol(2);
- plot3d(x,y,&z[0][0],NPTS,NPTS,NPTS,opt[k],1);
- plcol(3);
- plmtex("t",1.0,0.5,0.5,title[k]);
- }
-
- pltext();
- plend();
- }
-