cf_safe_norm¶
Category: math
GitHub: cute_math.h
Returns a normalized vector.
CF_V2 cf_safe_norm(CF_V2 a) { float sq = cf_dot(a, a); return sq != 0.0f ? cf_div(a, CF_SQRTF(sq)) : cf_v2(0, 0); }
Remarks¶
Sets the vector to { 0, 0 } if the length of the vector is zero. Unlike cf_norm, this function cannot fail for
the case of a zero vector.