Constant Time Queries on Uniformly Distributed Points on a Hemisphere

Mel Slater

Software

There is an illustrative implemention of the algorithm described in the paper. It has been developed and tested on a SGI O2 MIPS R5000, Rev 2. It has also been executed on a Toshiba Portege 7200 Series laptop with Microsoft Visual C++ 6.0 - on which it still works, but there are more reported errors. This is probably to do with differences in floating point precision between the two machines.

The implementation makes use of OpenGL and the GLUT library. It also makes use of a 3D graphics library developed for teaching, which for convenience provides some basic data structures such as Point3D, and also a camera model. There is some documentation for this library, though only very few of its data structures and functions are used here, and they should be obvious.

The main program, uniform sphere and query point implementation are in QuerySphere and the graphics library is in Lib3D.

The query sphere implementation writes polygons with RGB floating point values into the frame buffer and then reads them out using glReadPixels. The implementation relies obviously on exactly the same floating RGB point values being extracted from the framebuffer as went into it.
The implementation assumes that the floating point values that can be represented are uniformly distributed in the space available in the number of bits for each of the colours. For example, on the Toshiba Portege, a glGetIntegerv on GL_RED_BITS delivers 5 as the number of bits for red. It is assumed that floating point values available for red between 0.0 and 1.0 are therefore i/31.0 (i=0,1,...,31) on this machine. This type of calculation gives correct results on both the SGI and the Portege. Note that OpenGL does transform the data stored in the framebuffer in various ways (eg, see the documentation for glReadPixels) so that it is important to check this.

Another simple program (colortest) simply fills a window with a color with speficied RGB values decoded from an arbitrary integer and then reads back the framebuffer and prints out the RGB values obtained and the reconstruction of the integer code. If this program does not work then nor will the query sphere program.

QuerySphere.tar.gz

Lib3D.tar.gz