11 e.(a) *= (value ** weight);
13 e.(a) += (value ** mean) * weight;
23 return (e.(a) ** (1.0 / e.(c)));
24 return ((e.(a) / e.(c)) ** (1.0 / mean));
27#define MEAN_ACCUMULATE(s, prefix, v, w) mean_accumulate(s, prefix##_accumulator, prefix##_count, prefix##_mean, v, w)
28#define MEAN_EVALUATE(s, prefix) mean_evaluate(s, prefix##_accumulator, prefix##_count, prefix##_mean)
29#define MEAN_DECLARE(prefix, m) float prefix##_mean = m; .float prefix##_count, prefix##_accumulator
40float angc(
float a1,
float a2)
59float fsnap(
float val,
float fsize)
61 return rint(val / fsize) * fsize;
68 vret.x =
rint(point.x / fsize) * fsize;
69 vret.y =
rint(point.y / fsize) * fsize;
70 vret.z =
ceil(point.z / fsize) * fsize;
77 return f0 * (1 - ratio) +
f1 * ratio;
81float lerp(
float t0,
float f0,
float t1,
float f1,
float t)
97 return f0 * (1 - ratio) +
f1 * ratio;
110 return v0 + (v1 - v0) * ((t - t0) / (t1 - t0));
116 return (c - 2 * b + a) * (t * t)
124 return (c - 2 * b + a) * (2 * t)
131 return (((startspeedfactor + endspeedfactor - 2
132 ) * spd - 2 * startspeedfactor - endspeedfactor + 3
133 ) * spd + startspeedfactor
140 if (startspeedfactor < 0 || endspeedfactor < 0)
152 if (startspeedfactor <= 3 && endspeedfactor <= 3)
156 float se = startspeedfactor + endspeedfactor;
157 float s_e = startspeedfactor - endspeedfactor;
158 if (3 * (se - 4) * (se - 4) + s_e * s_e <= 12)
207 return f / (
fabs(f) + 1);
220 return (a < c) ?
bound(a, b, c) :
bound(c, b, a);
226 float eps = (
max(a, -a) +
max(b, -b)) * 0.001;
227 return a - b < eps && b - a < eps;
234 return a - b < eps && b - a < eps;
240 float eps = (
max(a, -a) +
max(c, -c)) * 0.001;
243 return b ==
median(a - eps, b, c + eps);
249 if (halflifedist > 0)
250 return (0.5 ** ((
bound(mindist, d, maxdist) - mindist) / halflifedist));
251 else if (halflifedist < 0)
252 return (0.5 ** ((
bound(mindist, d, maxdist) - maxdist) / halflifedist));
256#define power2of(e) (2 ** e)
265 if (e > 4194304)
return 23;
267 if (e > 2097152)
return 22;
270 if (e > 524288)
return 20;
272 if (e > 262144)
return 19;
276 if (e > 65536)
return 17;
278 if (e > 32768)
return 16;
281 if (e > 8192)
return 14;
283 if (e > 4096)
return 13;
288 if (e > 1024)
return 11;
290 if (e > 512)
return 10;
293 if (e > 128)
return 8;
295 if (e > 64)
return 7;
299 if (e > 16)
return 5;
331 float D = b * b - 4 * a * c;
337 v.x = ((-b) - D) / (2 * a);
338 v.y = ((-b) + D) / (2 * a);
342 v.x = (-b + D) / (2 * a);
343 v.y = (-b - D) / (2 * a);
367float map_ranges(
float value,
float src_min,
float src_max,
float dest_min,
float dest_max)
369 float src_diff = src_max - src_min;
370 float dest_diff = dest_max - dest_min;
371 float ratio = (value - src_min) / src_diff;
372 return dest_min + dest_diff * ratio;
377float map_bound_ranges(
float value,
float src_min,
float src_max,
float dest_min,
float dest_max)
379 if (value <= src_min)
return dest_min;
380 if (value >= src_max)
return dest_max;
381 return map_ranges(value, src_min, src_max, dest_min, dest_max);
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
const float FLOAT_EPSILON
ERASEABLE float mean_evaluate(entity e,.float a,.float c, float mean)
ERASEABLE float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
ERASEABLE float lerpratio(float f0, float f1, float ratio)
ERASEABLE void mean_accumulate(entity e,.float a,.float c, float mean, float value, float weight)
ERASEABLE float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd)
ERASEABLE float lerp3ratio(float f0, float f1, float f2, float ratio)
ERASEABLE float log2of(float e)
ERASEABLE float map_ranges(float value, float src_min, float src_max, float dest_min, float dest_max)
Maps values between the src and dest range: src_min to dest_min, src_max to dest_max,...
ERASEABLE float angc(float a1, float a2)
ERASEABLE float float2range11(float f)
Continuous function mapping all reals into -1..1.
ERASEABLE vector lerpv3ratio(vector f0, vector f1, vector f2, float ratio)
ERASEABLE vector vsnap(vector point, float fsize)
ERASEABLE vector lerpv(float t0, vector v0, float t1, vector v1, float t)
ERASEABLE float fsnap(float val, float fsize)
ERASEABLE vector solve_quadratic(float a, float b, float c)
ax^2 + bx + c = 0
ERASEABLE float float2range01(float f)
Continuous function mapping all reals into 0..1.
ERASEABLE vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t)
ERASEABLE float almost_equals(float a, float b)
ERASEABLE vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t)
ERASEABLE float median(float a, float b, float c)
ERASEABLE float map_bound_ranges(float value, float src_min, float src_max, float dest_min, float dest_max)
Same as map_ranges except that values outside the source range are clamped to min or max.
ERASEABLE bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor)
ERASEABLE float almost_in_bounds(float a, float b, float c)
ERASEABLE vector lerpvratio(vector f0, vector f1, float ratio)
ERASEABLE float lerp(float t0, float f0, float t1, float f1, float t)
ERASEABLE float almost_equals_eps(float a, float b, float times_eps)
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1points f2