#include <constants.h>
Public Types  
typedef detail::ScalarTrait< S >::type  Real 
Static Public Member Functions  
static constexpr Real  eps () 
Returns ε for the precision of the underlying scalar type. More...  
static Real  eps_12 () 
Returns ε^(1/2) for the precision of the underlying scalar type. More...  
static Real  eps_34 () 
Returns ε^(3/4) for the precision of the underlying scalar type. More...  
static Real  eps_78 () 
Returns ε^(7/8) for the precision of the underlying scalar type. More...  
static Real  gjk_default_tolerance () 
static constexpr S  phi () 
The golden ratio. More...  
static constexpr S  pi () 
The mathematical constant pi. More...  
A collection of scalardependent constants. This provides the ability to get mathematical constants and tolerance values that are appropriately scaled and typed to the scalar type S
.
Constants pi()
and phi()
are returned in the literal scalar type S
. In other words, if S
is an AutoDiffScalar<...>
, then the value of pi
and phi
are likewise AutoDiffScalar<...>
typed.
Tolerances (e.g., eps()
and its variants) are always provided in the scalar's numerical representation. In other words, if S
is a double
or float
, the tolerances are given as double
and float
, respectively. For AutoDiffScalar
it is more interesting. The AutoDiffScalar
has an underlying numerical representation (e.g., AutoDiffScalar<Matrix<double, 1, 3>>
has a double). It is the type of this underlying numerical representation that is provided by the tolerance functions.
This is designed to specifically work with float
, double
, long double
, and corresponding AutoDiffScalar
types. However, custom scalars will also work provided that the scalar type provides a class member type Real
which must be one of long double
, double
, or float
. E.g.,
The above example shows a common but incorrect method for defining a local epsilon. It defines it as being an order of magnitude larger (base 10) than the machine epsilon for S
. However, if S
is a float, its epsilon is essentially 1e7. A full decimal digit of precision is 1/7th of the available digits. In contrast, double epsilon is approximately 2e16. Throwing away a digit there reduces the precision by only 1/16th. This technique disproportionately punishes lowerprecision numerical representations. Instead, by raising epsilon to a fractional power, we scale the precision. Roughly, ε^(1/2)
gives us half the precision (3.5e4 for floats and 1.5e8 for doubles). Similarly powers of 3/4 and 7/8 gives us three quarters and 7/8ths of the bits of precision. By defining tolerances in this way, one can get some fraction of machine precision, regardless of the choice of numeric type.
S  The scalar type for which constant values will be retrieved. 
Definition at line 129 of file constants.h.
typedef detail::ScalarTrait<S>::type fcl::constants< S >::Real 
Definition at line 131 of file constants.h.

inlinestaticconstexpr 
Returns ε for the precision of the underlying scalar type.
Definition at line 151 of file constants.h.

inlinestatic 
Returns ε^(1/2) for the precision of the underlying scalar type.
Definition at line 176 of file constants.h.

inlinestatic 
Returns ε^(3/4) for the precision of the underlying scalar type.
Definition at line 170 of file constants.h.

inlinestatic 
Returns ε^(7/8) for the precision of the underlying scalar type.
Definition at line 164 of file constants.h.

inlinestatic 
Defines the default accuracy for gjk and epa tolerance. It is defined as ε^(7/8) – where ε is the machine precision epsilon for the inuse Real. The value is a much smaller epsilon for doubles than for floats (2e14 vs 9e7, respectively). The choice of ε^(7/8) as the default GJK tolerance reflects a tolerance that is a slightly tighter bound than the historical value of 1e6 used for 32bit floats.
Definition at line 145 of file constants.h.

inlinestaticconstexpr 
The golden ratio.
Definition at line 137 of file constants.h.

inlinestaticconstexpr 
The mathematical constant pi.
Definition at line 134 of file constants.h.