summaryrefslogtreecommitdiff
path: root/src/math/math.c
blob: 7d731f8024ff2af0a5137bc8c2a9d92f6c7b269b (plain)
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[2048] = { 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;
}