|
World of Rigid Bodies (WoRB)
|
00001 #ifndef _CONSTANTS_H_INCLUDED 00002 #define _CONSTANTS_H_INCLUDED 00003 00004 /** 00005 * @file Constants.h 00006 * @brief Definitions for the Const static class that encapsulates various 00007 * physical and mathematical constants. 00008 * @author Mikica Kocic 00009 * @version 0.1 00010 * @date 2012-05-06 00011 * @copyright GNU Public License. 00012 */ 00013 00014 namespace WoRB 00015 { 00016 class Quaternion; 00017 00018 ///////////////////////////////////////////////////////////////////////////////////// 00019 /** @class Const 00020 * 00021 * Physical and mathematical constants. 00022 */ 00023 class Const 00024 { 00025 public: 00026 00027 ///////////////////////////////////////////////////////////////////////////////// 00028 00029 /** Represents X-axis unit vector. 00030 */ 00031 const static Quaternion X; 00032 00033 /** Represents Y-axis unit vector. 00034 */ 00035 const static Quaternion Y; 00036 00037 /** Represents Z-axis unit vector. 00038 */ 00039 const static Quaternion Z; 00040 00041 ///////////////////////////////////////////////////////////////////////////////// 00042 00043 /** Gets standard gravity (standard acceleration due to free fall in kg m/s^2). 00044 * @note Standard gravity is given along Y-axis as vertical axis. 00045 */ 00046 const static Quaternion g_n; 00047 00048 ///////////////////////////////////////////////////////////////////////////////// 00049 00050 /** Represents Pi. 00051 */ 00052 const static double Pi; 00053 00054 ///////////////////////////////////////////////////////////////////////////////// 00055 00056 /** Represents the maximum finite value for a double floating-point number. 00057 */ 00058 const static double Max; 00059 00060 /** Represents the minimum finite value for a double floating-point number. 00061 */ 00062 const static double Min; 00063 00064 /** Gets the smallest positive `x` such that `x + Eps + x` is representable. 00065 */ 00066 const static double Eps; 00067 00068 /** Returns the representation of positive infinity. 00069 */ 00070 const static double Inf; 00071 00072 /** Returns the representation of a quiet not a number (NaN). 00073 */ 00074 const static double NaN; 00075 00076 /** Returns true if the argument is NaN. 00077 */ 00078 static bool IsNaN( double x ) 00079 { 00080 return x != x; 00081 } 00082 00083 /** Returns +1/-1 if the argument is positive/negative infinity. 00084 */ 00085 static int IsInf( double x ) 00086 { 00087 double delta = x - x; 00088 if ( x == x && delta != 0.0 ) { 00089 return x < 0.0 ? -1 : 1; 00090 } 00091 return 0; 00092 } 00093 00094 ///////////////////////////////////////////////////////////////////////////////// 00095 }; 00096 00097 } // namespace WoRB 00098 00099 #endif // _QUATERNION_H_INCLUDED