Add perp method to Dir2 - #25422
Merged
Merged
Conversation
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
Zeophlite
approved these changes
Aug 15, 2026
Contributor
|
Any reason not to call it |
Jengamon
reviewed
Aug 16, 2026
Contributor
There was a problem hiding this comment.
I agree with @JMS55 about naming the method perpendicular, with 2 main points:
- this keeps code like the one changed in
bevy_gizmosworking without change - it follows the general pattern I notice elsewhere in
bevy_mathwhere operations tend to be spelled-out
Contributor
Author
|
I agree with perpendicular() method if complete names are common practice |
Co-authored-by: Uche Okwo <bob.hostern@gmail.com>
Contributor
|
The one vantage of calling it |
hukasu
approved these changes
Aug 16, 2026
Contributor
Author
|
I am happy to change it back to perp if the core maintainers prefer that behavior, but I will leave it as perpendicular() for now based on the previous feedback. |
HugoPeters1024
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25418
This PR adds a
perpmethod toDir2inline with howglamimplements it forVec2. It utilizesSelf::new_uncheckedsince rotating a normalized 2D unit vector by 90 degrees inherently preserves its unit length.Unit tests have been added to verify correct rotation and length preservation.