MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / as_cardan_angles

Method as_cardan_angles

lib/mpl_toolkits/mplot3d/axes3d.py:4424–4435  ·  view source on GitHub ↗

The inverse of `from_cardan_angles()`. Note that the angles returned are in radians, not degrees. The angles are not sensitive to the quaternion's norm().

(self)

Source from the content-addressed store, hash-verified

4422 return cls(qw, [qx, qy, qz])
4423
4424 def as_cardan_angles(self):
4425 """
4426 The inverse of `from_cardan_angles()`.
4427 Note that the angles returned are in radians, not degrees.
4428 The angles are not sensitive to the quaternion's norm().
4429 """
4430 qw = self.scalar
4431 qx, qy, qz = self.vector[..., :]
4432 azim = np.arctan2(2*(-qw*qz+qx*qy), qw*qw+qx*qx-qy*qy-qz*qz)
4433 elev = np.arcsin(np.clip(2*(qw*qy+qz*qx)/(qw*qw+qx*qx+qy*qy+qz*qz), -1, 1))
4434 roll = np.arctan2(2*(qw*qx-qy*qz), qw*qw-qx*qx-qy*qy+qz*qz)
4435 return elev, azim, roll

Callers 2

_on_moveMethod · 0.80
test_quaternionFunction · 0.80

Calls 1

clipMethod · 0.45

Tested by 1

test_quaternionFunction · 0.64