void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight)
{
if (weight == 0) return;
void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight)
{
if (weight == 0) return;
float mean_evaluate(entity e, .float a, .float c, float mean)
{
if (e.(c) == 0) return 0;
float mean_evaluate(entity e, .float a, .float c, float mean)
{
if (e.(c) == 0) return 0;
float fsnap(float val, float fsize)
{
return rint(val / fsize) * fsize;
}
float fsnap(float val, float fsize)
{
return rint(val / fsize) * fsize;
}
vector lerpv(float t0, vector v0, float t1, vector v1, float t)
{
return v0 + (v1 - v0) * ((t - t0) / (t1 - t0));
}
vector lerpv(float t0, vector v0, float t1, vector v1, float t)
{
return v0 + (v1 - v0) * ((t - t0) / (t1 - t0));
}
vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t)
{
return (c - 2 * b + a) * (t * t)
vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t)
{
return (c - 2 * b + a) * (t * t)
vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t)
{
return (c - 2 * b + a) * (2 * t)
+ (b - a) * 2;
}
vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t)
{
return (c - 2 * b + a) * (2 * t)
+ (b - a) * 2;
}
float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd)
{
return (((startspeedfactor + endspeedfactor - 2
float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd)
{
return (((startspeedfactor + endspeedfactor - 2
bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor)
{
if (startspeedfactor < 0 || endspeedfactor < 0) return false;
bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor)
{
if (startspeedfactor < 0 || endspeedfactor < 0) return false;
float float2range11(float f)
{
return f / (fabs(f) + 1);
}
/** continuous function mapping all reals into 0..1 */
float float2range11(float f)
{
return f / (fabs(f) + 1);
}
/** continuous function mapping all reals into 0..1 */
float median(float a, float b, float c)
{
return (a < c) ? bound(a, b, c) : bound(c, b, a);
}
float median(float a, float b, float c)
{
return (a < c) ? bound(a, b, c) : bound(c, b, a);
}
float almost_equals(float a, float b)
{
float eps = (max(a, -a) + max(b, -b)) * 0.001;
return a - b < eps && b - a < eps;
}
float almost_equals(float a, float b)
{
float eps = (max(a, -a) + max(b, -b)) * 0.001;
return a - b < eps && b - a < eps;
}
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;
}
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;
}
float almost_in_bounds(float a, float b, float c)
{
float eps = (max(a, -a) + max(c, -c)) * 0.001;
float almost_in_bounds(float a, float b, float c)
{
float eps = (max(a, -a) + max(c, -c)) * 0.001;
float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
{
if (halflifedist > 0) return (0.5 ** ((bound(mindist, d, maxdist) - mindist) / halflifedist));
float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
{
if (halflifedist > 0) return (0.5 ** ((bound(mindist, d, maxdist) - mindist) / halflifedist));