]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/math.qh
pow(a, b) -> a ** b
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / math.qh
index 94cdcc6710c2627ef76890036b12ba719bfff365..de6cb95c37c4e9b971c0b2e350cea712adee9b54 100644 (file)
@@ -5,16 +5,16 @@
 void mean_accumulate(entity e, .float a, .float c, float mean, float value, float weight)
 {
        if (weight == 0) return;
-       if (mean == 0) e.(a) *= pow(value, weight);
-       else e.(a) += pow(value, mean) * weight;
+       if (mean == 0) e.(a) *= (value ** weight);
+       else e.(a) += (value ** mean) * weight;
        e.(c) += weight;
 }
 
 float mean_evaluate(entity e, .float a, .float c, float mean)
 {
        if (e.(c) == 0) return 0;
-       if (mean == 0) return pow(e.(a), 1.0 / e.(c));
-       else return pow(e.(a) / e.(c), 1.0 / mean);
+       if (mean == 0) return (e.(a) ** (1.0 / e.(c)));
+       else return ((e.(a) / e.(c)) ** (1.0 / mean));
 }
 
 #define MEAN_ACCUMULATE(s, prefix, v, w) mean_accumulate(s, prefix##_accumulator, prefix##_count, prefix##_mean, v, w)
@@ -193,14 +193,14 @@ float almost_in_bounds(float a, float b, float c)
 
 float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
 {
-       if (halflifedist > 0) return pow(0.5, (bound(mindist, d, maxdist) - mindist) / halflifedist);
-       else if (halflifedist < 0) return pow(0.5, (bound(mindist, d, maxdist) - maxdist) / halflifedist);
+       if (halflifedist > 0) return (0.5 ** (bound(mindist, d, maxdist) - mindist) / halflifedist);
+       else if (halflifedist < 0) return (0.5 ** (bound(mindist, d, maxdist) - maxdist) / halflifedist);
        else return 1;
 }
 
 float power2of(float e)
 {
-       return pow(2, e);
+       return (2 ** e);
 }
 
 float log2of(float e)