Function:ns2vm

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 01:32, 30 October 2007
S2plot admin (Talk | contribs)

← Previous diff
Revision as of 04:25, 11 December 2007
S2plot admin (Talk | contribs)

Next diff →
Line 15: Line 15:
* 1 = wireframe 3D cross * 1 = wireframe 3D cross
* 2 = shaded box * 2 = shaded box
-* 4 = octahedron (diamond)+* 3 = octahedron (diamond)
== See Also == == See Also ==
Line 44: Line 44:
marker = 0; marker = 0;
- for (i=0;i<12;i++) {+ for (i=0;i<4;i++) {
- xyz.x = drand48()*2.0 - 1.0; /* Random position */+ x = drand48()*2.0 - 1.0; /* Random position */
- xyz.y = drand48()*2.0 - 1.0;+ y = drand48()*2.0 - 1.0;
- xyz.z = drand48()*2.0 - 1.0;+ z = drand48()*2.0 - 1.0;
- col.r = drand48(); /* Randomish colour */+ r = drand48(); /* Randomish colour */
- col.g = 1.0; + g = 1.0;
- col.b = 0.3; + b = 0.3;
- ns2vm(marker, size, xyz, col); /* Draw the marker */+ ns2m(marker, size, xyz, rgb); /* Draw the marker */
- marker++;+ marker = (marker+1)%4;
- if (marker == 3) marker++; /* There is no marker 3 */+
- if (marker > 4) marker = 0;+
} }

Revision as of 04:25, 11 December 2007

ns2vm

Draw a marker - vector input

Prototype

void ns2vm(int type, float size, XYZ P, COLOUR col);

Description

Draw a marker at position P, with size and RGB colour col, using vector data structures. Argument type should be one of:

  • 0 = tetrahedron (pyramid)
  • 1 = wireframe 3D cross
  • 2 = shaded box
  • 3 = octahedron (diamond)

See Also

ns2m Draw a marker
struct_COLOUR Data structure for (r,g,b) colour indices.
struct_XYZ Data structure for (x,y,z) coordinates.


Code Example

#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"

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

   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++) {
      x = drand48()*2.0 - 1.0;			/* Random position */
      y = drand48()*2.0 - 1.0;
      z = drand48()*2.0 - 1.0;
      r = drand48();				/* Randomish colour */
      g = 1.0; 
      b = 0.3; 
      ns2m(marker, size, xyz, rgb);		/* Draw the marker */
      marker = (marker+1)%4;
   }

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

Back to S2PLOT function list.


Personal tools