2
0

MathBinds.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #include "MathUtils.h"
  2. #include "Types.h"
  3. namespace crown
  4. {
  5. extern "C"
  6. {
  7. bool math_equals(float a, float b);
  8. bool math_test_bitmask(int32_t value, int32_t bitmask);
  9. int32_t math_set_bitmask(int32_t value, int32_t bitmask);
  10. int32_t math_unset_bitmask(int32_t value, int32_t bitmask);
  11. float math_deg_to_rad(float deg);
  12. float math_rad_to_deg(float rad);
  13. uint32_t math_next_pow_2(uint32_t x);
  14. bool math_is_pow_2(uint32_t x);
  15. float math_ceil(float x);
  16. float math_floor(float x);
  17. float math_sqrt(float x);
  18. float math_inv_sqrt(float x);
  19. float math_sin(float x);
  20. float math_cos(float x);
  21. float math_asin(float x);
  22. float math_acos(float x);
  23. float math_tan(float x);
  24. float math_atan2(float y, float x);
  25. float math_abs(float x);
  26. float math_fmod(float n, float d);
  27. }
  28. //-------------------------------------------------------------------
  29. bool math_equals(float a, float b)
  30. {
  31. return math::equals(a, b, math::FLOAT_PRECISION);
  32. }
  33. //-------------------------------------------------------------------
  34. bool math_test_bitmask(int32_t value, int32_t bitmask)
  35. {
  36. return math::test_bitmask(value, bitmask);
  37. }
  38. //-------------------------------------------------------------------
  39. int32_t math_set_bitmask(int32_t value, int32_t bitmask)
  40. {
  41. return math::set_bitmask(value, bitmask);
  42. }
  43. //-------------------------------------------------------------------
  44. int32_t math_unset_bitmask(int32_t value, int32_t bitmask)
  45. {
  46. return math::unset_bitmask(value, bitmask);
  47. }
  48. //-------------------------------------------------------------------
  49. float math_deg_to_rad(float deg)
  50. {
  51. return math::deg_to_rad(deg);
  52. }
  53. //-------------------------------------------------------------------
  54. float math_rad_to_deg(float rad)
  55. {
  56. return math::rad_to_deg(rad);
  57. }
  58. //-------------------------------------------------------------------
  59. uint32_t math_next_pow_2(uint32_t x)
  60. {
  61. return math::next_pow_2(x);
  62. }
  63. //-------------------------------------------------------------------
  64. bool math_is_pow_2(uint32_t x)
  65. {
  66. return math::is_pow_2(x);
  67. }
  68. //-------------------------------------------------------------------
  69. float math_ceil(float x)
  70. {
  71. return math::ceil(x);
  72. }
  73. //-------------------------------------------------------------------
  74. float math_floor(float x)
  75. {
  76. return math::floor(x);
  77. }
  78. //-------------------------------------------------------------------
  79. float math_sqrt(float x)
  80. {
  81. return math::sqrt(x);
  82. }
  83. //-------------------------------------------------------------------
  84. float math_inv_sqrt(float x)
  85. {
  86. return math::inv_sqrt(x);
  87. }
  88. //-------------------------------------------------------------------
  89. float math_sin(float x)
  90. {
  91. return math::sin(x);
  92. }
  93. //-------------------------------------------------------------------
  94. float math_cos(float x)
  95. {
  96. return math::cos(x);
  97. }
  98. //-------------------------------------------------------------------
  99. float math_asin(float x)
  100. {
  101. return math::asin(x);
  102. }
  103. //-------------------------------------------------------------------
  104. float math_acos(float x)
  105. {
  106. return math::acos(x);
  107. }
  108. //-------------------------------------------------------------------
  109. float math_tan(float x)
  110. {
  111. return math::tan(x);
  112. }
  113. //-------------------------------------------------------------------
  114. float math_atan2(float y, float x)
  115. {
  116. return math::atan2(y, x);
  117. }
  118. //-------------------------------------------------------------------
  119. float math_abs(float x)
  120. {
  121. return math::abs(x);
  122. }
  123. //-------------------------------------------------------------------
  124. float math_fmod(float n, float d)
  125. {
  126. return math::fmod(n, d);
  127. }
  128. //-------------------------------------------------------------------
  129. // bool math_solve_quadratic_equation(float a, float b, float c, float& x1, float& x2)
  130. // {
  131. // return math::solve_quadratic_equation(a, b, c, x1, x2);
  132. // }
  133. } // namespace crown