Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 343b3dc commit e497c77Copy full SHA for e497c77
lib/mpl_toolkits/mplot3d/axes3d.py
@@ -4023,9 +4023,10 @@ def as_cardan_angles(self):
4023
The inverse of `from_cardan_angles()`.
4024
Note that the angles returned are in radians, not degrees.
4025
"""
4026
- qw = self.scalar
4027
- qx, qy, qz = self.vector[..., :]
+ n = np.sqrt(self.norm)
+ qw = self.scalar / n
4028
+ qx, qy, qz = self.vector[..., :] / n
4029
azim = np.arctan2(2*(-qw*qz+qx*qy), qw*qw+qx*qx-qy*qy-qz*qz)
- elev = np.arcsin( 2*( qw*qy+qz*qx)/(qw*qw+qx*qx+qy*qy+qz*qz)) # noqa E201
4030
+ elev = np.arcsin(np.clip(2*(qx*qz + qw*qy), -1, 1))
4031
roll = np.arctan2(2*( qw*qx-qy*qz), qw*qw-qx*qx-qy*qy+qz*qz) # noqa E201
4032
return elev, azim, roll
0 commit comments