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