#include "lib/float.qh"
+[[eraseable]]
void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight)
{
if (weight == 0) return;
e.(c) += weight;
}
+[[eraseable]]
float mean_evaluate(entity e, .float a, .float c, float mean)
{
if (e.(c) == 0) return 0;
*/
+[[eraseable]]
float angc(float a1, float a2)
{
while (a1 > 180)
return a;
}
+[[eraseable]]
float fsnap(float val, float fsize)
{
return rint(val / fsize) * fsize;
}
+[[eraseable]]
vector vsnap(vector point, float fsize)
{
vector vret;
return vret;
}
+[[eraseable]]
vector lerpv(float t0, vector v0, float t1, vector v1, float t)
{
return v0 + (v1 - v0) * ((t - t0) / (t1 - t0));
}
+[[eraseable]]
vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t)
{
return (c - 2 * b + a) * (t * t)
+ a;
}
+[[eraseable]]
vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t)
{
return (c - 2 * b + a) * (2 * t)
+ (b - a) * 2;
}
+[[eraseable]]
float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd)
{
return (((startspeedfactor + endspeedfactor - 2
) * spd;
}
+[[eraseable]]
bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor)
{
if (startspeedfactor < 0 || endspeedfactor < 0) return false;
}
/** continuous function mapping all reals into -1..1 */
+[[eraseable]]
float float2range11(float f)
{
return f / (fabs(f) + 1);
}
/** continuous function mapping all reals into 0..1 */
+[[eraseable]]
float float2range01(float f)
{
return 0.5 + 0.5 * float2range11(f);
}
+[[eraseable]]
float median(float a, float b, float c)
{
return (a < c) ? bound(a, b, c) : bound(c, b, a);
}
+[[eraseable]]
float almost_equals(float a, float b)
{
float eps = (max(a, -a) + max(b, -b)) * 0.001;
return a - b < eps && b - a < eps;
}
+[[eraseable]]
float almost_equals_eps(float a, float b, float times_eps)
{
float eps = max(fabs(a), fabs(b)) * FLOAT_EPSILON * times_eps;
return a - b < eps && b - a < eps;
}
+[[eraseable]]
float almost_in_bounds(float a, float b, float c)
{
float eps = (max(a, -a) + max(c, -c)) * 0.001;
return b == median(a - eps, b, c + eps);
}
+[[eraseable]]
float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
{
if (halflifedist > 0) return (0.5 ** ((bound(mindist, d, maxdist) - mindist) / halflifedist));
#define power2of(e) (2 ** e)
+[[eraseable]]
float log2of(float e)
{
// NOTE: generated code
}
/** ax^2 + bx + c = 0 */
+[[eraseable]]
vector solve_quadratic(float a, float b, float c)
{
vector v;