Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #define SMALL_NUMBER (1.e-8f)
- #define BIG_NUMBER (3.4e+38f)
- #define THRESH_VECTOR_NORMALIZED (0.01f)
- struct MathJSH
- {
- static inline float Square(float x) { return x * x; }
- static inline float Abs(float x) { return x > 0.0f ? x : -x; }
- static inline float Sqrt(float x)
- {
- int NUM_REPEAT = 16;
- int i;
- float result;
- float tmp = x;
- for (i = 0, result = tmp; i < NUM_REPEAT; i++)
- {
- if (result < 1.f) break;
- result = (result*result + tmp) / (2.f*result);
- }
- return result;
- }
- static inline float InvSqrt(float x) { return 1.0f / Sqrt(x); }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement