Exemplo n.º 1
0
int main(int argc, char *argv[])
{
   int i, N = 20;
   float x[20], y[20], z[20];			/* Static geometry */

   srand48((long)time(NULL));			/* Seed random numbers */
   for (i=0;i<N;i++) {
      x[i] = drand48()*4.0-2.0;			/* Random positions */
      y[i] = drand48()*4.0-2.0;
      z[i] = drand48()*4.0-2.0;
   }
  
   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-2.,2., -2.,2., -2.,2.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   cs2scb(&cb);                                  /* Install the callback */
   cs2sncb(&ncb);                              /* Install number callback */
 
   s2slw(4);					/* Set line width */
   s2sci(S2_PG_YELLOW);
   s2pt(N,x,y,z,1);				/* Draw static data */
   s2slw(1);

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
   float x[10], y[10], z[10];			/* Arrays of coordinate points */
   int N = 10;					/* Number of points */
   int Nl = 3;					/* Number of line widths */
   int i, j;					/* Loop variables */
   float width = 1;				/* Line width */

   srand48((long)time(NULL));			/* Seed random numbers */
   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   for (j=0;j<Nl;j++) {
      for (i=0;i<N;i++) {
         x[i] = drand48()*2.0 - 1.0;		/* Random (x,y,z) coordinates */
         y[i] = drand48()*2.0 - 1.0;
         z[i] = drand48()*2.0 - 1.0;
      }

      s2sci((j%15)+1);				/* Set colour */
      width = 2.0*(float)(j+1);			/* Line width */
      s2slw(width);				/* Set line width */
      s2line(N, x, y, z);   			/* Draw the poly-line */
   }
   
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
   int i;					/* Loop variable */
   int N = 50;					/* Number of points */
   float x[50], y[50], z[50];			/* Coordinates of points */
   int symbol = 1;				/* Point symbol */

   srand48((long)time(NULL));			/* Seed random numbers */
   for (i=0;i<N;i++) {
      x[i] = drand48()*2.0 - 1.0;
      y[i] = drand48()*2.0 - 1.0;
      z[i] = drand48()*2.0 - 1.0;
   }

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   s2sch(2);					/* Sets size of most symbols */
   s2slw(2);					/* Sets size of point */
   for (i=0;i<N;i++) {
      s2sci((i%15) + 1);				/* Set the colour */
      s2pt1(x[i],y[i],z[i],symbol);		/* Draw a single point */
   }
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
   float x = 0.0;
   float y = 0.5;
   float z = 0.2; 
   float y1,y2, z1,z2;				/* Bounding coordinates */
   char string[32] = "S2PLOT is great!";
   float pad = 0.5;				/* Padding around text */

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   s2sci(S2_PG_YELLOW);
   s2slw(2);					/* Set line width */
   s2textyz(x,y,z,string);			/* Write some text in y-z plane */

   s2qtxtyz(&y1,&y2, &z1,&z2, x,y,z, string, pad);
						/* Query bounding box for text */

   s2sci(S2_PG_GREEN);	
   s2rectyz(y1,y2, z1,z2, x-0.01);		/* Draw bounding rectangle */
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemplo n.º 5
0
void cb(double *t, int *kc)
/* A dynamic callback - jitter particle positions each time through */
{
   static int flag = 0;                 /* Flag on whether first time through */
   static float x[20], y[20], z[20];    /* Dynamic geometry */
   int i, N = 20;

   if (flag == 0) {                     /* First time only */
      for (i=0;i<N;i++) {
         x[i] = drand48()*2.0-1.0;      /* Random positions */
         y[i] = drand48()*2.0-1.0;
         z[i] = drand48()*2.0-1.0;
      }
      flag = 1;         	/* Set the flag - don't need this loop again */
   }

   for (i=0;i<N;i++) {
      x[i] += (drand48()*0.1-0.05); /* Apply a jitter each time in callback */
      y[i] += (drand48()*0.1-0.05);
      z[i] += (drand48()*0.1-0.05);
   }

   s2sci((*kc % 2) + colour);
         /* Set colour on number of times space is pressed - uses global */

   s2slw(3);                        /* Set the line width */
   s2pt(N, x, z, y, 1);             /* Draw the points */

}
Exemplo n.º 6
0
int main(int argc, char *argv[])
{
   float px, py, pz;				/* Position */
   float nx, ny, nz;				/* Normal */
   float sx, sy, sz;				/* Starting vector */
   float deg = 180.0;				/* Angular extent */
   int nseg = 48;				/* Number of segments */

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   px = 0.0; py = 0.0; pz = 0.0;		/* Set position */
   nx = 0.0; ny = 1.0; nz = 1.0; 		/* Normal vector */
   sx = 1.0; sy = 0.0; sz = 0.0;		/* Starting vector */

   s2slw(3);					/* Set line width */
   s2sci(S2_PG_YELLOW);				/* Set the colour */

   float axratio = 0.5;
   ns2erc(px,py,pz, nx,ny,nz, sx,sy,sz, deg, nseg, axratio);	
						/* Draw the arc */
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
   int i;                                       /* Loop varibale */
   float x, y, z;                               /* Random data */

   srand48((long)time(NULL));                   /* Seed random numbers */

   fprintf(stderr,"Shift-s to toggle handles\nShift-c to toggle crosshair\n");
   fprintf(stderr,"Right mouse select\nSpacebar toggle show all/show sel\n");
   s2opend("/?",argc, argv);                    /* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */

   for (i=0;i<N;i++) {                          /* Set-up globals */
      xyz[i].x = drand48()*2.0 - 1.0;           /* Random position */
      xyz[i].y = drand48()*2.0 - 1.0;
      xyz[i].z = drand48()*2.0 - 1.0;
      col[i].r = drand48();                     /* Random colour */
      col[i].g = drand48();
      col[i].b = drand48();
      sel[i]   = 0;                             /* Not currently selected */
   }

   cs2scb(&cb);                                  /* Install dynamic callback */
   cs2shcb(&pick);                               /* Install handle callback */

   s2slw(2);                                    /* Set line width */
   for (i=0;i<N;i++) {          /* Non-selectable random data points */
      x = drand48()*2.0 - 1.0;
      y = drand48()*2.0 - 1.0;
      z = drand48()*2.0 - 1.0;
      s2sci(15*drand48() + 1);                  /* Random colour */
      s2pt1(x,y,z,1);
   }

   s2show(1);                                   /* Open the s2plot window */

   return 1;
}
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
   int i;					/* Loop variable */
   int N = 50;					/* Number of points */
   float x[50], y[50], z[50];			/* Coordinates of points */
   float r, g, b;				/* RGB colours */
   int symbol = 1;				/* Point symbol */
   int offset = 32;				/* Starting colour */

   srand48((long)time(NULL));			/* Seed random numbers */
   for (i=0;i<N;i++) {
      x[i] = drand48()*2.0 - 1.0;
      y[i] = drand48()*2.0 - 1.0;
      z[i] = drand48()*2.0 - 1.0;
   }

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   s2slw(5);					/* Sets size of point */
   s2scir(offset, offset+N);			/* Set the colour index range */
   for (i=offset;i<(offset+N);i++) {
      r = drand48();				/* Choose random red value */
      g = r;					/* Green = Blue = Red */ 
      b = r;					/*  means grey-scale! */
      s2scr(i, r, g, b);			/* Set colour representation */
   }
   
   for (i=0;i<N;i++) {
      s2qcr(offset+i, &r, &g, &b);		/* Query colour representation */
      s2scr(offset+i, r, 1.0, g);		/* Make it greenish */
      s2sci(offset+i);				/* Set the colour */
      s2pt1(x[i],y[i],z[i],symbol);		/* Draw a single point */
   }
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemplo n.º 9
0
int main(int argc, char *argv[])
{
   int i, N = 20;				/* Loop variables */
   float x, y, z;				/* Random data */
   XYZ focus;					/* Point to rotate about */
   int wc = 1;					/* Use world coordinates */

   srand48((long)time(NULL));			/* Seed random numbers */

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   s2slw(3);					/* Set line width */
   for (i=0;i<N;i++) {
      x = drand48()*2.0 - 1.0;			/* Random (x,y,z) */
      y = drand48()*2.0 - 1.0;
      z = drand48()*2.0 - 1.0;
      s2sci(15*drand48() + 1);			/* Random colour */
      s2pt1(x,y,z,1);				/* Plot the point */
   }

   focus.x = drand48()*2.0 - 1.0;		/* Random rotation point */
   focus.y = drand48()*2.0 - 1.0;
   focus.z = drand48()*2.0 - 1.0;
   ss2scf(focus, wc);				/* Set the rotation point */

   s2sch(0.7);					/* Set text height */
   s2textxy(-1,0,0,"Rotate camera - then press 1 followed by +"); 

   cs2sncb(&numcb);				/* Install number callback */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}