2
0

math.c 4.4 KB

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