Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Switch to a 3d rotation trackball implementation with path independence #29244

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

Closed

Conversation

scottshambaugh
Copy link
Contributor

@scottshambaugh scottshambaugh commented Dec 6, 2024

PR summary

Different 3D rotation methods were added in #28841, with different tradeoffs to each. In that PR I was adamant that the matplotlib default method should have the property of "path independence", which is valuable since it allows users to "undo" errant rotations by returning their mouse to the original point on the screen.

Since then, I did a deep dive and writeup on different virtual trackball control methods (https://theshamblog.com/virtual-trackballs-a-taxonomy-and-new-method/), and learned that it's possible to implement the "trackball" control method in a way that preserves the path independence property, and IMO is a strict improvement on the original implementation. This PR switches to that implementation, and cleans up a little bit of the docs.

@MischaMegens2 pinging you for review! During the original PR you favored "trackball" as the default method, which I pushed back on because of the lack of path independence. I'm open to switching it over to that now if you'd prefer it!

We might be able to squeeze a change to the default into 3.10 with a quick review, I think it would be harder to switch over in 3.10.1 since it's changing behavior. But to other devs, I don't want this to block a timely 3.10 release.

PR checklist

@scottshambaugh scottshambaugh added this to the v3.10.0 milestone Dec 6, 2024
@github-actions github-actions bot added the Documentation: API files in lib/ and doc/api label Dec 6, 2024
@MischaMegens2
Copy link
Contributor

@timhoffm:
The PR #29244 proposes a trick to fix a perceived deficiency of the trackball mouse rotation style: the dependence of the orientation on the details of path the mouse took, even when the start and end of the mouse motion were identical.

The proposed PR might seem to fix the 'path dependence', but unfortunately, it is only a superficial fix - it has unintended consequences: if you would momentarily released the mouse button during a mouse drag, then the outcome in general will be different - even when the path taken was exactly the same.
None of the other methods suffer from this. For all the other styles, the rotation is purely incremental. (The particular location of the 'touch down' is not relevant later on, only the mouse motion is.)
Thus the proposed 'improvement' comes at a price, and the cure may be worse than the disease.

Moreover:

  • The proposed modified trackball style no longer has a straightforward physical interpretation, like the original trackball style, in terms of a ball covered by a plate that you drag with the mouse; this is a loss.
  • The documentation (even though it would be updated) still suggests that it does, erroneously.

The proposed modified mouse rotation style is altogether different from the trackball style, arguably it is closer to the azel style in spirit.
Hence it should not supplant the trackball style; it could be an additional style, at best.

The proposed new style drags along twice as much 'state': not only the quaternion q for the current orientation (like all the other mouse rotation styles), but also _q0, for the orientation when the mouse button was initially depressed.
Not pretty.
Worse, the implementation is brittle: if you'd switch to the new 'trackball' mouse rotation style while the mouse button is already depressed, then when you move the mouse pointer, the on_mouse_move() call will error out since _q0 is not defined...

To be honest, I do not quite understand the preoccupation with the 'path-dependence'. It is a natural consequence of the plate-on-a-ball arrangement of the trackball mouse rotation style; and the path-dependence is actually useful there, since it provides a way to conveniently adjust roll (by moving the mouse in circles), which is needed for this style, since, unlike the arcball, it does not have special a provision for it. That is to say, the path-dependence is a feature, not a bug, for the trackball.
(The proposed changes to the documentation removes this hint, also not an improvement...)
With the PR, it becomes impossible to adjust the roll in one mouse drag. Not good.

In summary:

  • I don't think this PR is a good idea, let alone ready for 3.10;
  • I would certainly not advise it for the default style - it makes it hard to control roll.

@scottshambaugh
Copy link
Contributor Author

scottshambaugh commented Dec 10, 2024

I think we disagree on which properties are features vs bugs, and the remaining objections can be fixed with docs tweaks. But if there's not clear agreement then I'll close this PR and we can wait for user feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: API files in lib/ and doc/api topic: mplot3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants