]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/warpzone/mathlib.qh
Merge branch 'master' into DefaultUser/armormega
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / warpzone / mathlib.qh
1 #pragma once
2
3 // <math.h>
4
5 // The commented-out functions need no implementation because DarkPlaces offers
6 // them as builtins. They are listed here anyway for completeness sake.
7
8 const int FP_NAN = 0;
9 const int FP_INFINITE = 1;
10 const int FP_ZERO = 2;
11 const int FP_SUBNORMAL = 3;
12 const int FP_NORMAL = 4;
13 int fpclassify(float e);
14 bool isfinite(float e);
15 bool isinf(float e);
16 bool isnan(float e);
17 bool isnormal(float e);
18 bool signbit(float e);
19
20 //float acos(float e);
21 //float asin(float e);
22 //float atan(float e);
23 //float atan2(float f, float e);
24 //float cos(float e);
25 //float sin(float e);
26 //float tan(float e);
27
28 float acosh(float e);
29 float asinh(float e);
30 float atanh(float e);
31 float cosh(float e);
32 float sinh(float e);
33 float tanh(float e);
34
35 float exp(float e);
36 float exp2(float e);
37 float expm1(float e);
38
39 vector frexp(float e); // returns mantissa as _x, exponent as _y
40 int ilogb(float e);
41 float ldexp(float e, int e);
42 //float log(float e);
43 float logn(float e, float base);
44 float log10(float e);
45 float log1p(float e);
46 float log2(float e);
47 float logb(float e);
48 vector modf(float f); // fraction as _x, integer as _y
49
50 float scalbn(float e, int n);
51
52 float cbrt(float e);
53 //float fabs(float e);
54 float hypot(float e, float f);
55 //float pow(float e, float f);
56 //float sqrt(float e, float f);
57
58 float erf(float e);
59 float erfc(float e);
60 vector lgamma(float e); // value in _x, sign in _y
61 float tgamma(float e);
62
63 /**
64  * Pythonic mod:
65  * TODO: %% operator?
66  *
67  *  1 %  2 ==  1
68  * -1 %  2 ==  1
69  *  1 % -2 == -1
70  * -1 % -2 == -1
71  */
72 float pymod(float e, float f);
73
74 //float ceil(float e);
75 //float floor(float e);
76 float nearbyint(float e);
77 //float rint(float e);
78 //float round(float e);
79 float trunc(float e);
80
81 float fmod(float e, float f);
82 float remainder(float e, float f);
83 vector remquo(float e, float f);
84
85 float copysign(float e, float f);
86 float nan(string tag);
87 float nextafter(float e, float f);
88 float nexttoward(float e, float f);
89
90 float fdim(float e, float f);
91 float fmax(float e, float f);
92 float fmin(float e, float f);
93 float fma(float e, float f, float g);
94
95 int isgreater(float e, float f);
96 int isgreaterequal(float e, float f);
97 int isless(float e, float f);
98 int islessequal(float e, float f);
99 int islessgreater(float e, float f);
100 int isunordered(float e, float f);
101
102 const float M_E        = 2.7182818284590452354;   /* e */
103 const float M_LOG2E    = 1.4426950408889634074;   /* log_2 e */
104 const float M_LOG10E   = 0.43429448190325182765;  /* log_10 e */
105 const float M_LN2      = 0.69314718055994530942;  /* log_e 2 */
106 const float M_LN10     = 2.30258509299404568402;  /* log_e 10 */
107 // -Wdouble-declaration
108 #define M_PI             3.14159265358979323846   /* pi */
109 const float M_PI_2     = 1.57079632679489661923;  /* pi/2 */
110 const float M_PI_4     = 0.78539816339744830962;  /* pi/4 */
111 const float M_1_PI     = 0.31830988618379067154;  /* 1/pi */
112 const float M_2_PI     = 0.63661977236758134308;  /* 2/pi */
113 const float M_2_SQRTPI = 1.12837916709551257390;  /* 2/sqrt(pi) */
114 const float M_SQRT2    = 1.41421356237309504880;  /* sqrt(2) */
115 const float M_SQRT1_2  = 0.70710678118654752440;  /* 1/sqrt(2) */