Function:ns2vnpoint

From S2PLOT

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

← Previous diff
Revision as of 23:17, 10 December 2007
S2plot admin (Talk | contribs)

Next diff →
Line 22: Line 22:
<tr><td>[[Function:struct_XYZ | struct_XYZ ]]</td><td>Data structure for (x,y,z) coordinates. </td></tr> <tr><td>[[Function:struct_XYZ | struct_XYZ ]]</td><td>Data structure for (x,y,z) coordinates. </td></tr>
</table> </table>
 +
 +==Code Example==
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <time.h>
 +#include "s2plot.h"
 +
 +int main(int argc, char *argv[])
 +{
 + int N = 100; /* Number of points */
 + XYZ xyz[100]; /* Positions */
 + COLOUR col; /* Colour */
 + int i;
 +
 + 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); /* Note this does NOT change linewidth - use ns2thpoint */
 + for (i=0;i<N;i++) { /* Random data positions */
 + xyz[i].x = drand48()*2.0 - 1.0;
 + xyz[i].y = drand48()*2.0 - 1.0;
 + xyz[i].z = drand48()*2.0 - 1.0;
 + col.r = drand48();
 + col.g = drand48();
 + col.b = drand48();
 + }
 + ns2vnpoint(xyz, col, N); /* Draw the points */
 +
 + s2show(1); /* Open the s2plot window */
 +
 + return 1;
 +}

Revision as of 23:17, 10 December 2007

ns2vnpoint

Draw multiple points at the given positions with one colour - vector input.

Prototype

void ns2vnpoint(XYZ *P, COLOUR col, int n);

Description

Draw n points at positions P with RBG colour (col), using vector data structures.

See Also

ns2point Draw a point at the given position and colour.
ns2vpoint Draw a point at the given position and colour - vector input.
ns2thpoint Draw a thick point at given position, in colour and thickness in pixels (not world coords).
ns2vthpoint Draw a thick point at given position, in colour and thickness in pixels (not world coords) - vector input.
struct_COLOUR Data structure for (r,g,b) colour indices.
struct_XYZ Data structure for (x,y,z) coordinates.

Code Example

  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <time.h>
  4. include "s2plot.h"

int main(int argc, char *argv[]) {

  int N = 100;                                 /* Number of points */
  XYZ xyz[100];                                /* Positions */
  COLOUR col;                                  /* Colour */
  int i;
  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);    /* Note this does NOT change linewidth - use ns2thpoint */
  for (i=0;i<N;i++) {                          /* Random data positions */
     xyz[i].x = drand48()*2.0 - 1.0;
     xyz[i].y = drand48()*2.0 - 1.0;
     xyz[i].z = drand48()*2.0 - 1.0;
     col.r = drand48();
     col.g = drand48();
     col.b = drand48();
  }
  ns2vnpoint(xyz, col, N);                     /* Draw the points */
  s2show(1);                                   /* Open the s2plot window */
  return 1;

}


Back to S2PLOT function list.