Add is_null_vector() function
This commit is contained in:
parent
e4bad92195
commit
33408e5e46
21
src/vector.c
21
src/vector.c
@ -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;
|
||||||
|
}
|
||||||
|
@ -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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user