Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
In mplot3d, the plot currently reacts differently to dragging the mouse, depending on the orientation of the axes. In the default orientation, moving the mouse left/right or up/down tilts the plot left/right or up/down correspondingly, which is quite natural and intuitive. However, when the plot is rotated so that we are looking down the z-axis, then moving the mouse up/down does not tilt the plot up/down as expected, but rotates it around the z-axis. The situation reminds of gimball lock. It is clumsy and annoying.
Additionally, the 'roll' angle currently cannot be controlled with the mouse (issue#14451 and PR#21426 mention this) - at present, the two degrees of freedom of the mouse (left-right and up-down) correspond directly to two of the rotational degrees of freedom of the plot (azimuth and elevation), whereas there are in fact three (i.e., azimuth, elevation, and roll; or heading, tilt, and bank, if you will). Rotations around three cartesian axes do look essentially different (one can turn up/down, turn left/right, or twist left/right-handed). Controlling only two limits the accessible orientations.
Proposed solution
For a natural interaction with the mouse, it is desirable that the figure reacts in the same way to mouse movements, regardless of orientation: there should be no difference between "poles" and "equator" of the figure, and no 'gimbal lock'.
Of course this problem is not new - satisfying solutions have been devised in the nineties of the last century, e.g., Ken Shoemake's 'arcball' [1]. All that is needed to implement this inmplot3d
is a small change toaxes3d._onmove()
, together with a minimal quaternion class - this avoids an additional dependency on a large package likenumpy-quaternion
.
The quaternion class can be made internal, to hide it; or it can be exposed since it can be more generally useful.
- [Ken Shoemake, "ARCBALL: A user interface for specifying three-dimensional rotation using a mouse." in Proceedings of Graphics Interface '92, 1992, pp. 151-156,https://doi.org/10.20380/GI1992.18]