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
Summary
Part of PR#21426 'Add ability to roll the camera in 3D plots' (by Scott Shambaugh, 3 years ago) read as follows:- Make elev, azim, roll ordering consistent everywhere
However, the choice of ordering is rather unfortunate:
- It is not the common one (most everyone else in the world uses azim-elev-roll, see below)
- It does not correspond to the order in which the 3 rotations take place (that's azim-elev-roll)
- It is not consistent with the ordering in matplotlib's
colors.py
.
I.e., there is room for improvement.
When I google:
"azimuth, elevation"
-> 291 000 results"elevation, azimuth"
-> 41 500 results
That is to say, theelevation, azimuth
ordering is not the common one. And if we consider that searchingfor both yields:
"azimuth, elevation" and "elevation, azimuth"
-> 37 500 results (some links are non-committal),
then it becomes clear that theelevation, azimuth
ordering is really a minority position: (41-37)/(291-37) < 2%.
(Also, for what it's worth: MATLAB happens to use"azimuth, elevation"
, just like (almost) everyone else.)
The ordering with elevation first does not correspond to the order in which the 3 rotations take place:
if thinking about intrinsic rotations, then the rotation order is azim, elev, then roll.
The corresponding quaternion is q = exp((+roll/2)*e_x)*exp((+elev/2)*e_y)*exp((-azim/2)*e_z)
i.e., to be precise, mplot3d'sazim, elev, roll
are a kind of Tait-Bryan angles, -z,y',x".
It is a bit of a mess with the Euler angles, apparently there are 24 variations (not counting the signs) -https://github.com/moble/quaternion/wiki/Euler-angles-are-horrible
Proposed fix
Switch (back) to the common ordering, the order in which the rotations are performed:azim, elev, roll
.
Fortunately, Scott had the good foresight to use named parameters, so it is not a completely breaking change.
We can make the use of named parameters forazim
andelev
mandatory (preceding with a '*' argument), so changing the order (when parameters are unnamed) won't result in any silent failures.
Scott voiced a hesitation to change it (again), and I can understand his initial reaction. However, it seems to me that changing the order has clear benefits, and arguably it could be worth the effort of adapting existing code, as perhttps://matplotlib.org/devdocs/devel/api_changes.html (especially in view of the fact that the effort might be limited, with the named parameters).
I have a PR almost ready to show what the changes would be.