16

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?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Darkenor
  • 4,349
  • 8
  • 40
  • 67
  • 10
    If 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 Answers1

26

glm::length():

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.

Community
  • 1
  • 1
genpfault
  • 51,148
  • 11
  • 85
  • 139