Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #pragma once
  2.  
  3. #define SMALL_NUMBER (1.e-8f)
  4. #define BIG_NUMBER (3.4e+38f)
  5.  
  6. #define THRESH_VECTOR_NORMALIZED (0.01f)
  7.  
  8. struct MathJSH
  9. {
  10. static inline float Square(float x) { return x * x; }
  11. static inline float Abs(float x) { return x > 0.0f ? x : -x; }
  12. static inline float Sqrt(float x)
  13. {
  14. int NUM_REPEAT = 16;
  15. int i;
  16. float result;
  17. float tmp = x;
  18. for (i = 0, result = tmp; i < NUM_REPEAT; i++)
  19. {
  20. if (result < 1.f) break;
  21. result = (result*result + tmp) / (2.f*result);
  22. }
  23. return result;
  24. }
  25. static inline float InvSqrt(float x) { return 1.0f / Sqrt(x); }
  26. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement