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.
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
return Direction3d from Transform::up and friends #11604
return Direction3d from Transform::up and friends #11604
Changes from 1 commit
4c9ac33
baa4f46
a6a6bb8
f23ebd7
e63c897
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be implemented for the
Direction2d
&Vec2
pair.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be implemented for
Direction2d
as well for consistency. It should probably also be implemented the other way around, i.e.impl Mul<Direction3d> for f32
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should probably use
new_unchecked
to avoid the normalization. It'd be useful to implementMul<Quat>
for the direction types though; with that, this would just be:Of course, it would have to be guaranteed that rotation doesn't change the length. I think it should work, but I haven't tried with degenerate quaternions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (rotate direction with multiplication) would also only work for 3D directions until we have a
Rotation2d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough maths to confidently use new_unchecked (or to say that the unwrap will never be hit), so I'd appreciate if someone smarter than me could help here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should merge this with the checked version for now, and look into accelerating this (with tests) in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to avoid the deref here would be to simply implement
Add<Direction3d>
forVec3
. That can be done in a follow-up thoughThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would find this a little odd, from an API perspective. If we include direction in the vector algebra we might as well just call it
UnitVector
. Multiplying a direction by a scalar to get a vector makes sense. Adding a direction to a vector... that's just weird to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we impl
Mul<Direction3d> for f32
or switch around the operand order, these derefs shouldn't be needed either.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could technically make
looking_at
take animpl Into<Vec3>
to remove the need for deref here, but it's probably follow-up material (and also pretty niche probably)