Computer Graphics Stack Exchange is a question and answer site for computer graphics researchers and programmers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am quite confused over how GLM library is behaving or I am using it improperly.

glm::vec2 testVec(6,-4);

float len = testVec.length();

I get the value 2 with the above code snippet. I believe I am trying to get the length of the vector defined by testVec. You know very well that it is not the correct length of the vector. What am I missing here?

share|improve this question

Sorry folks for posting such a trivial issue! The issue is solved. I was using the wrong function. Here goes the correct one:

glm::vec2 testVec(6,-4);
float len  = glm::length(testVec);

The member function of the same name returns the number of components instead (i.e. vec2::length will always yield 2, vec3::length will always yield 3, etc.).

share|improve this answer
3  
Don't apologise, I think it's a fair question, seeing that GLM's function naming is quite misleading here. I expect this could be a useful (and concise) reference in the future. – Martin Ender Mar 1 at 9:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.