What is the HOOPS/3dGS Double-Precision Module?

Technical Notes on Double-Precision vs. Single-Precision Values

Getting Started


What is the HOOPS/3dGS Double-Precision Module?

The HOOPS Double-Precision module is a set of routines that enable users to get double-precision data into and out of HOOPS. The double-precision values are only stored for later retrieval, and are not used for display.

Often times the application data used to generate HOOPS/3dGS geometry exists as double-precision values and it would be convenient if these values could be used when creating geometry in HOOPS/3dGS. The HOOPS/3dGS Double-Precision module enables users to insert, edit, and show geometry with double-precision values without data loss. It does this by providing double-precision-variants of the:

routines in the HOOPS/3dGS API, as well as variants of the following Compute routines:

Wherever these routines call for floating point values, the double-precision interface takes doubles.

Transparent to the user, the double-precision variant is a wrapper around the "normal" or single-precision version of the routine. The double-precision variant associates the input double-precision data with a HOOPS key using a hash table that is initialized upon the first call to one of double-precision variants After the double-precision data is stored, it is converted to a form that HOOPS can understand, i.e., downcast to a float. The variant then executes the "normal" variant of the routine on the user's behalf, passing in the downcast version of the double-precision value. When the user later calls the corresponding show routine, the double-precision data is recalled from the hash table.

HOOPS' selection calculations remain single-precision. To access the double-precision information associated with a selected geometric primitive, the primitive's keys and vertex id's should be used to extract double-precision information. In other words, Show_Selection_Position has no double-precision variant, but Show_Selection_Keys and Show_Selection_Element can get the keys and/or id's needed to get double-precision vertices.

The HOOPS/3dGS Double-Precision module contains 53 functions; an enumeration of the double-precision variants of functions is given in the double-precision function index.


Technical Notes on Single vs. Double-Precision Floating Point Values

  • Single-precision requires 32 bits, and gives you about 6 significant digits.
  • 6 significant digits can store 3.14159, 0.0000314159, 314159000, but not 3000.014159
  • Numbers with greater than 6 significant digits stored as single-precision are rounded to the nearest legal value
  • Double-precision requires 64 bits, and gives you about 14 significant digits.
  • Floating point is governed by IEEE standard 754
  • Many non-integers cannot be stored by computers with exact precision. For example the number PI is 3.14159265358979323846........

Assuming we could pass HOOPS/3dGS the infinitely long number PI, what would happen?

HOOPS/3dGS Single Precision

  HC_Insert_Marker( PI, PI, PI )

HOOPS would store PI as single-precision (a.k.a. floating point): 3.14159

HOOPS/3dGS Double-Precision

HC_DInsert_Marker( PI, PI, PI );

HOOPS would store the input point as: (3.1415926535898, 3.1415926535898, 3.1415926535898) in a hash table, cast each of the stored point's values to a single precision float, 3.14159, and call HC_Insert_Marker as above.

The advantage of the double-precision module is that after HC_DShow_Marker( &x, &y, &z ), x, y, and z will be 3.1415926535898, and not just 3.14159.


Getting Started

Programs that use the double-precision module must:

  #include "hcd.h"

and link to hcd.o (named hcd.obj on NT, and hcd.o under Unix platforms).

The object files (hcd.obj or hdc.o) are located in the /hoops/lib directory. Please contact support@techsoft3d.com if you require assistance with linking. The following is a trivial example of how to use the double-precision module.

#include "hc.h" 
#include "hcd.h" 
#define PI 3.14159265358979323846 
int main() 
{ 
   	long key; 
   	double x, y, z; 
 	
	HC_Open_Segment( "?Picture" ); 
   		key = HC_DKInsert_Marker( PI, PI, PI ); 
   		HC_DShow_Marker( key, &x, &y, &z ); 
   	HC_Close_Segment( ); 
   	if(( x == PI ) && ( y == PI ) && ( z == PI )) 
   		printf( "success!" ); 
   	else 
   		printf( "failed." ); 
}