Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glm::length(glm::vec) and glm::vec::length

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Dec 2012
    Posts
    1

    glm::length(glm::vec) and glm::vec::length

    glm::length(v) gives the length of v and v.length() gives the dimension of v.

    I feel like this is a accident waiting to happen.

    Also, there doesn't seem to be a length squared function as far as I can tell. I added my own because I got tired of writing dot(v, v), but I feel like this is an extremely common function and should be added.

  2. #2
    Super Moderator Frequent Contributor Groovounet's Avatar
    Join Date
    Jul 2004
    Posts
    934
    Quote Originally Posted by raymondp View Post
    glm::length(v) gives the length of v and v.length() gives the dimension of v.

    I feel like this is a accident waiting to happen.

    Also, there doesn't seem to be a length squared function as far as I can tell. I added my own because I got tired of writing dot(v, v), but I feel like this is an extremely common function and should be added.
    That might be unfortunate but the GLSL specifications define both. As GLM is trying its best to follow GLSL specification, the library is following this convention as well.

    If you include <glm/gtx/norm.hpp> you will be able to use glm::length2 to compute your squared lengths.

    Thanks,
    Christophe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •