]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mathlib.h
added invpow (arbitrary logarithm, finds a power that the base number would need...
[xonotic/darkplaces.git] / mathlib.h
index d99a2d41b80e09299ae0191353afc9578ffb54e4..002c3f132b5e9eda844144250d40ffeff2037f30 100644 (file)
--- a/mathlib.h
+++ b/mathlib.h
@@ -51,6 +51,8 @@ extern vec3_t vec3_origin;
 
 #define lhrandom(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN))
 
+#define invpow(base,number) (log(number) / log(base))
+
 #define DEG2RAD(a) ((a) * ((float) M_PI / 180.0f))
 #define RAD2DEG(a) ((a) * (180.0f / (float) M_PI))
 #define ANGLEMOD(a) (((int) ((a) * (65536.0f / 360.0f)) & 65535) * (360.0f / 65536.0f))
@@ -90,6 +92,7 @@ extern vec3_t vec3_origin;
 }
 #define VectorRandom(v) do{(v)[0] = lhrandom(-1, 1);(v)[1] = lhrandom(-1, 1);(v)[2] = lhrandom(-1, 1);}while(DotProduct(v, v) > 1)
 #define VectorBlend(b1, b2, blend, c) do{float iblend = 1 - (blend);VectorMAM(iblend, b1, blend, b2, c);}while(0)
+#define BoxesOverlap(a,b,c,d) ((a)[0] <= (d)[0] && (b)[0] >= (c)[0] && (a)[1] <= (d)[1] && (b)[1] >= (c)[1] && (a)[2] <= (d)[2] && (b)[2] >= (c)[2])
 
 /*
 // LordHavoc: quaternion math, untested, don't know if these are correct,
@@ -182,6 +185,9 @@ tinydoubleplane_t;
 
 void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees);
 
+float RadiusFromBounds (const vec3_t mins, const vec3_t maxs);
+float RadiusFromBoundsAndOrigin (const vec3_t mins, const vec3_t maxs, const vec3_t origin);
+
 // print a matrix to the console
 struct matrix4x4_s;
 void Matrix4x4_Print(const struct matrix4x4_s *in);