improve getting angle between two vector

This commit is contained in:
Recep Aslantas
2017-01-24 16:39:57 +03:00
parent 9ac590bc12
commit 13a47ca598

View File

@@ -372,7 +372,11 @@ glm_vec4_normalize_to(vec4 vec, vec4 dest) {
CGLM_INLINE
float
glm_vec_angle(vec3 v1, vec3 v2) {
return acosf(glm_vec_dot(v1, v2) / glm_vec_norm(v1) * glm_vec_norm(v2));
float norm;
/* maybe compiler generate approximation instruction (rcp) */
norm = 1.0f / (glm_vec_norm(v1) * glm_vec_norm(v2));
return acosf(glm_vec_dot(v1, v2) * norm);
}
CGLM_INLINE