home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d2xx
/
d222
/
plplot.lha
/
Plplot
/
examples
/
example08.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-19
|
1KB
|
63 lines
/* Demonstration of 3-d plotting */
#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"
};
main()
{
int i, j, k;
float x[NPTS], y[NPTS], z[NPTS][NPTS];
float xx, yy, r;
int work[4*NPTS];
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);
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,
"bcmnstuv","z axis",0.0,0);
plot3d(x,y,z,work,NPTS,NPTS,NPTS,opt[k]);
if(k==1 || k==3)
plside3(x,y,z,NPTS,NPTS,NPTS,opt[k]);
if(k==2 || k==3)
plgrid3(0.0);
plmtex("t",1.0,0.5,0.5,title[k]);
}
pltext();
plend();
}