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

Skip to content

Commit 039b975

Browse files
Revert parameters for view_transformation
1 parent 1cdc5aa commit 039b975

File tree

3 files changed

+86
-17
lines changed

3 files changed

+86
-17
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Axes3D(Axes):
5151
_axis_names = ("x", "y", "z")
5252
Axes._shared_axes["z"] = cbook.Grouper()
5353

54-
dist = _api.deprecate_privatize_attribute("3.7")
54+
dist = _api.deprecate_privatize_attribute("3.6")
5555
vvec = _api.deprecate_privatize_attribute("3.7")
5656
eye = _api.deprecate_privatize_attribute("3.7")
5757
sx = _api.deprecate_privatize_attribute("3.7")
@@ -160,6 +160,8 @@ def __init__(
160160
self.fmt_zdata = None
161161

162162
self.mouse_init()
163+
self.figure.canvas.callbacks._connect_picklable(
164+
'motion_notify_event', self._on_move)
163165
self.figure.canvas.callbacks._connect_picklable(
164166
'button_press_event', self._button_press)
165167
self.figure.canvas.callbacks._connect_picklable(
@@ -917,13 +919,13 @@ def get_proj(self):
917919
# Generate the view and projection transformation matrices
918920
if self._focal_length == np.inf:
919921
# Orthographic projection
920-
viewM = proj3d.view_transformation(u, v, w, eye)
922+
viewM = proj3d.view_transformation_uvw(u, v, w, eye)
921923
projM = proj3d.ortho_transformation(-self._dist, self._dist)
922924
else:
923925
# Perspective projection
924926
# Scale the eye dist to compensate for the focal length zoom effect
925927
eye_focal = R + self._dist * ps * self._focal_length
926-
viewM = proj3d.view_transformation(u, v, w, eye_focal)
928+
viewM = proj3d.view_transformation_uvw(u, v, w, eye_focal)
927929
projM = proj3d.persp_transformation(-self._dist,
928930
self._dist,
929931
self._focal_length)
@@ -1245,14 +1247,22 @@ def _set_view_from_bbox(self, bbox, direction='in',
12451247
def zoom_data_limits(self, scale_u, scale_v, scale_w):
12461248
"""
12471249
Zoom in or out of a 3D plot.
1248-
Will scale the data limits by the scale factors, where scale_u,
1249-
scale_v, and scale_w refer to the scale factors for the viewing axes.
1250-
These will be transformed to the x, y, z data axes based on the current
1251-
view angles. A scale factor > 1 zooms out and a scale factor < 1 zooms
1252-
in.
1250+
Will scale the data limits by the scale factors. These will be
1251+
transformed to the x, y, z data axes based on the current view angles.
1252+
A scale factor > 1 zooms out and a scale factor < 1 zooms in.
1253+
12531254
For an axes that has had its aspect ratio set to 'equal', 'equalxy',
12541255
'equalyz', or 'equalxz', the relevant axes are constrained to zoom
12551256
equally.
1257+
1258+
Parameters
1259+
----------
1260+
scale_u : float
1261+
Scale factor for the u view axis (view screen horizontal).
1262+
scale_v : float
1263+
Scale factor for the v view axis (view screen vertical).
1264+
scale_w : float
1265+
Scale factor for the w view axis (view screen depth).
12561266
"""
12571267
scale = np.array([scale_u, scale_v, scale_w])
12581268

@@ -1276,6 +1286,15 @@ def scale_axis_limits(self, scale_x, scale_y, scale_z):
12761286
Keeping the center of the x, y, and z data axes fixed, scale their
12771287
limits by scale factors. A scale factor > 1 zooms out and a scale
12781288
factor < 1 zooms in.
1289+
1290+
Parameters
1291+
----------
1292+
scale_x : float
1293+
Scale factor for the x data axis.
1294+
scale_y : float
1295+
Scale factor for the y data axis.
1296+
scale_z : float
1297+
Scale factor for the z data axis.
12791298
"""
12801299
# Get the axis limits and centers
12811300
minx, maxx, miny, maxy, minz, maxz = self.get_w_lims()

lib/mpl_toolkits/mplot3d/proj3d.py

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,26 @@ def rotation_about_vector(v, angle):
7575
def view_axes(E, R, V, roll):
7676
"""
7777
Get the unit viewing axes in data coordinates.
78-
`u` is towards the right of the screen
79-
`v` is towards the top of the screen
80-
`w` is out of the screen
78+
79+
Parameters
80+
----------
81+
E : 3-element numpy array
82+
The coordinates of the eye/camera.
83+
R : 3-element numpy array
84+
The coordinates of the center of the view box.
85+
V : 3-element numpy array
86+
Unit vector in the direction of the vertical axis.
87+
roll : float
88+
The roll angle in radians.
89+
90+
Returns
91+
-------
92+
u : 3-element numpy array
93+
Unit vector pointing towards the right of the screen.
94+
v : 3-element numpy array
95+
Unit vector pointing towards the top of the screen.
96+
w : 3-element numpy array
97+
Unit vector pointing out of the screen.
8198
"""
8299
w = (E - R)
83100
w = w/np.linalg.norm(w)
@@ -94,12 +111,47 @@ def view_axes(E, R, V, roll):
94111
return u, v, w
95112

96113

97-
def view_transformation(u, v, w, E):
114+
def view_transformation_uvw(u, v, w, E):
115+
"""
116+
Return the view transformation matrix.
117+
118+
Parameters
119+
----------
120+
u : 3-element numpy array
121+
Unit vector pointing towards the right of the screen.
122+
v : 3-element numpy array
123+
Unit vector pointing towards the top of the screen.
124+
w : 3-element numpy array
125+
Unit vector pointing out of the screen.
126+
E : 3-element numpy array
127+
The coordinates of the eye/camera.
128+
"""
98129
Mr = np.eye(4)
99130
Mt = np.eye(4)
100131
Mr[:3, :3] = [u, v, w]
101132
Mt[:3, -1] = -E
102-
return np.dot(Mr, Mt)
133+
M = np.dot(Mr, Mt)
134+
return M
135+
136+
137+
def view_transformation(E, R, V, roll):
138+
"""
139+
Return the view transformation matrix.
140+
141+
Parameters
142+
----------
143+
E : 3-element numpy array
144+
The coordinates of the eye/camera.
145+
R : 3-element numpy array
146+
The coordinates of the center of the view box.
147+
V : 3-element numpy array
148+
Unit vector in the direction of the vertical axis.
149+
roll : float
150+
The roll angle in radians.
151+
"""
152+
u, v, w = view_axes(E, R, V, roll)
153+
M = view_transformation_uvw(u, v, w, E)
154+
return M
103155

104156

105157
def persp_transformation(zfront, zback, focal_length):

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,7 @@ def _test_proj_make_M():
976976
R = np.array([100, 100, 100])
977977
V = np.array([0, 0, 1])
978978
roll = 0
979-
u, v, w = proj3d.view_axes(E, R, V, roll)
980-
viewM = proj3d.view_transformation(u, v, w, E)
979+
viewM = proj3d.view_transformation(E, R, V, roll)
981980
perspM = proj3d.persp_transformation(100, -100, 1)
982981
M = np.dot(perspM, viewM)
983982
return M
@@ -1043,8 +1042,7 @@ def test_proj_axes_cube_ortho():
10431042
R = np.array([0, 0, 0])
10441043
V = np.array([0, 0, 1])
10451044
roll = 0
1046-
u, v, w = proj3d.view_axes(E, R, V, roll)
1047-
viewM = proj3d.view_transformation(u, v, w, E)
1045+
viewM = proj3d.view_transformation(E, R, V, roll)
10481046
orthoM = proj3d.ortho_transformation(-1, 1)
10491047
M = np.dot(orthoM, viewM)
10501048

0 commit comments

Comments
 (0)