Function:ss2qpr

From S2PLOT

Jump to: navigation, search

ss2qpr

Query point to rotate camera about.

Prototype

void ss2qpr(XYZ *position, int worldcoords);

Description

Query the point to rotate about camera and geometry about. Fortunately or unfortunately, this is not guaranteed to be the same as the focus point (what the camera is looking at); the meanings are mixed and need to be disentangled. For now, we allow querying of this point independent of the focus point, as it is needed for some things like GPU-based volume rendering.


See Also

ss2scfSet the camera mid/focus point.
ss2scfUnset the camera mid/focus point - return to auto mid-point

Code Example

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

void cb(double *t, int *kc)
/* Dynamic callback function */
{
   XYZ rot;
   int wc = 1;                          /* Use world coordinates */
   XYZ off = { 0.01, 0.01, 0.0 };       /* Small offset for text */

   int set;
   char string[255];
   s2sch(0.05);                         /* Set the text height */
   if (*kc%2 == 0) {
      ss2qpr(&rot, wc);                 /* Query the rotation point */
      sprintf(string,"Rotation about (%.2f, %.2f, %.2f)",rot.x,rot.y,rot.z);
      XYZ xyz = { 0.5, 0.5, 0.5 };
      ss2scf(xyz, wc);                  /* Set the camera focus */
   } else {
      ss2qcf(&set, &rot, wc);           /* Query the camera focus */
      sprintf(string,"Focus at (%.2f, %.2f, %.2f)",rot.x,rot.y,rot.z);
   }
   ds2vtb(rot, off,string,1);           /* Write some dynamic billboard text */
   s2lab("","","","<space> to toggle mode");
                                        /* Display an instructional label */

}

int main(int argc, char *argv[])
{
   int i;                               /* Loop variable */
   XYZ xyz;                             /* Coordinate for plotting points */
   COLOUR col;                          /* Colour of plotted points */

   s2opend("/S2MONO",argc,argv);        /* Query the s2plot device to use */
   s2swin(-1.,1.,-1.,1.,-1.,1.);        /* Set the world coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);     /* Draw a coordinate box */

   srand48((long)time(NULL));           /* Seed the random number generator */

   for (i=0;i<1000;i++) {               /* Generate and plot random points */
      xyz.x = drand48()*2.0 - 1.0;      /*  with random colours */
      xyz.y = drand48()*2.0 - 1.0;
      xyz.z = drand48()*2.0 - 1.0;
      col.r = drand48();
      col.g = drand48();
      col.b = drand48();
      ns2vpoint(xyz, col);
   }
   ss2sas(1);                           /* Start the geometry auto-spinning */
   cs2scb(cb);                          /* Install a dynamic callback */
   s2show(1);                           /* Display the geometry */
   return 0;
}

Back to S2PLOT function list.


Personal tools