mpl_toolkits.mplot3d.axes3d.Axes3D.view_init
provides a means to set the elevation and the azimuth, but the z-axis is always aligned with the vertical camera axis.
A third angle would be required to permit any view.
The issue was reported on stackoverflow 3.5 years ago.
Now, however hard you try to rotate the plot interactively or what angles you set in ax.view_init(), you will never be able to get the z-axis in a horizontalish position that is required to produce the plot below:
Expected outcome
By rotating interactively or via ax.view_init() one should be able to obtain this view below. Unfortunately, this is not possible.
my searching of how this could work ends here. I would kindly ask the community to implement this third angle to complete the 3D plotting in this case.
Implementing this would likely require recoding a few things that relied on
implicit assumptions baked into mplot3d such as the code that figures out
where to draw the axes labels so that it is always the exterior boundary
and connected to the others (which also controls the placement of offsets),
and the 2D -> 3D estimate calculation (used for the cursor display). There
are probably a few others, but they aren't coming to mind right now. Not
saying it is impossible, but it would be a bit of an undertaking.
Another aspect of this that would need to be addressed is that mplot3d's
interactivity is currently designed around two degrees of freedom, which
are handled by dragging the mouse in the X and Y directions. Another action
would be needed to introduce control for this proposed third degree of
freedom.
On Wed, Mar 10, 2021 at 2:48 AM SReich-EMI ***@***.***> wrote:
my searching of how this could work ends here. I would kindly ask the
community to implement this third angle to complete the 3D plotting in this
case.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#14453 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6AG5WIZZQJTKTVVWGLTC4P5TANCNFSM4HTTQWOA>
.
This is something I've been frustrated with pretty much every single time I need to plot something in 3D, and I'm going to take a stab at it this weekend and see how far I can get.
The missing piece is that azimuth, elevation, and radius uniquely define a viewpoint in 3D space, but you need an additional angle defining the rotation about the radius vector in order to fully capture the entire space of view orientations. If we add this 3rd angle with a default value of 0 deg, it should not break any old code.
As to naming this additional angle, I think roll is the obvious choice. It aligns with both the aerospace pith/yaw/roll convention, as well as the camera angle pan/tilt/roll convention. On the other hand I have seen tilt, twist, lean, and bank used for this angle, so if someone has a strong opinion or a source for the canonical term used in computer graphics I'm open to that. We will be jumping ahead of matlab features a bit, so if they decide to add this in the future and choose a different name there is the risk of divergence.
Really this should be done using quaternions - Euler angles are pretty much always bad. But since quaternions aren't natively in numpy we probably don't want to introduce those as a dependency just to avoid gimbal lock at the two poles.
With the restricted two angles, the final view direction does not depend on the execution order of the two rotations.
With three angles, you have to find a reasonable execution order and document that.
When interactively navigating in the view window we currently map the two screeen directions horizontal/vertical to azimuth/elevation. AFAICS there is no simple way of controlling the third dimension interactively (though one might look at 3d programs how they solve this)
Activity
SReich-EMI commented on Mar 10, 2021
my searching of how this could work ends here. I would kindly ask the community to implement this third angle to complete the 3D plotting in this case.
WeatherGod commented on Mar 10, 2021
scottshambaugh commented on Oct 21, 2021
This is something I've been frustrated with pretty much every single time I need to plot something in 3D, and I'm going to take a stab at it this weekend and see how far I can get.
The missing piece is that azimuth, elevation, and radius uniquely define a viewpoint in 3D space, but you need an additional angle defining the rotation about the radius vector in order to fully capture the entire space of view orientations. If we add this 3rd angle with a default value of 0 deg, it should not break any old code.
As to naming this additional angle, I think roll is the obvious choice. It aligns with both the aerospace pith/yaw/roll convention, as well as the camera angle pan/tilt/roll convention. On the other hand I have seen tilt, twist, lean, and bank used for this angle, so if someone has a strong opinion or a source for the canonical term used in computer graphics I'm open to that. We will be jumping ahead of matlab features a bit, so if they decide to add this in the future and choose a different name there is the risk of divergence.
Really this should be done using quaternions - Euler angles are pretty much always bad. But since quaternions aren't natively in numpy we probably don't want to introduce those as a dependency just to avoid gimbal lock at the two poles.
scottshambaugh commented on Oct 21, 2021
This looks like a relevant PR to keep in mind when reworking this: #10762
timhoffm commented on Oct 21, 2021
There are two aspects to consider:
With three angles, you have to find a reasonable execution order and document that.
scottshambaugh commented on Oct 22, 2021
Finished my PR, it's ready for review.
baloe commented on Dec 3, 2021
This is brilliant, thank you so much @scottshambaugh !
baloe commented on Dec 3, 2021
I updated my answer in the SO thread: https://stackoverflow.com/a/56457693/7042795
SReich-EMI commented on Dec 6, 2021
Thanks a lot for your work! I will surely test it in the next days!