Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb58073

Browse files
oscargusLorenzoPeri17
authored andcommitted
Backport PR #28261: Correct roll angle units, issue #28256
1 parent 0a6b5ff commit cb58073

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,7 @@ def test_shared_axes_retick():
18361836
assert ax2.get_zlim() == (-0.5, 2.5)
18371837

18381838

1839+
<<<<<<< HEAD
18391840
def test_quaternion():
18401841
# 1:
18411842
q1 = Quaternion(1, [0, 0, 0])
@@ -1941,22 +1942,42 @@ def test_rotate():
19411942
[30, 0, 0.5, -60, -90, 90],
19421943
[0, 0.5, 0.5, -45, -90, 45],
19431944
[30, 0.5, 0.5, -15, -90, 45]]:
1945+
=======
1946+
def test_rotate():
1947+
"""Test rotating using the left mouse button."""
1948+
for roll in [0, 30]:
1949+
>>>>>>> 042e1bb7f9 (Backport PR #28261: Correct roll angle units, issue #28256)
19441950
fig = plt.figure()
19451951
ax = fig.add_subplot(1, 1, 1, projection='3d')
19461952
ax.view_init(0, 0, roll)
19471953
ax.figure.canvas.draw()
19481954

1955+
<<<<<<< HEAD
19491956
# drag mouse to change orientation
1957+
=======
1958+
# drag mouse horizontally to change azimuth
1959+
dx = 0.1
1960+
dy = 0.2
1961+
>>>>>>> 042e1bb7f9 (Backport PR #28261: Correct roll angle units, issue #28256)
19501962
ax._button_press(
19511963
mock_event(ax, button=MouseButton.LEFT, xdata=0, ydata=0))
19521964
ax._on_move(
19531965
mock_event(ax, button=MouseButton.LEFT,
19541966
xdata=dx*ax._pseudo_w, ydata=dy*ax._pseudo_h))
19551967
ax.figure.canvas.draw()
1968+
<<<<<<< HEAD
19561969

19571970
assert np.isclose(ax.elev, new_elev)
19581971
assert np.isclose(ax.azim, new_azim)
19591972
assert np.isclose(ax.roll, new_roll)
1973+
=======
1974+
roll_radians = np.deg2rad(ax.roll)
1975+
cs = np.cos(roll_radians)
1976+
sn = np.sin(roll_radians)
1977+
assert ax.elev == (-dy*180*cs + dx*180*sn)
1978+
assert ax.azim == (-dy*180*sn - dx*180*cs)
1979+
assert ax.roll == roll
1980+
>>>>>>> 042e1bb7f9 (Backport PR #28261: Correct roll angle units, issue #28256)
19601981

19611982

19621983
def test_pan():

0 commit comments

Comments
 (0)