From 2e82e2ddd0852b8063a3d6645366f53ee844e273 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 4 Dec 2019 00:07:32 +0800 Subject: +init --- src/math/math.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/math/math.c (limited to 'src/math/math.c') 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 -- cgit v1.1-26-g67d0