bbMath.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #include <math.h>
  2. #define RAD_TO_DEG 57.2957795130823208767981548141052
  3. #define DEG_TO_RAD 0.0174532925199432957692369076848861
  4. #ifndef __STDC_VERSION__
  5. #define __STDC_VERSION__ 0
  6. #endif
  7. #if __STDC_VERSION__ >= 199901L
  8. inline int bbIsNan( double x ){
  9. return isnan(x) ? 1 : 0;
  10. }
  11. inline int bbIsInf( double x ){
  12. return isinf(x) ? 1 : 0;
  13. }
  14. inline double bbSqr( double x ){
  15. return sqrt( x );
  16. }
  17. inline double bbSin( double x ){
  18. return sin( x*DEG_TO_RAD );
  19. }
  20. inline double bbCos( double x ){
  21. return cos( x*DEG_TO_RAD );
  22. }
  23. inline double bbTan( double x ){
  24. return tan( x*DEG_TO_RAD );
  25. }
  26. inline double bbASin( double x ){
  27. return asin( x ) * RAD_TO_DEG;
  28. }
  29. inline double bbACos( double x ){
  30. return acos( x ) * RAD_TO_DEG;
  31. }
  32. inline double bbATan( double x ){
  33. return atan( x ) * RAD_TO_DEG;
  34. }
  35. inline double bbATan2( double y,double x ){
  36. return atan2( y,x ) * RAD_TO_DEG;
  37. }
  38. inline double bbSinh( double x ){
  39. return sinh( x );
  40. }
  41. inline double bbCosh( double x ){
  42. return cosh( x );
  43. }
  44. inline double bbTanh( double x ){
  45. return tanh( x );
  46. }
  47. inline double bbExp( double x ){
  48. return exp( x );
  49. }
  50. inline double bbFloor( double x ){
  51. return floor( x );
  52. }
  53. inline double bbLog( double x ){
  54. return log(x);
  55. }
  56. inline double bbLog10( double x ){
  57. return log10(x);
  58. }
  59. inline double bbCeil( double x ){
  60. return ceil( x );
  61. }
  62. inline double bbRound( double x ){
  63. return round( x );
  64. }
  65. inline double bbTrunc( double x ){
  66. return trunc( x );
  67. }
  68. inline double bbDeg2Rad( double x ){
  69. return x * DEG_TO_RAD;
  70. }
  71. inline double bbRad2Deg( double x ){
  72. return x * RAD_TO_DEG;
  73. }
  74. #define RAD_TO_DEGF 57.2957795
  75. #define DEG_TO_RADF 0.0174532
  76. inline float bbSqrf( float x ){
  77. return sqrtf( x );
  78. }
  79. inline float bbSinf( float x ){
  80. return sinf( x*DEG_TO_RADF );
  81. }
  82. inline float bbCosf( float x ){
  83. return cosf( x*DEG_TO_RADF );
  84. }
  85. inline float bbTanf( float x ){
  86. return tanf( x*DEG_TO_RADF );
  87. }
  88. inline float bbASinf( float x ){
  89. return asinf( x ) * RAD_TO_DEGF;
  90. }
  91. inline float bbACosf( float x ){
  92. return acosf( x ) * RAD_TO_DEGF;
  93. }
  94. inline float bbATanf( float x ){
  95. return atanf( x ) * RAD_TO_DEGF;
  96. }
  97. inline float bbATan2f( float y,float x ){
  98. return atan2f( y,x ) * RAD_TO_DEGF;
  99. }
  100. inline float bbSinhf( float x ){
  101. return sinhf( x );
  102. }
  103. inline float bbCoshf( float x ){
  104. return coshf( x );
  105. }
  106. inline float bbTanhf( float x ){
  107. return tanhf( x );
  108. }
  109. inline float bbExpf( float x ){
  110. return expf( x );
  111. }
  112. inline float bbFloorf( float x ){
  113. return floorf( x );
  114. }
  115. inline float bbLogf( float x ){
  116. return logf(x);
  117. }
  118. inline float bbLog10f( float x ){
  119. return log10f(x);
  120. }
  121. inline float bbCeilf( float x ){
  122. return ceilf( x );
  123. }
  124. inline float bbRoundf( float x ){
  125. return roundf( x );
  126. }
  127. inline float bbTruncf( float x ){
  128. return truncf( x );
  129. }
  130. inline float bbDeg2Radf( float x ){
  131. return x * DEG_TO_RADF;
  132. }
  133. inline float bbRad2Degf( float x ){
  134. return x * RAD_TO_DEGF;
  135. }
  136. #else
  137. int bbIsNan( double x );
  138. int bbIsInf( double x );
  139. double bbSqr( double x );
  140. double bbSin( double x );
  141. double bbCos( double x );
  142. double bbTan( double x );
  143. double bbASin( double x );
  144. double bbACos( double x );
  145. double bbATan( double x );
  146. double bbATan2( double y,double x );
  147. double bbSinh( double x );
  148. double bbCosh( double x );
  149. double bbTanh( double x );
  150. double bbExp( double x );
  151. double bbFloor( double x );
  152. double bbLog( double x );
  153. double bbLog10( double x );
  154. double bbCeil( double x );
  155. double bbRound( double x );
  156. double bbTrunc( double x );
  157. double bbDeg2Rad( double x );
  158. double bbRad2Deg( double x );
  159. int bbIsNanf( float x );
  160. int bbIsInff( float x );
  161. float bbSqrf( float x );
  162. float bbSinf( float x );
  163. float bbCosf( float x );
  164. float bbTanf( float x );
  165. float bbASinf( float x );
  166. float bbACosf( float x );
  167. float bbATanf( float x );
  168. float bbATan2f( float y,float x );
  169. float bbSinhf( float x );
  170. float bbCoshf( float x );
  171. float bbTanhf( float x );
  172. float bbExpf( float x );
  173. float bbFloorf( float x );
  174. float bbLogf( float x );
  175. float bbLog10f( float x );
  176. float bbCeilf( float x );
  177. float bbRoundf( float x );
  178. float bbTruncf( float x );
  179. float bbDeg2Radf( float x );
  180. float bbRad2Degf( float x );
  181. #endif