Skip to content

Alternative to len #70

Closed
Closed

Description

@mantielero

Sorry for this probably naive question. I was trying the following:

import vmath
var a = vec2(10.0,2.0)
echo a.len

This works if compiled with -d:vmathArrayBased, but how can I get the length of the vector when is not based in arrays?

Activity

  1. treeform commented on Oct 13, 2023

    @treeform
    Owner

    You can use the length() function to get the magnitude:
    https://registry.khronos.org/OpenGL-Refpages/gl4/html/length.xhtml

    Or do want to get how many dementions the vector has? In this case 2 because its a vec2?

  2. mantielero commented on Oct 14, 2023

    @mantielero
    Author

    Yes, I meant getting the vector dimension (2 for Vec2). I think it would make sense having an equivalent len for the cases where is not compiled with -d:vmathArrayBased.

  3. treeform commented on May 25, 2026

    @treeform
    Owner

    Thank you for this issue. I actually have a need for this feature, and so I added it here: #87

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions