bbMath.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #define RAD_TO_DEGF 57.2957795
  69. #define DEG_TO_RADF 0.0174532
  70. inline float bbSqrf( float x ){
  71. return sqrtf( x );
  72. }
  73. inline float bbSinf( float x ){
  74. return sinf( x*DEG_TO_RADF );
  75. }
  76. inline float bbCosf( float x ){
  77. return cosf( x*DEG_TO_RADF );
  78. }
  79. inline float bbTanf( float x ){
  80. return tanf( x*DEG_TO_RADF );
  81. }
  82. inline float bbASinf( float x ){
  83. return asinf( x ) * RAD_TO_DEGF;
  84. }
  85. inline float bbACosf( float x ){
  86. return acosf( x ) * RAD_TO_DEGF;
  87. }
  88. inline float bbATanf( float x ){
  89. return atanf( x ) * RAD_TO_DEGF;
  90. }
  91. inline float bbATan2f( float y,float x ){
  92. return atan2f( y,x ) * RAD_TO_DEGF;
  93. }
  94. inline float bbSinhf( float x ){
  95. return sinhf( x );
  96. }
  97. inline float bbCoshf( float x ){
  98. return coshf( x );
  99. }
  100. inline float bbTanhf( float x ){
  101. return tanhf( x );
  102. }
  103. inline float bbExpf( float x ){
  104. return expf( x );
  105. }
  106. inline float bbFloorf( float x ){
  107. return floorf( x );
  108. }
  109. inline float bbLogf( float x ){
  110. return logf(x);
  111. }
  112. inline float bbLog10f( float x ){
  113. return log10f(x);
  114. }
  115. inline float bbCeilf( float x ){
  116. return ceilf( x );
  117. }
  118. inline float bbRoundf( float x ){
  119. return roundf( x );
  120. }
  121. inline float bbTruncf( float x ){
  122. return truncf( x );
  123. }
  124. #else
  125. int bbIsNan( double x );
  126. int bbIsInf( double x );
  127. double bbSqr( double x );
  128. double bbSin( double x );
  129. double bbCos( double x );
  130. double bbTan( double x );
  131. double bbASin( double x );
  132. double bbACos( double x );
  133. double bbATan( double x );
  134. double bbATan2( double y,double x );
  135. double bbSinh( double x );
  136. double bbCosh( double x );
  137. double bbTanh( double x );
  138. double bbExp( double x );
  139. double bbFloor( double x );
  140. double bbLog( double x );
  141. double bbLog10( double x );
  142. double bbCeil( double x );
  143. double bbRound( double x );
  144. double bbTrunc( double x );
  145. int bbIsNanf( float x );
  146. int bbIsInff( float x );
  147. float bbSqrf( float x );
  148. float bbSinf( float x );
  149. float bbCosf( float x );
  150. float bbTanf( float x );
  151. float bbASinf( float x );
  152. float bbACosf( float x );
  153. float bbATanf( float x );
  154. float bbATan2f( float y,float x );
  155. float bbSinhf( float x );
  156. float bbCoshf( float x );
  157. float bbTanhf( float x );
  158. float bbExpf( float x );
  159. float bbFloorf( float x );
  160. float bbLogf( float x );
  161. float bbLog10f( float x );
  162. float bbCeilf( float x );
  163. float bbRoundf( float x );
  164. float bbTruncf( float x );
  165. #endif