@@ -1836,6 +1836,7 @@ def test_shared_axes_retick():
1836
1836
assert ax2 .get_zlim () == (- 0.5 , 2.5 )
1837
1837
1838
1838
1839
+ < << << << HEAD
1839
1840
def test_quaternion ():
1840
1841
# 1:
1841
1842
q1 = Quaternion (1 , [0 , 0 , 0 ])
@@ -1941,22 +1942,42 @@ def test_rotate():
1941
1942
[30 , 0 , 0.5 , - 60 , - 90 , 90 ],
1942
1943
[0 , 0.5 , 0.5 , - 45 , - 90 , 45 ],
1943
1944
[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
+ > >> >> >> 042e1 bb7f9 (Backport PR #28261: Correct roll angle units, issue #28256)
1944
1950
fig = plt .figure ()
1945
1951
ax = fig .add_subplot (1 , 1 , 1 , projection = '3d' )
1946
1952
ax .view_init (0 , 0 , roll )
1947
1953
ax .figure .canvas .draw ()
1948
1954
1955
+ << < << << HEAD
1949
1956
# drag mouse to change orientation
1957
+ == == == =
1958
+ # drag mouse horizontally to change azimuth
1959
+ dx = 0.1
1960
+ dy = 0.2
1961
+ >> >> >> > 042e1 bb7f9 (Backport PR #28261: Correct roll angle units, issue #28256)
1950
1962
ax ._button_press (
1951
1963
mock_event (ax , button = MouseButton .LEFT , xdata = 0 , ydata = 0 ))
1952
1964
ax ._on_move (
1953
1965
mock_event (ax , button = MouseButton .LEFT ,
1954
1966
xdata = dx * ax ._pseudo_w , ydata = dy * ax ._pseudo_h ))
1955
1967
ax .figure .canvas .draw ()
1968
+ << < << << HEAD
1956
1969
1957
1970
assert np .isclose (ax .elev , new_elev )
1958
1971
assert np .isclose (ax .azim , new_azim )
1959
1972
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
+ >> > >> >> 042e1 bb7f9 (Backport PR #28261: Correct roll angle units, issue #28256)
1960
1981
1961
1982
1962
1983
def test_pan ():
0 commit comments