8000 Add np.clip() to avoid floating point round-off errors · matplotlib/matplotlib@eaa51a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit eaa51a4

Browse files
committed
Add np.clip() to avoid floating point round-off errors
With proper parentheses
1 parent 6b15663 commit eaa51a4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4053,6 +4053,6 @@ def as_cardan_angles(self):
40534053
qw = self.scalar
40544054
qx, qy, qz = self.vector[..., :]
40554055
azim = np.arctan2(2*(-qw*qz+qx*qy), qw*qw+qx*qx-qy*qy-qz*qz)
4056-
elev = np.arcsin(np.clip(2*(qw*qy+qz*qx)/(qw*qw+qx*qx+qy*qy+qz*qz)), -1, 1)
4056+
elev = np.arcsin(np.clip(2*(qw*qy+qz*qx)/(qw*qw+qx*qx+qy*qy+qz*qz), -1, 1))
40574057
roll = np.arctan2(2*(qw*qx-qy*qz), qw*qw-qx*qx-qy*qy+qz*qz)
40584058
return elev, azim, roll

0 commit comments

Comments
 (0)
0