Function:s2qah

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:28, 23 November 2007
S2plot admin (Talk | contribs)

← Previous diff
Current revision
S2plot admin (Talk | contribs)

Line 1: Line 1:
-==s2qci==+==s2qah==
Query the arrow-head style. Query the arrow-head style.
Line 14: Line 14:
<table> <table>
<tr><td>[[Function:s2sah | s2sah]]</td><td>Set the arrow-head style.</td><td> </td></tr> <tr><td>[[Function:s2sah | s2sah]]</td><td>Set the arrow-head style.</td><td> </td></tr>
 +<tr><td>[[Function:s2arro | s2arro ]]</td><td>Draw an arrow from the point with world-coordinates (x1,y1,z1) to (x2,y2,z2). </td></tr>
</table> </table>
Line 20: Line 21:
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
 +#include <time.h>
#include "s2plot.h" #include "s2plot.h"
Line 35: Line 37:
float angle, barb; /* Arrow parameters */ float angle, barb; /* Arrow parameters */
s2qah(&fs, &angle, &barb); /* Query arrow paramters */ s2qah(&fs, &angle, &barb); /* Query arrow paramters */
- + 
- char string[32]; + char string[32];
- sprintf(string,"Arrow (angle,barb) = (%.2f, %.2f)",angle,barb); + sprintf(string,"Arrow (angle,barb) = (%.2f, %.2f)",angle,barb);
/* Write to string */ /* Write to string */
s2textxy(0,0,0,string); /* Display text */ s2textxy(0,0,0,string); /* Display text */
s2sch(4); /* Control size of arrowhead */ s2sch(4); /* Control size of arrowhead */
- float x[2], y[2], z[2]; + float x[2], y[2], z[2];
x[0] = -0.8; y[0] = -0.4; z[0] = 0.0; /* Coordinates of line */ x[0] = -0.8; y[0] = -0.4; z[0] = 0.0; /* Coordinates of line */
x[1] = +0.8; y[1] = -0.4; z[1] = 0.0; x[1] = +0.8; y[1] = -0.4; z[1] = 0.0;
- s2arro(x[0],y[0],z[0], x[1],y[1],z[1]); /* Draw the arrow */ + s2arro(x[0],y[0],z[0], x[1],y[1],z[1]); /* Draw the arrow */
s2sch(1); /* Reset size for text */ s2sch(1); /* Reset size for text */
Line 55: Line 57:
fprintf(stderr,"Press the <spacebar> to change arrow parameters"); fprintf(stderr,"Press the <spacebar> to change arrow parameters");
 + srand48((long)time(NULL)); /* Seed random numbers */
s2opend("/s2mono", argc, argv); /* Open in mono mode */ s2opend("/s2mono", argc, argv); /* Open in mono mode */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */ s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
- + 
cs2scb(cb); /* Install dynamic callback */ cs2scb(cb); /* Install dynamic callback */
s2show(1); /* Open the s2plot window */ s2show(1); /* Open the s2plot window */
Line 64: Line 67:
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

s2qah

Query the arrow-head style.

Prototype

void s2qah(int *fs, float *angle, float *barb);

Description

Query the arrow-head style.

See Also

s2sahSet the arrow-head style.
s2arro Draw an arrow from the point with world-coordinates (x1,y1,z1) to (x2,y2,z2).

Code Example

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

void cb(double *t, int *kc)
{
   static int lkc = 0;                          /* Count of key presses */
   int filled = 1;                              /* Arrow fill style */

   if (lkc != *kc) {                            /* Space bar pressed? */
      s2sah(filled, drand48()*130+5.0, drand48()*0.95+0.05);
                                                /* Choose random arrow format */
   }

   int fs;                                      /* Fill style */
   float angle, barb;                           /* Arrow parameters */
   s2qah(&fs, &angle, &barb);                   /* Query arrow paramters */

   char string[32];
   sprintf(string,"Arrow (angle,barb) = (%.2f, %.2f)",angle,barb);
                                                /* Write to string */
   s2textxy(0,0,0,string);                      /* Display text */

   s2sch(4);                                    /* Control size of arrowhead */
   float x[2], y[2], z[2];
   x[0] = -0.8; y[0] = -0.4; z[0] = 0.0;        /* Coordinates of line */
   x[1] = +0.8; y[1] = -0.4; z[1] = 0.0;
   s2arro(x[0],y[0],z[0], x[1],y[1],z[1]);      /* Draw the arrow */
   s2sch(1);                                    /* Reset size for text */

   lkc = *kc;                                   /* Update count */
}

int main(int argc, char *argv[])
{
   fprintf(stderr,"Press the <spacebar> to change arrow parameters");

   srand48((long)time(NULL));                   /* Seed random numbers */
   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;
}

Back to S2PLOT function list.


Personal tools