Function:ns2m
From S2PLOT
(Difference between revisions)
Revision as of 04:25, 11 December 2007 S2plot admin (Talk | contribs) ← Previous diff |
Current revision S2plot admin (Talk | contribs) |
||
Line 27: | Line 27: | ||
#include <stdio.h> | #include <stdio.h> | ||
#include <stdlib.h> | #include <stdlib.h> | ||
+ | #include <time.h> | ||
#include "s2plot.h" | #include "s2plot.h" | ||
Line 32: | Line 33: | ||
{ | { | ||
int i; | int i; | ||
- | int marker; /* Type of marker to use */ | + | int marker; /* Type of marker to use */ |
- | float x, y, z; /* Position */ | + | float x, y, z; /* Position */ |
- | float r, g, b; /* Colour */ | + | float r, g, b; /* Colour */ |
- | float size = 0.4; /* Size of marker */ | + | float size = 0.4; /* Size of marker */ |
- | s2opend("/?",argc, argv); /* Open the display */ | + | srand48((long)time(NULL)); /* Seed random numbers */ |
- | s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ | + | s2opend("/?",argc, argv); /* Open the display */ |
- | s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */ | + | 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; | marker = 0; | ||
for (i=0;i<4;i++) { | for (i=0;i<4;i++) { | ||
- | x = drand48()*2.0 - 1.0; /* Random position */ | + | x = drand48()*2.0 - 1.0; /* Random position */ |
y = drand48()*2.0 - 1.0; | y = drand48()*2.0 - 1.0; | ||
z = drand48()*2.0 - 1.0; | z = drand48()*2.0 - 1.0; | ||
- | r = drand48(); /* Randomish colour */ | + | r = drand48(); /* Randomish colour */ |
- | g = 1.0; | + | g = 1.0; |
- | b = 0.3; | + | b = 0.3; |
- | ns2m(marker, size, x,y,z, r,g,b); /* Draw the marker */ | + | ns2m(marker, size, x,y,z, r,g,b); /* Draw the marker */ |
marker = (marker+1)%4; | marker = (marker+1)%4; | ||
} | } | ||
- | s2show(1); /* Open the s2plot window */ | + | s2show(1); /* Open the s2plot window */ |
- | + | ||
return 1; | return 1; | ||
} | } | ||
+ | |||
</pre></code> | </pre></code> | ||
[[S2PLOT:Function List | Back]] to S2PLOT function list. | [[S2PLOT:Function List | Back]] to S2PLOT function list. | ||
__NOTOC__ | __NOTOC__ | ||
__NOEDITSECTION__ | __NOEDITSECTION__ |
Current revision
ns2m
Draw a marker
Prototype
void ns2m(int type, float size, float x, float y, float z, float red, float green, float blue);
Description
Draw a marker at (x,y,z) with size and RGB colour (red,green,blue). Argument type should be one of:
- 0 = tetrahedron (pyramid)
- 1 = wireframe 3D cross
- 2 = shaded box
- 3 = octahedron (diamond)
See Also
ns2vm | Draw a marker - vector input |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"
int main(int argc, char *argv[])
{
int i;
int marker; /* Type of marker to use */
float x, y, z; /* Position */
float r, g, b; /* 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++) {
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, x,y,z, r,g,b); /* Draw the marker */
marker = (marker+1)%4;
}
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.