Add is_null_vector() function

This commit is contained in:
hasufell 2014-05-13 20:09:32 +02:00
parent e4bad92195
commit 33408e5e46
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
2 changed files with 22 additions and 0 deletions

View File

@ -184,3 +184,24 @@ bool set_null_vector(vector *a)
return true; return true;
} }
/**
* Check if vector a is a null vector,
* so all coordinates are 0.
*
* @param a vector
* @return true if vector is a null vector, false
* otherwise, -1 on failure
*/
int is_null_vector(vector *a)
{
if (!a)
return -1;
if (a->x == 0 &&
a->y == 0 &&
a->z == 0)
return true;
else
return false;
}

View File

@ -123,6 +123,7 @@ bool sub_vectors(vector *a, vector *b, vector *c);
bool normalize_vector(vector *a, vector *b); bool normalize_vector(vector *a, vector *b);
bool copy_vector(vector *a, vector *b); bool copy_vector(vector *a, vector *b);
bool set_null_vector(vector *a); bool set_null_vector(vector *a);
int is_null_vector(vector *a);
#endif /* _DROW_ENGINE_VEC_MATH_H */ #endif /* _DROW_ENGINE_VEC_MATH_H */