Function:ss2scf
From S2PLOT
ss2scf
Set the camera mid/focus point.
Prototype
void ss2scf(XYZ position, int worldcoords);
Description
Set the camera mid/focus point. If this is set, then rotation will be about the provided point (position). Use ss2ucf to revert to "auto" mid point. If worldcoords > 0 then caller has given world coordinates, otherwise they are viewport-relative coordinates.
See Also
ss2ucf | Unset the camera mid/focus point - revert to auto mid-point. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"
void numcb(int *N)
{
if (*N != 1) return;
ss2ucf(); /* Go back to rotating around centre */
}
int main(int argc, char *argv[])
{
int i, N = 20; /* Loop variables */
float x, y, z; /* Random data */
XYZ focus; /* Point to rotate about */
int wc = 1; /* Use world coordinates */
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 */
s2slw(3); /* Set line width */
for (i=0;i<N;i++) {
x = drand48()*2.0 - 1.0; /* Random (x,y,z) */
y = drand48()*2.0 - 1.0;
z = drand48()*2.0 - 1.0;
s2sci(15*drand48() + 1); /* Random colour */
s2pt1(x,y,z,1); /* Plot the point */
}
focus.x = drand48()*2.0 - 1.0; /* Random rotation point */
focus.y = drand48()*2.0 - 1.0;
focus.z = drand48()*2.0 - 1.0;
ss2scf(focus, wc); /* Set the rotation point */
s2sch(0.7); /* Set text height */
s2textxy(-1,0,0,"Rotate camera - then press 1 followed by +");
cs2sncb(&numcb); /* Install number callback */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.