I'm new to using the GLM library, but it appears it does not have a magnitude function. Is this correct? If so, what is the reasoning?
Asked
Active
Viewed 2.1k times
16
-
10If you just need to compare magnitudes, you may want to use `glm::length2()` from the `gtx/norm.hpp` extension, as it avoids the expensive `sqrt`. It is essentially equivalent to `glm::dot(v,v)`. – bcrist Nov 08 '13 at 21:14
1 Answers
26
genType::value_type glm::length( genType const & x )
Returns the length of x, i.e., sqrt(x * x).
And as @bcrist pointed out, glm::length2
from GLM_GTX_norm
:
T glm::length2( vecType< T, P > const& x )
Returns the squared length of x.