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)
| 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 |