Function:ss2qca

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:56, 7 January 2009
S2plot admin (Talk | contribs)

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

Line 22: Line 22:
<code><pre> <code><pre>
 +#include <stdio.h>
 +#include <stdlib.h>
 +#include <time.h>
 +#include "s2plot.h"
 +
 +void cb(double *t, int *kc)
 +{
 + int N = 100; /* Number of points */
 + static int flag = -1; /* Flag for initialisation */
 + static XYZ xyz[100]; /* Array of point positions */
 + static COLOUR col[100]; /* Array of colours */
 + int i; /* Loop variable */
 +
 + if (flag < 0) { /* First time through? */
 + for (i=0;i<N;i++) {
 + xyz[i].x = drand48()*2.0 - 1.0; /* Random data positions */
 + xyz[i].y = drand48()*2.0 - 1.0;
 + xyz[i].z = drand48()*2.0 - 1.0;
 + col[i].r = drand48(); /* Random data colours */
 + col[i].g = drand48();
 + col[i].b = drand48();
 + }
 + flag = 1; /* Set the flag */
 + }
 +
 + for (i=0;i<N;i++) {
 + ns2vthpoint(xyz[i], col[i], 3); /* Draw the point */
 + }
 +
 + static int lkc = 1; /* Last time <space> key pressed */
 + if (lkc != *kc) /* Check for keyboard press */
 + ss2sca(drand48()*70 + 20); /* Set the camera aperture */
 + lkc = *kc; /* Update key press */
 +
 + int wc = ss2qca(); /* Query camera aperture */
 + char text[64];
 + sprintf(text, "Aperture %d degrees\n",wc); /* Prepare a text string */
 + s2textxy(0.0,0.0,0.0, text); /* Display text string */
 +
 + s2lab("","","","Press <space> to change camera aperture");
 +}
 +
 +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;
 +}
</pre></code> </pre></code>

Current revision

ss2qca

Query the camera aperture.

Prototype

float ss2qca(void);

Description

Query the camera aperture (in degrees).

See Also

ss2sca Set the camera aperture.
ss2scs Set the camera speed.
ss2qcs Query the camera speed.
ss2sc Set the camera position, up vector and view direction.
ss2qc Query the camera position, up vector and view direction.

Code Example

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

void cb(double *t, int *kc)
{
   int N = 100;                                 /* Number of points */
   static int flag = -1;                        /* Flag for initialisation */
   static XYZ xyz[100];                         /* Array of point positions */
   static COLOUR col[100];                      /* Array of colours */
   int i;                                       /* Loop variable */

   if (flag < 0) {                              /* First time through? */
      for (i=0;i<N;i++) {
         xyz[i].x = drand48()*2.0 - 1.0;        /* Random data positions */
         xyz[i].y = drand48()*2.0 - 1.0;
         xyz[i].z = drand48()*2.0 - 1.0;
         col[i].r = drand48();                  /* Random data colours */
         col[i].g = drand48();
         col[i].b = drand48();
      }
      flag = 1;                                 /* Set the flag */
   }

   for (i=0;i<N;i++) {
      ns2vthpoint(xyz[i], col[i], 3);           /* Draw the point */
   }

   static int lkc = 1;                          /* Last time <space> key pressed */
   if (lkc != *kc)                              /* Check for keyboard press */
      ss2sca(drand48()*70 + 20);                /* Set the camera aperture */
   lkc = *kc;                                   /* Update key press */

   int wc = ss2qca();                           /* Query camera aperture */
   char text[64];
   sprintf(text, "Aperture %d degrees\n",wc);   /* Prepare a text string */
   s2textxy(0.0,0.0,0.0, text);                 /* Display text string */

   s2lab("","","","Press <space> to change camera aperture");
}

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;
}

Back to S2PLOT function list.


Personal tools