Function:s2chromapts
From S2PLOT
s2chromapts
Plot points on a sphere using chromastereoscopic colouring for depth
Prototype
void s2chromapts(int n, float *ilong, float *lat, float *dist, float *size, float radius, float dmin, float dmax);
Description
Plot points on a sphere of given radius, at given longitude ilong and latitude ilat (in degrees), coloured by the current colormap. Array dist gives the distance to each point. Index into map is calculated linearly between dmin and dmax. This function is so called because with the right colormap, a chromastereoscopic view will be produced for observing from the origin of the coordinate system - especially useful when using a fisheye projection. Array size contains the desired sizes of the points.
See Also
s2chromacpts | Plot cartesian points using chromastereoscopic colouring for depth |
ss2lcm | Load a colourmap into memory. |
s2ldev | List the available S2PLOT devices on stdout. |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "s2plot.h"
#define NPTS 500
#define D2R (M_PI / 180.)
int main(int argc, char **argv)
{
XYZ pos = {0., 0., -0.1}; /* Camera position */
XYZ up = {0., 1., 0.}; /* Camera up vector */
XYZ view = {0., 0., 1.}; /* Camera view direction */
int nentries; /* Number of entries in colour map */
float a[NPTS], b[NPTS], dist[NPTS]; /* Coordinates for each point */
float size[NPTS]; /* Size to plot point */
int i; /* Loop variable */
fprintf(stderr,"This demonstration appears in 3D when viewed with ");
fprintf(stderr,"Chromadepth(TM) glasses\n");
s2opend("/S2FISH",argc, argv); /* Open the display - fisheye */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
ss2sc(pos, up, view, 0); /* Set camera position */
ss2tc(0); /* prevent translation of the camera */
/* Load the chromadepth colour map, stored in directory S2PLOT_TEXPATH */
nentries = ss2lcm("chromapal.txt", 100, 2000);
s2scir(100, 100+nentries-1); /* Set colour range */
for (i=0;i<NPTS;i++) { /* Create random positions */
a[i] = (float)(rand()) / (float)RAND_MAX * 360.;
b[i] = asinf(-1. + 2. * (float)(rand()) / (float)RAND_MAX) / M_PI * 180.0;
dist[i] = sqrtf((float)(rand()) / (float)RAND_MAX * 100.);
size[i] = 11. - dist[i] * 0.8; /* Size based on distance */
}
s2chromapts(NPTS, a, b, dist, size, 1., 0., 10.);
/* Plot using chromadepth information */
s2show(1);
return 1;
}
Back to S2PLOT function list.