Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
   int i;
   int marker;					/* Type of marker to use */
   XYZ xyz;					/* Position */
   COLOUR col;					/* Colour */
   float size = 0.4;				/* Size of marker */

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

   marker = 0;
   for (i=0;i<4;i++) {
      xyz.x = drand48()*2.0 - 1.0;			/* Random position */
      xyz.y = drand48()*2.0 - 1.0;
      xyz.z = drand48()*2.0 - 1.0;
      col.r = drand48();				/* Randomish colour */
      col.g = 1.0; 
      col.b = 0.3; 
      ns2vm(marker, size, xyz, col);		/* Draw the marker */
      marker = (marker+1)%4;
   }

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
   XYZ vertex[4];				/* 4 vertices */
   COLOUR col = { 1.0, 1.0, 0.3 };		/* Yellowish */
   float scale = 1.0;				/* Scale for texture */
   int texid;					/* ID for this texture */
   char *texture = "firetile2_pow2_rgb.tga";	
		/* Texture in directory pointed to by S2PLOT_TEXPATH */ 

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

   texid = ss2lt(texture);
   vertex[0].x = 0.0; vertex[0].y =  0.0; vertex[0].z = 0.0;
   vertex[1].x = 0.5; vertex[1].y =  0.0; vertex[1].z = 0.0;
   vertex[2].x = 0.5; vertex[2].y = -0.4; vertex[2].z = 1.0;
   vertex[3].x = 0.0; vertex[3].y = -0.4; vertex[3].z = 1.0;

   ns2vf4x(vertex, col, texid, scale, 'o'); 	/* Draw the polygon */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
   int width = 16, height = 16;		/* Dimensions of texture */
   int i, j;				/* Loop variables */
   int idx;				/* Index into texture array */
   unsigned char *tex;				/* Array of texture values */

   srand48((long)time(NULL));			/* Seed random numbers */
   s2opend("/?",argc,argv);			/* Open the display */
   s2svp(-1.0,1.0, -1.0,1.0, -1.0,1.0);		/* Set the viewport coords */
   s2swin(-1.0,1.0, -1.0,1.0, -1.0,1.0);	/* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);	/* Draw a bounding box */

   tid = ss2ct(width, height);		/* Create a new texture */
   tex = ss2gt(tid, &width, &height);	/* Get the texture */

   for (j=0;j<height;j++) {
      for (i=0;i<width;i++) {
         idx = (j*width + i) * 4;		/* Stored as (r,g,b,alpha) */
         tex[idx  ] = 127*drand48()+128;	/* Randomish red */
         tex[idx+1] = 0;			/* Green */
         tex[idx+2] = 0;			/* Blue */
						/* Do nothing to alpha */
      }
   }
   ss2pt(tid);				/* Push texture for usage */

   cs2scb(&cb);				/* Install a callback */

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

   return 1;
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
   int i;				/* Loop variable */
   XYZ xyz;				/* Coordinate for plotting points */
   COLOUR col;				/* Colour of plotted points */

   s2opend("/S2MONO",argc,argv);	/* Query the s2plot device to use */
   s2swin(-1.,1.,-1.,1.,-1.,1.);	/* Set the world coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);	/* Draw a coordinate box */

   srand48((long)time(NULL));		/* Seed the random number generator */

   for (i=0;i<1000;i++) {		/* Generate and plot random points */
      xyz.x = drand48()*2.0 - 1.0;	/*  with random colours */
      xyz.y = drand48()*2.0 - 1.0;
      xyz.z = drand48()*2.0 - 1.0;
      col.r = drand48();
      col.g = drand48();
      col.b = drand48();
      ns2vpoint(xyz, col);
   }
   ss2sas(1);				/* Start the geometry auto-spinning */
   cs2scb(cb);				/* Install a dynamic callback */
   s2show(1);				/* Display the geometry */
   return 0;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
   XYZ xyz = { 0.0, 0.0, 0.0 };			/* Position */
   XYZ right = { 0.05, 0.0, 0.0 };		/* Right vector */
   XYZ up = { 0.0, 0.05, 0.0 };			/* Up vector */
   COLOUR col = { 1.0, 1.0, 0.0 };		/* Colour */
   char text[32];				/* Text */
   float sp = 5.0;				/* Speed */

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

   sp = ss2qss();				/* Get spin speed */
   sprintf(text,"Speed = %5.2f",sp);		/* Prepare the text */
   ns2vtext(xyz, right, up, col, text);		/* Right some text */
  
   s2lab("","","","Use * and / to control the spin speed");

   ss2sas(1);					/* Start camera rotating */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
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;
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 12
0
int main(int argc, char *argv[])
{
   s2opendo("/?");				/* Prompt for display type */
   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;
}
Ejemplo n.º 13
0
int main(int argc, char *argv[])
{
   fprintf(stderr,"Resize window to see change in panel size");

   s2opend("/s2mono", argc, argv);             	/* Open in mono mode */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */
   
   cs2scb(cb);					/* Install dynamic callback */
   s2show(1);                                   /* Open the s2plot window */

   return 1;
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
   int panel0 = 0;				/* Default ID of main panel */
   int panel1;					/* ID of newly created panel */
   int panel2;					/* ID of newly created panel */
   int pa;					/* Activity status of panel */

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

   s2opend("/s2mono", argc, argv);      	/* Open in mono mode */

   xs2mp(panel0, 0.5, 1.0, 1.0, 1.0);		/* Move master to top */
   s2swin(-1.,1., -1.,1., -1.,1.);      	/* Set window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */
   
   panel1 = xs2ap(0.0, 0.0, 0.5, 0.5);		/* Create new panel */
   xs2cp(panel1);				/* Choose this panel */
   s2swin(-1.,1., -1.,1., -1.,1.);      	/* Set window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);  	/* Draw coordinate box */
   
   panel2 = xs2ap(0.5, 0.0, 1.0, 0.5);		/* Create new panel  */
   xs2cp(panel2);				/* Choose this panel */
   s2swin(-1.,1., -1.,1., -1.,1.);      	/* Set window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);  	/* Draw coordinate box */

   int i;					/* Loop variable */
   for (i=panel0;i<=panel2;i++) {
      if (drand48() > 0.7) xs2tp(i);		/* Randomly deactivate panel */
      xs2cp(i);					/* Chose a panel */
      pa = xs2qcpa();				/* Is this panel active? */
      if (pa) fprintf(stderr,"Panel %d is active\n",i);
      else fprintf(stderr,"Panel %d is inactive\n",i);
   }

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

   return 1;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{

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

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

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 16
0
int main(int argc, char *argv[])
{
   s2opend("/s2mono", argc, argv);             	/* Open in mono mode */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */
   
   xs2mp(master_panel, 0.0, 0.5, 0.5, 1.0);	/* Move to top left */

   slave_panel = xs2ap(0.5, 0.0, 1.0, 0.5);	/* Create panel in bottom right */
   xs2cp(slave_panel);				/* Choose this panel */
   s2swin(-2.,2., -2.,2., -2.,2.);              /* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);  	/* Draw coordinate box */
  
   xs2cp(master_panel);				/* Go back to main panel */
   cs2scb(cb);					/* Install dynamic callback */

   fprintf(stderr,"Press <tab> to switch between panels\n");
   fprintf(stderr,"Press <spacebar> to link cameras together - cannot be undone\n");
   fprintf(stderr,"Futher presses of <spacebar> toggle panel visiblity\n");

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

   return 1;
}
Ejemplo n.º 17
0
int main(int argc, char *argv[])
{

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

   s2lab("","","","Press < and > to change camera movement increment, then +/- to test zooming\n"); 

   cs2scb(cb);					/* Install dynamic callback */
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 18
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;
}
Ejemplo n.º 19
0
int main(int argc, char *argv[])
{

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

   cs2scb(cb);					/* Install a dynamic callback */

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

   
   return 1;
}
Ejemplo n.º 20
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;
}
Ejemplo n.º 21
0
int main(int argc, char *argv[])
{
   int Nx = 32, Ny = 32, Nz = 32;		/* Texture dimensions */
   int w,h,d;					/* Returned dimensions */

   s2opend("/?",argc,argv);			/* Open the s2plot display device */
   s2swin(-1,1,-1,1,-1,1);			/* Set the world coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);
	
   texid = ss2c3dt(Nx, Ny, Nz);			/* Create a new 3d texture */
   unsigned char *bits = (unsigned char *)ss2g3dt(texid, &w, &h, &d);
						/* Get the texture data for modification */
   int i, j, k;
   long idx;
   float x,y,z;  
   for (i=0;i<Nx;i++) {
      x = -1.0 + i*(2.0/(float)(Nx-1));
      for (j=0;j<Ny;j++) {
         y = -1.0 + j*(2.0/(float)(Ny-1));
         for (k=0;k<Nz;k++) {
            z = -1.0 + k*(2.0/(float)(Nz-1));
            idx = ((i*Ny + j)*Nz + k)*4;
	    if ((x*x + y*y + z*z) < 1.0) {	/* 3D solid red sphere */
               bits[idx + 1 ] = 255;
               ns2point(x,y,z,1,1,1);		/* Plot point in sphere */
            } else { 
               bits[idx + 0 ] = 0;
            }

	    bits[idx + 1 ] = 0;			/* Blue channel */
	    bits[idx + 2 ] = 0;			/* Green channel */
	    bits[idx + 3 ] = 255;		/* Alpha channel */
         }     
      }     
   }     

   fprintf(stderr, "3d texture IS %d x %d x %d\n", w, h, d);
   ss2pt(texid);				/* Push back the texture */

   cs2scb(cb);					/* Install a dynamic callback */
   				
   s2show(1);					/* Display the geometry */

   return 0;
}
Ejemplo n.º 22
0
int main(int argc, char *argv[])
{
   srand48((long)time(NULL));			/* Seed random numbers */
   s2opend("/?", argc, argv);			/* Prompt for display type */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);	/* Draw coordinate box */

   cs2scb(cb);					/* Install dynamic geometry callback */
   cs2sncb(ncb);				/* Install number key press callback */

   char string[128];				/* Write instruction label */
   sprintf(string,"Press 1 to protect, press 2 to unprotect");
   s2lab("","","",string);

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 23
0
nemo_main()
{
    permanent bool first=TRUE;
    int argc = 1;
    static char *argv[] = {"snaps2plot", NULL};
    float size = 1.0;
    extern string yapp_string;

    setparams();

    /* also:  check env var S2PLOT_DEV */
#if 0
    s2opend("/?", argc, argv);
#else
    s2opendo(yapp_string);
#endif
    s2swin((float)xrange[0], (float)xrange[1], 
	   (float)yrange[0], (float)yrange[1], 
	   (float)zrange[0], (float)zrange[1]);
    s2box(s2box_opt,0,0,s2box_opt,0,0,s2box_opt,0,0);
    s2lab(xlabel,ylabel,zlabel,input);


    instr = stropen(input, "r");
    get_history(instr);
    compfuncs();
#ifdef COLOR
    setcolors();
#endif
    while (scansnap()) {
	if (! trakflag) {
	  if (first) {
	    first = FALSE;
	  } else {
	    sleep(FRAMEDELAY);
	    plframe();
	  } 
	}
	plotsnap();
	warning("Can only do first selected snapshot");
	s2show(1);
	/* how to clear and advance to next snapshot */
    }
}
Ejemplo n.º 24
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;
}
Ejemplo n.º 25
0
int main(int argc, char *argv[])
{
   XYZ vertex[4];				/* 4 vertices */
   COLOUR col = { 1.0, 1.0, 0.3 };		/* Yellowish */

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

   vertex[0].x = 0.0; vertex[0].y =  0.0; vertex[0].z = 0.0;
   vertex[1].x = 0.5; vertex[1].y =  0.0; vertex[1].z = 0.0;
   vertex[2].x = 0.5; vertex[2].y = -0.4; vertex[2].z = 1.0;
   vertex[3].x = 0.0; vertex[3].y = -0.4; vertex[3].z = 1.0;

   ns2vf4(vertex, col);                         /* Draw the polygon */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
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;
}
Ejemplo n.º 28
0
int main(int argc, char *argv[])
{
   XYZ xyz    = { 0.0, 0.0, 0.0 };
   COLOUR col = { 1.0, 1.0, 1.0 };		/* White */
   float radius = 0.2;				/* Sphere radius */
   float lx, ly, lz;				/* Light position */
   float lr, lg, lb;				/* Light colour */

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

   lx = 0.0; ly = 0.3; lz = 0.8; 		/* Light position */ 
   lr = 0.0; lg = 0.0; lb = 1.0; 		/* A blue light */ 

   ns2vsphere(xyz, radius, col);		/* Draw a sphere */
   ns2i(lx,ly,lz, lr,lg,lb);			/* Put the light in */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 29
0
int main(int argc, char *argv[])
{
   XYZ xyz;					/* Declare an XYZ variable */
   COLOUR col;					/* Declare a COLOUR variable */
   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 */

   xyz.x =  0.0;				/* Set some values */
   xyz.y =  0.5;
   xyz.z = -0.3;

   col.r = 0.3;					/* Set colour value */
   col.g = 1.0;
   col.b = 0.7;

   ns2vpoint(xyz, col);				/* Draw the point */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Ejemplo n.º 30
0
int main(int argc, char *argv[])
{
   char xopt[] = "BCDETMNOPQ";
   char yopt[] = "BCDETMNOPQ";
   char zopt[] = "BCDETMNOPQ";

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box(xopt, 0,0, yopt, 0,0, zopt, 0,0);	/* Draw the coordinate box */
   s2lab("X-axis","Y-axis","Z-axis","Plot");	/* Write some labels */

   XYZ xyz1 = { -0.8, -0.8, -0.8 };		/* Box coordinate */
   XYZ xyz2 = { +0.8, +0.8, +0.8 };		/* Box coordinate */
   COLOUR col = { 1.0, 0.3, 0.2 };		/* RGB colours */

   float alpha = 0.4;				/* Alpha channel transparency */

   ns2vscube(xyz1, xyz2, col, alpha);

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