+#include "mathlib.qh"
#if defined(CSQC)
#include "../dpdefs/csprogsdefs.qh"
- #include "mathlib.qh"
#elif defined(MENUQC)
#elif defined(SVQC)
- #include "../dpdefs/progsdefs.qh"
#include "../dpdefs/dpextensions.qh"
- #include "mathlib.qh"
+ #include "../dpdefs/progsdefs.qh"
#endif
int fpclassify(float x)
return exp(v.x) * v.y;
}
+/**
+ * Pythonic mod:
+ * TODO: %% operator?
+ *
+ * 1 % 2 == 1
+ * -1 % 2 == 1
+ * 1 % -2 == -1
+ * -1 % -2 == -1
+ */
+float pymod(float x, float y)
+{
+ return x - y * floor(x / y);
+}
+
float nearbyint(float x)
{
return rint(x);
{
return !(x < y || x == y || x > y);
}
+
+vector cross(vector a, vector b)
+{
+ return
+ '1 0 0' * (a.y * b.z - a.z * b.y)
+ + '0 1 0' * (a.z * b.x - a.x * b.z)
+ + '0 0 1' * (a.x * b.y - a.y * b.x);
+}