Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to vector types that returns direction and length #291

Open
bitshifter opened this issue May 30, 2022 · 3 comments
Open

Add method to vector types that returns direction and length #291

bitshifter opened this issue May 30, 2022 · 3 comments
Labels
1.0 Issues to be fixed before 1.0 stable release

Comments

@bitshifter
Copy link
Owner

It's not uncommon to find the direction and length of a vector, but it is a hassle to do it manually. It would be good to have a method for this.

@paul-hansen
Copy link

Just poking through the open issues and seeing if there is anything I can help with.

Looks like length is already done: https://docs.rs/glam/0.21.3/glam/?search=length
Direction would probably just be normalize which is already done too: https://docs.rs/glam/0.21.3/glam/?search=normalize Unless you meant something else.

Anything else needed/missing here?

We could probably add a doc alias for normalize or something if we wanted to make normalize show up when you search for "direction"

@janhohenheim
Copy link

Late to the party, but I found this issue while looking whether there was something convenient to get both the direction and length of a vector, since normalizing it indirectly involves calculating the length. Something like the following:

let (norm, len) = some_vec.normalize_and_length();

@bitshifter
Copy link
Owner Author

yes, that's what I was meaning. I think I managed to completely miss paul-hansen's comment from 2 years ago, whoops!

@bitshifter bitshifter added the 1.0 Issues to be fixed before 1.0 stable release label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 Issues to be fixed before 1.0 stable release
Projects
None yet
Development

No branches or pull requests

3 participants