Function:ss2sca

From S2PLOT

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

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

Line 1: Line 1:
==ss2sca== ==ss2sca==
 +Set the camera aperture.
==Prototype== ==Prototype==
<code><pre> <code><pre>
 +void ss2sca(float aperture);
</pre></code> </pre></code>
==Description== ==Description==
 +Set the camera aperture (in degrees).
==See Also== ==See Also==
 +<table>
 +<tr><td>[[Function:ss2qca | ss2qca ]]</td><td>Query the camera aperture. </td></tr>
 +<tr><td>[[Function:ss2scs | ss2scs ]]</td><td>Set the camera speed. </td></tr>
 +<tr><td>[[Function:ss2qcs | ss2qcs ]]</td><td>Query the camera speed. </td></tr>
 +<tr><td>[[Function:ss2sc | ss2sc ]]</td><td>Set the camera position, up vector and view direction. </td></tr>
 +<tr><td>[[Function:ss2qc | ss2qc ]]</td><td>Query the camera position, up vector and view direction. </td></tr>
 +</table>
==Code Example== ==Code Example==
<code><pre> <code><pre>
-</pre></code>+#include <stdio.h>
 +#include <stdlib.h>
 +#include <time.h>
 +#include "s2plot.h"
-[[S2PLOT:Function List | Back]] to S2PLOT function list.+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 */
 + }
-__NOTOC__+ static int lkc = 1; /* Last time <space> key pressed */
-__NOEDITSECTION__+ 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 */
-Back to [[Function:Template | template]] page.+ 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>
 + 
 +[[S2PLOT:Function List | Back]] to S2PLOT function list.
 + 
 +__NOTOC__
 +__NOEDITSECTION__

Current revision

ss2sca

Set the camera aperture.

Prototype

void ss2sca(float aperture);

Description

Set the camera aperture (in degrees).

See Also

ss2qca Query 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