Exemple #1
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;
}
Exemple #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;
}
Exemple #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;
}
Exemple #4
0
int main(int argc, char *argv[])
{
   float r1  = 0.5;				/* Inner radius */
   float r2  = 0.8;				/* Outer radius */

   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_RED);
   s2diskxy(0.0,0.0,-0.5, r1, r2);		/* Disk in x-y plane */
   s2sci(S2_PG_BLUE);
   s2diskxy(0.0,0.0,-0.5, r1/2.0, r2/2.0);	/* Disk in x-y plane */
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemple #5
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;
}
Exemple #6
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 */

}
Exemple #7
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;
}
Exemple #8
0
int main(int argc, char *argv[])
{
   float r   = 0.5;				/* Radius */
   int nseg  = 32;				/* Segments for circle */
   float asp = 1.0;				/* Circle not ellipse */

   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_RED);
   s2circxz(0.0,-0.5,0.0, r, nseg,asp);		/* Circle in x-z plane */
   s2sci(S2_PG_BLUE);
   s2circxz(0.0,-0.5,0.0, r/2.0, nseg,asp);	/* Circle in x-z plane */
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemple #9
0
int main(int argc, char *argv[])
{
   float x1 = -0.5, x2 = +0.5;			/* Rectangle coordinates */
   float y1 = -0.2, y2 = +0.2;
   float z1 = -0.3, z2 = +0.3;

   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);
   s2rectxy(x1,x2, y1,y2, z1);			/* Rectangle in x-y plane */
   s2sci(S2_PG_GREEN);
   s2rectxy(x1,x2, y1,y2, z2);			/* Rectangle in x-y plane */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemple #10
0
int main(int argc, char *argv[])
{
   s2opend("/?",argc, argv);			/* Open the display */
   s2svp(-1.,0., -1.,1., -1.,1.);		/* First view port */
   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_RED);
   s2svp(0.5,1., -1.,1., -1.,1.);		/* Second viewport */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */
   
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemple #11
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;
}
Exemple #12
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;
}
Exemple #13
0
int main(int argc, char *argv[])
{
   float x1, y1, z1;				/* Start of line */
   float x2, y2, z2;				/* End of line */
   float r1, g1, b1;				/* Colour of line segment (start) */
   float r2, g2, b2;				/* Colour of line segment (end) */
   float size;					/* Thickness of line */
   int N = 10;					/* Number of lines */
   int i;					/* Loop variable */

   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 */

   s2sci(S2_PG_YELLOW);				/* Set colour */
   for (i=0;i<N;i++) {
      x1 = drand48()*2.0 - 1.0;			/* Random (x,y,z) coordinates */
      y1 = drand48()*2.0 - 1.0;
      z1 = drand48()*2.0 - 1.0;
      x2 = drand48()*2.0 - 1.0;			/* Random (x,y,z) coordinates */
      y2 = drand48()*2.0 - 1.0;
      z2 = drand48()*2.0 - 1.0;
      r1  = drand48();
      g1  = drand48();
      b1  = drand48();
      r2  = drand48();
      g2  = drand48();
      b2  = drand48();
      size = drand48()*10.0;			/* Line thickness */
      ns2thcline(x1,y1,z1, x2,y2,z2, r1,g1,b1, r2,g2,b2, size);	/* Draw the thick line */
   }

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Exemple #14
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;
}
Exemple #15
0
plotsnap()
{
    real t, *mp, *psp, *pp, *ap, *acp;
    int vismax, visnow, i, vis, icol;
    real psz, col, x, y, z;
    Body b;
    bool Qall = FALSE;

    t = (timeptr != NULL ? *timeptr : 0.0);	/* get current time value   */
    CLRV(Acc(&b));				/* zero unsupported fields  */
    Key(&b) = 0;
    visnow = vismax = 0;
    do {					/* loop painting layers     */
	visnow++;				/*   make next layer visib. */
	mp  = massptr;				/*   (re)set data pointers  */
	psp = phaseptr;
	pp  = phiptr;
	ap  = auxptr;
	acp = accptr;
	npnt = 0;
	for (i = 0; i < nbody; i++) {		/*   loop over all bodies   */
	    Mass(&b) = (mp != NULL ? *mp++ : 0.0);
						/*     set mass if supplied */
	    SETV(Pos(&b), psp);			/*     always set position  */
	    psp += NDIM;			/*     and advance p.s. ptr */
	    SETV(Vel(&b), psp);			/*     always set velocity  */
	    psp += NDIM;			/*     and advance ptr      */
	    Phi(&b) = (pp != NULL ? *pp++ : 0.0);	
	    Aux(&b) = (ap != NULL ? *ap++ : 0.0);
	    if (acp) {				
	    	SETV(Acc(&b),acp);		/*     set accel's          */	
	    	acp += NDIM;			/*     and advance ptr      */
	    }
	    					/*     set phi,aux if given */
	    vis = (*vfunc)(&b, t, i);		/*     evaluate visibility  */
	    vismax = MAX(vismax, vis);		/*     remember how hi to go*/
	    if (vis == visnow) {		/*     if body is visible   */
	        x = (*xfunc)(&b, t, i);	        /*     evaluate x,y,z coords*/
		y = (*yfunc)(&b, t, i);
		z = (*zfunc)(&b, t, i);

		psz = (*pfunc)(&b, t, i);
#define MAXCOLOR 16
#ifdef COLOR
		col = (*cfunc)(&b, t, i);
		col = (col - crange[0])/(crange[1] - crange[0]);
		icol = 1 + (MAXCOLOR - 2) * MAX(0.0, MIN(1.0, col));
		s2sci(icol);
#endif
		xpnt[npnt] = x;
		ypnt[npnt] = y;
		zpnt[npnt] = z;
		if (!Qall) {
		  s2pt1(xpnt[npnt],ypnt[npnt],zpnt[npnt], visnow);
		}
		npnt++;
	    }
	} /* i<nbody */
	if (Qall)
	  s2pt(npnt, xpnt, ypnt, zpnt, visnow);
    } while (visnow < vismax);			/* until final layer done   */
}