home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / examples / example11.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-27  |  1.3 KB  |  63 lines

  1. /* Demonstration of mesh plotting (just like example08 but mesh) */
  2.  
  3. #include "plplot.h"
  4. #include <math.h>
  5.  
  6. #define   NPTS   41
  7.  
  8. static PLINT opt[] = {1,   2,   3,   3};
  9.  
  10. static PLFLT alt[] = {60.0,20.0,60.0,60.0};
  11.  
  12. static PLFLT az[] = {30.0,60.0,120.0,160.0};
  13.  
  14. static char *title[4] =  {
  15.    "#frPLPLOT Example 11 - Alt=60, Az=30, Opt=1",
  16.    "#frPLPLOT Example 11 - Alt=20, Az=60, Opt=2",
  17.    "#frPLPLOT Example 11 - Alt=60, Az=120, Opt=3",
  18.    "#frPLPLOT Example 11 - Alt=60, Az=160, Opt=3"
  19. };
  20.  
  21. static float x[NPTS], y[NPTS], z[NPTS][NPTS];
  22.  
  23. main()
  24. {
  25.    int i, j, k;
  26.  
  27.    float xx, yy, r;
  28.  
  29.    for (i=0; i<NPTS; i++)  {
  30.       x[i] = (i-(NPTS/2))/(double)(NPTS/2);
  31.       y[i] = (i-(NPTS/2))/(double)(NPTS/2);
  32.    }
  33.  
  34.    for (i=0; i<NPTS; i++)  {
  35.       xx = x[i];
  36.       for (j=0; j<NPTS; j++)  {
  37.          yy = y[j];
  38.          r = sqrt(xx*xx + yy*yy);
  39.          z[i][j] = exp(-r*r) * cos(2.0*3.141592654*r);
  40.       }
  41.    }
  42.  
  43.    plstar(1,1);
  44.  
  45.    for (k=0; k<4; k++)  {
  46.       pladv(0);
  47.       plcol(1);
  48.       plvpor(0.0,1.0,0.0,0.9);
  49.       plwind(-1.0,1.0,-0.9,1.1);
  50.  
  51.       plw3d(1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,alt[k],az[k]);
  52.       plbox3("bnstu","x axis",0.0,0,"bnstu","y axis",0.0,0,
  53.              "bcdmnstuv","z axis",0.0,0);
  54.       plcol(2);
  55.       plmesh(x,y,&z[0][0],NPTS,NPTS,NPTS,opt[k]);
  56.       plcol(3);
  57.       plmtex("t",1.0,0.5,0.5,title[k]);
  58.    }
  59.  
  60.    pltext();
  61.    plend();
  62. }
  63.