Child pages
  • Numbers and Constants in SimTK

You are viewing the documentation for OpenSim 2.4. Are you looking for the latest OpenSim 4.0 Documentation?

Skip to end of metadata
Go to start of metadata

SimTK supports both float (single) and double precision, and is compiled with one of those as its default, which is then referred to in SimTK as type Real. SimTK::Real is simply a typedef to either the built-in float or double type. OpenSim always uses double precision, so for our purposes the SimTK::Real type is always defined

typedef double Real;

Thus SimTK::Real and double are interchangeable in the OpenSim API. We will use double everywhere because it is more conventional and requires fewer characters. However, if you look elsewhere at SimTK documentation, you will see type Real used instead; just interpret that as double when you see it. Similarly, SimTK has a type SimTK::Complex which is interchangeable here with the C++ built-in type std::complex<double>. You probably will not need to use complex numbers with OpenSim, but they are available if you need them. 

SimTK pre-defines a number of constants to machine precision; we recommend you use those rather than defining your own. The most useful ones are: Pi, E (e), Infinity, NaN (not-a-number), and I (i= sqrt(-1) ). Note that the first letter of constants are capitalized and in the SimTK namespace. 

  • No labels