1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include "math.h" char printbuffer[1024] = { 0 }; float rsqrt(float number) { long i; float x2, y; x2 = number * 0.5F; y = number; i = *(long *)&y; i = 0x5f3759df - (i >> 1); y = *(float *)&i; y = y * (1.5F - (x2 * y * y)); return y; } float lerp(float a, float b, float t) { return a * (1 - t) + b * t; }