This is example11.c in view mode; [Download] [Up]
/* Demonstration of mesh plotting (just like example08 but mesh) */ #include <math.h> #define XPTS 35 #define YPTS 46 static int opt[] = {1, 2, 3, 3}; static double alt[] = {60.0,20.0,60.0,60.0}; static double az[] = {30.0,60.0,120.0,160.0}; static char *title[4] = { "#frPLPLOT Example 11 - Alt=60, Az=30, Opt=1", "#frPLPLOT Example 11 - Alt=20, Az=60, Opt=2", "#frPLPLOT Example 11 - Alt=60, Az=120, Opt=3", "#frPLPLOT Example 11 - Alt=60, Az=160, Opt=3" }; main() { int i, j, k; FLOAT *x, *y, **z; double xx, yy, r; char *malloc(); x = (FLOAT *)malloc(XPTS*sizeof(FLOAT)); y = (FLOAT *)malloc(YPTS*sizeof(FLOAT)); z = (FLOAT **)malloc(XPTS*sizeof(FLOAT *)); for (i=0; i<XPTS; i++) { z[i] = (FLOAT *)malloc(YPTS*sizeof(FLOAT)); x[i] = (i-(XPTS/2))/(double)(XPTS/2); } for (i=0; i<YPTS; i++) y[i] = (i-(YPTS/2))/(double)(YPTS/2); for (i=0; i<XPTS; i++) { xx = x[i]; for (j=0; j<YPTS; 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); plcol(1); 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, "bcdmnstuv","z axis",0.0,0); plcol(2); plmesh(x,y,z,XPTS,YPTS,opt[k]); plcol(3); plmtex("t",1.0,0.5,0.5,title[k]); pleop(); } pltext(); plend(); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.