vec3 and vec4 sign helper

This commit is contained in:
Recep Aslantas
2018-04-07 21:53:22 +03:00
parent 257c57d41f
commit 12c5307447
2 changed files with 45 additions and 1 deletions

View File

@@ -26,6 +26,7 @@
#define cglm_vec3_ext_h
#include "common.h"
#include "util.h"
#include <stdbool.h>
#include <math.h>
#include <float.h>
@@ -196,4 +197,19 @@ glm_vec_isvalid(vec3 v) {
return !glm_vec_isnan(v) && !glm_vec_isinf(v);
}
/*!
* @brief get sign of 32 bit float as +1, -1, 0
*
* Important: It returns 0 for zero/NaN input
*
* @param v vector
*/
CGLM_INLINE
void
glm_vec_sign(vec3 v, vec3 dest) {
dest[0] = glm_signf(v[0]);
dest[1] = glm_signf(v[1]);
dest[2] = glm_signf(v[2]);
}
#endif /* cglm_vec3_ext_h */