diff --git a/src/vector.c b/src/vector.c index f33f2c8..ba8151a 100644 --- a/src/vector.c +++ b/src/vector.c @@ -184,3 +184,24 @@ bool set_null_vector(vector *a) 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; +} diff --git a/src/vector.h b/src/vector.h index 8ce955c..0fe21bb 100644 --- a/src/vector.h +++ b/src/vector.h @@ -123,6 +123,7 @@ bool sub_vectors(vector *a, vector *b, vector *c); bool normalize_vector(vector *a, vector *b); bool copy_vector(vector *a, vector *b); bool set_null_vector(vector *a); +int is_null_vector(vector *a); #endif /* _DROW_ENGINE_VEC_MATH_H */