-
Notifications
You must be signed in to change notification settings - Fork 155
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 Transform::{look_at_rh, look_at_lh} and deprecate look_at (continued) #514
base: master
Are you sure you want to change the base?
Conversation
|
||
/// Create a transformation matrix that will cause `unit_x()` to point at | ||
/// `dir`. `unit_y()` will be perpendicular to `dir`, and the closest to `up`. | ||
pub fn look_to(dir: Vector2<S>, up: Vector2<S>) -> Matrix2<S> { |
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 look_to_{lh|rh}
. I didn't update these because I didn't know what the current implementation was.
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.
Is there a handedness distinction for 2D rotations?
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 that there is because handedness defines the direction of rotation. However, I had the same (unresolved) question which is why I decided not to modify it in the other PR. My reasoning was that it's probably better to leave it alone until I (or someone else) has time to figure out the correct path forward.
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'm confused. I thought handedness determines between coordinate systems. The direction of rotation should be indistinguishable here. I.e. the rotation is the same regardless of which way you turn. For 2D rotations, setting an upside-down up vector should cause the coordinate system to flip, which, I think does the equivalent of what the 3D handedness does. I.e. it flips the sign of the output matrix determinant. Maybe I'm missing something here? It seems like we can either do handedness here without the up
vector or leave it as is.
@@ -474,7 +474,7 @@ impl<S: BaseFloat> From<Quaternion<S>> for Basis3<S> { | |||
|
|||
impl<S: BaseFloat> Rotation<Point3<S>> for Quaternion<S> { | |||
#[inline] | |||
fn look_at(dir: Vector3<S>, up: Vector3<S>) -> Quaternion<S> { |
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.
There should be {lh|rh}
variants. I wasn't sure about the consistency of the existing implementations.
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 was hoping to consolidate the look functions in Transform
and Rotation
in a separate PR since it is more involved. This looks like it is at least has consistent naming. What do you think?
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 guess my thinking is that it needs the handedness for it to be consistent and I don't think the implementations are consistent right now (i.e. they're not all LH or all RH and some of the implementations are on the raw structs instead of the traits).
What I think needs to happen is that someone needs to go through the remaining look_
function and determine if it's currently lh
or rh
and deprecate it in favor of an explicitly named version of that function. While checking these, the corresponding missing lh
or rh
version can also be added. I think you've done this for Matrix3
, but the other ones are missing the handedness suffix. I skipped over the ones I wasn't sure of rather than just renaming them to look_to
(without the suffix) because they'll just need to be renamed again.
I was also thinking that it doesn't really make sense to have look_at_
variants for structures that can only represent rotation. I think these should only have look_to_
functions. We should probably sort out these kinds of questions before considering the removal of Rotation
.
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 should probably sort out these kinds of questions before considering the removal of Rotation.
Agreed, so shall we punt that to another PR?
For this PR I am happy with having the look_at vs look_to consistency throughout cgmath.
Could somebody sum up the status of this PR? Is there a consensus, and what's left to do? |
IIRC this PR aims to get consistent naming for It does this to a certain extent without committing to major changes to the The other point to resolve is whether Matrix2 needs #508 leaves the |
Corresponding functions have been added to Matrix4 and Decomposed and are now consistent. Matrix3, Matrix2, and the Rotation trait are only partially updated.
This makes the Matrix3/4 and Decomposed `look_at_*` functions consistent with looking at a center/focus point and `look_to_*` functions consistent with looking in a direction.
Rename functions look_at* to look_to* on Matrix2 and related rotation transforms.
Remove a repated instance of Matrix4 look_at transform.
Previously look_at functions were erroneously renamed to look_to_{lh|rh} as a response to deprecation warnings. Instead what should've happened is that `allow(deprecated)` annotations are fixed to suppress tests that verify that deprecated functions are working. This commit reintroduced the tests for deprecated functions and suppresses the deprecation warnings.
This change clarifies the meaning of the _lh and _rh suffixes.
I believe the current implementation of |
This is a continuation of #508 with the following additions:
_lh
and_rh
suffixes are explained in each affected function.look_at
is renamed tolook_to
on Matrix2 and 2D rotations for consistency.look_at
were changed tolook_to
as necessary in theRotation
trait.These changes make
look_at
andlook_to
functions consistent in meaning throughout the crate (with exception of deprecated functions).