diff options
author | chai <chaifix@163.com> | 2019-12-04 00:07:32 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-12-04 00:07:32 +0800 |
commit | 2e82e2ddd0852b8063a3d6645366f53ee844e273 (patch) | |
tree | 41ec10760f2d2c9f1f782a918f48e1287da2a4b4 /src/math/math.c |
+init
Diffstat (limited to 'src/math/math.c')
-rw-r--r-- | src/math/math.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/math/math.c b/src/math/math.c new file mode 100644 index 0000000..4cca29e --- /dev/null +++ b/src/math/math.c @@ -0,0 +1,21 @@ +#include "math.h" + +char printbuffer[2048] = { 0 }; + +float rsqrt(float number) { + long i; + float x2, y; + const float threehalfs = 1.5F; + + x2 = number * 0.5F; + y = number; + i = *(long *)&y; + i = 0x5f3759df - (i >> 1); + y = *(float *)&i; + y = y * (threehalfs - (x2 * y * y)); + return y; +} + +float lerp(float a, float b, float t) { + return a * (1 - t) + b * t; +}
\ No newline at end of file |