Simbody
3.6

There are two kinds of numerical constants predefined by SimTK: (1) a set of typed, const, inmemory values in the SimTK namespace, at the default Real precision or with other specific types, and (2) a set of preprocessor (#define) macros containing extremely highprecision precalculated numerical values in long double precision. More...
Modules  
Numerical Constants with Types  
This is a set of predefined constants in the form of Real (SimTK default precision) symbols that are important for writing precisionindependent numerical algorithms.  
Preprocessor Macro Constants  
These are preprocessor (#define) macros providing constants values at very high precision. See the discussion under the main Predefined Constants module heading.  
There are two kinds of numerical constants predefined by SimTK: (1) a set of typed, const, inmemory values in the SimTK namespace, at the default Real precision or with other specific types, and (2) a set of preprocessor (#define) macros containing extremely highprecision precalculated numerical values in long double precision.
You should use the typed constants whenever possible in your code since they are very compact and wellbehaved in C++. They have memory addresses so can be returned as references. Because they are filled in at startup, they can include machine and precisionspecific values like NaN, Infinity, machine roundoff error, number of digits in a float, etc. that are very useful for writing robust, precisionindependent numerical algorithms.
The macro values must be cast to the appropriate type before use, and are mostly useful as raw material for making typed constants. These macros contain machineindependent constants, including unitless mathematical constants like pi, as well as physical constants and unit conversion factors. These constants are provided at extremely high precision as compiletime macros in long double precision. By using very high precision we ensure sufficient accuracy for any IEEE long double precision implementation (they can be 64, 80, or 128 bits). These constants can be used as raw material for providing nicer templatized constants in appropriate precisions and unit systems.
Note that the SimTK convention for typed constants is to name them like ordinary variables except with an initial capital letter (like a class name). This is distinct from the widelyused convention for constants that are defined via the presprocessor as macros (that is, using #define). Those are written entirely in UPPER_CASE_WITH_UNDERSCORES
, after an initial SimTK_
. Typed constants are processed instead by the compiler itself and do not require any special treatment when used; they behave just like variables of the same type and value would behave so there is no need to shout when using them.