mathlib: add AddPointToBounds, ClearBounds

This commit is contained in:
Eric Wasylishen 2017-07-22 13:19:06 -06:00
parent 0ebbdac5f9
commit 5893c16267
2 changed files with 23 additions and 0 deletions

View File

@ -102,6 +102,26 @@ VecStrf(const vec3_t vec)
return buf;
}
void ClearBounds(vec3_t mins, vec3_t maxs)
{
for (int i=0; i<3; i++) {
mins[i] = VECT_MAX;
maxs[i] = -VECT_MAX;
}
}
void AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs)
{
for (int i=0; i<3; i++) {
const vec_t val = v[i];
if (val < mins[i])
mins[i] = val;
if (val > maxs[i])
maxs[i] = val;
}
}
// from http://mathworld.wolfram.com/SpherePointPicking.html
// eqns 6,7,8
void

View File

@ -142,6 +142,9 @@ VectorCopyFromGLM(const qvec3f &in, vec3_t out)
out[2] = in[2];
}
void ClearBounds(vec3_t mins, vec3_t maxs);
void AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs);
static inline qvec3f
VectorToGLM(const vec3_t in)
{