| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + Functions in ``mpl_toolkits.mplot3d.proj3d`` | ||
| 2 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 3 | + | ||
| 4 | + The function ``transform`` is just an alias for ``proj_transform``, | ||
| 5 | + use the latter instead. | ||
| 6 | + | ||
| 7 | + The following functions are either unused (so no longer required in Matplotlib) | ||
| 8 | + or considered private. If you rely on them, please make a copy of the code, | ||
| 9 | + including all functions that starts with a ``_`` (considered private). | ||
| 10 | + | ||
| 11 | + * ``ortho_transformation`` | ||
| 12 | + * ``persp_transformation`` | ||
| 13 | + * ``proj_points`` | ||
| 14 | + * ``proj_trans_points`` | ||
| 15 | + * ``rot_x`` | ||
| 16 | + * ``rotation_about_vector`` | ||
| 17 | + * ``view_transformation`` | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -148,7 +148,7 @@ def set_3d_properties(self, z=0, zdir='z'): | |||
| 148 | 148 | @artist.allow_rasterization | |
| 149 | 149 | def draw(self, renderer): | |
| 150 | 150 | position3d = np.array((self._x, self._y, self._z)) | |
| 151 | - proj = proj3d.proj_trans_points( | ||
| 151 | + proj = proj3d._proj_trans_points( | ||
| 152 | 152 | [position3d, position3d + self._dir_vec], self.axes.M) | |
| 153 | 153 | dx = proj[0][1] - proj[0][0] | |
| 154 | 154 | dy = proj[1][1] - proj[1][0] | |
@@ -359,7 +359,7 @@ def do_3d_projection(self): | |||
| 359 | 359 | """ | |
| 360 | 360 | Project the points according to renderer matrix. | |
| 361 | 361 | """ | |
| 362 | - xyslist = [proj3d.proj_trans_points(points, self.axes.M) | ||
| 362 | + xyslist = [proj3d._proj_trans_points(points, self.axes.M) | ||
| 363 | 363 | for points in self._segments3d] | |
| 364 | 364 | segments_2d = [np.column_stack([xs, ys]) for xs, ys, zs in xyslist] | |
| 365 | 365 | LineCollection.set_segments(self, segments_2d) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -249,7 +249,7 @@ def _tunit_cube(self, vals=None, M=None): | |||
| 249 | 249 | if M is None: | |
| 250 | 250 | M = self.M | |
| 251 | 251 | xyzs = self._unit_cube(vals) | |
| 252 | - tcube = proj3d.proj_points(xyzs, M) | ||
| 252 | + tcube = proj3d._proj_points(xyzs, M) | ||
| 253 | 253 | return tcube | |
| 254 | 254 | ||
| 255 | 255 | @_api.deprecated("3.7") | |
@@ -918,15 +918,15 @@ def get_proj(self): | |||
| 918 | 918 | if self._focal_length == np.inf: | |
| 919 | 919 | # Orthographic projection | |
| 920 | 920 | viewM = proj3d._view_transformation_uvw(u, v, w, eye) | |
| 921 | - projM = proj3d.ortho_transformation(-self._dist, self._dist) | ||
| 921 | + projM = proj3d._ortho_transformation(-self._dist, self._dist) | ||
| 922 | 922 | else: | |
| 923 | 923 | # Perspective projection | |
| 924 | 924 | # Scale the eye dist to compensate for the focal length zoom effect | |
| 925 | 925 | eye_focal = R + self._dist * ps * self._focal_length | |
| 926 | 926 | viewM = proj3d._view_transformation_uvw(u, v, w, eye_focal) | |
| 927 | - projM = proj3d.persp_transformation(-self._dist, | ||
| 928 | - self._dist, | ||
| 929 | - self._focal_length) | ||
| 927 | + projM = proj3d._persp_transformation(-self._dist, | ||
| 928 | + self._dist, | ||
| 929 | + self._focal_length) | ||
| 930 | 930 | ||
| 931 | 931 | # Combine all the transformation matrices to get the final projection | |
| 932 | 932 | M0 = np.dot(viewM, worldM) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -367,7 +367,7 @@ def draw(self, renderer): | |||
| 367 | 367 | ||
| 368 | 368 | # Project the edge points along the current position and | |
| 369 | 369 | # create the line: | |
| 370 | - pep = proj3d.proj_trans_points([edgep1, edgep2], self.axes.M) | ||
| 370 | + pep = proj3d._proj_trans_points([edgep1, edgep2], self.axes.M) | ||
| 371 | 371 | pep = np.asarray(pep) | |
| 372 | 372 | self.line.set_data(pep[0], pep[1]) | |
| 373 | 373 | self.line.draw(renderer) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,8 @@ | |||
| 5 | 5 | import numpy as np | |
| 6 | 6 | import numpy.linalg as linalg | |
| 7 | 7 | ||
| 8 | + from matplotlib import _api | ||
| 9 | + | ||
| 8 | 10 | ||
| 9 | 11 | def _line2d_seg_dist(p, s0, s1): | |
| 10 | 12 | """ | |
@@ -51,7 +53,15 @@ def world_transformation(xmin, xmax, | |||
| 51 | 53 | [0, 0, 0, 1]]) | |
| 52 | 54 | ||
| 53 | 55 | ||
| 56 | + @_api.deprecated("3.8") | ||
| 54 | 57 | def rotation_about_vector(v, angle): | |
| 58 | + """ | ||
| 59 | + Produce a rotation matrix for an angle in radians about a vector. | ||
| 60 | + """ | ||
| 61 | + return _rotation_about_vector(v, angle) | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + def _rotation_about_vector(v, angle): | ||
| 55 | 65 | """ | |
| 56 | 66 | Produce a rotation matrix for an angle in radians about a vector. | |
| 57 | 67 | """ | |
@@ -101,7 +111,7 @@ def _view_axes(E, R, V, roll): | |||
| 101 | 111 | # Save some computation for the default roll=0 | |
| 102 | 112 | if roll != 0: | |
| 103 | 113 | # A positive rotation of the camera is a negative rotation of the world | |
| 104 | - Rroll = rotation_about_vector(w, -roll) | ||
| 114 | + Rroll = _rotation_about_vector(w, -roll) | ||
| 105 | 115 | u = np.dot(Rroll, u) | |
| 106 | 116 | v = np.dot(Rroll, v) | |
| 107 | 117 | return u, v, w | |
@@ -130,6 +140,7 @@ def _view_transformation_uvw(u, v, w, E): | |||
| 130 | 140 | return M | |
| 131 | 141 | ||
| 132 | 142 | ||
| 143 | + @_api.deprecated("3.8") | ||
| 133 | 144 | def view_transformation(E, R, V, roll): | |
| 134 | 145 | """ | |
| 135 | 146 | Return the view transformation matrix. | |
@@ -150,7 +161,12 @@ def view_transformation(E, R, V, roll): | |||
| 150 | 161 | return M | |
| 151 | 162 | ||
| 152 | 163 | ||
| 164 | + @_api.deprecated("3.8") | ||
| 153 | 165 | def persp_transformation(zfront, zback, focal_length): | |
| 166 | + return _persp_transformation(zfront, zback, focal_length) | ||
| 167 | + | ||
| 168 | + | ||
| 169 | + def _persp_transformation(zfront, zback, focal_length): | ||
| 154 | 170 | e = focal_length | |
| 155 | 171 | a = 1 # aspect ratio | |
| 156 | 172 | b = (zfront+zback)/(zfront-zback) | |
@@ -162,7 +178,12 @@ def persp_transformation(zfront, zback, focal_length): | |||
| 162 | 178 | return proj_matrix | |
| 163 | 179 | ||
| 164 | 180 | ||
| 181 | + @_api.deprecated("3.8") | ||
| 165 | 182 | def ortho_transformation(zfront, zback): | |
| 183 | + return _ortho_transformation(zfront, zback) | ||
| 184 | + | ||
| 185 | + | ||
| 186 | + def _ortho_transformation(zfront, zback): | ||
| 166 | 187 | # note: w component in the resulting vector will be (zback-zfront), not 1 | |
| 167 | 188 | a = -(zfront + zback) | |
| 168 | 189 | b = -(zfront - zback) | |
@@ -218,7 +239,9 @@ def proj_transform(xs, ys, zs, M): | |||
| 218 | 239 | return _proj_transform_vec(vec, M) | |
| 219 | 240 | ||
| 220 | 241 | ||
| 221 | - transform = proj_transform | ||
| 242 | + transform = _api.deprecated( | ||
| 243 | + "3.8", obj_type="function", name="transform", | ||
| 244 | + alternative="proj_transform")(proj_transform) | ||
| 222 | 245 | ||
| 223 | 246 | ||
| 224 | 247 | def proj_transform_clip(xs, ys, zs, M): | |
@@ -231,15 +254,26 @@ def proj_transform_clip(xs, ys, zs, M): | |||
| 231 | 254 | return _proj_transform_vec_clip(vec, M) | |
| 232 | 255 | ||
| 233 | 256 | ||
| 257 | + @_api.deprecated("3.8") | ||
| 234 | 258 | def proj_points(points, M): | |
| 235 | - return np.column_stack(proj_trans_points(points, M)) | ||
| 259 | + return _proj_points(points, M) | ||
| 260 | + | ||
| 236 | 261 | ||
| 262 | + def _proj_points(points, M): | ||
| 263 | + return np.column_stack(_proj_trans_points(points, M)) | ||
| 237 | 264 | ||
| 265 | + | ||
| 266 | + @_api.deprecated("3.8") | ||
| 238 | 267 | def proj_trans_points(points, M): | |
| 268 | + return _proj_trans_points(points, M) | ||
| 269 | + | ||
| 270 | + | ||
| 271 | + def _proj_trans_points(points, M): | ||
| 239 | 272 | xs, ys, zs = zip(*points) | |
| 240 | 273 | return proj_transform(xs, ys, zs, M) | |
| 241 | 274 | ||
| 242 | 275 | ||
| 276 | + @_api.deprecated("3.8") | ||
| 243 | 277 | def rot_x(V, alpha): | |
| 244 | 278 | cosa, sina = np.cos(alpha), np.sin(alpha) | |
| 245 | 279 | M1 = np.array([[1, 0, 0, 0], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1016,7 +1016,7 @@ def _test_proj_make_M(): | |||
| 1016 | 1016 | roll = 0 | |
| 1017 | 1017 | u, v, w = proj3d._view_axes(E, R, V, roll) | |
| 1018 | 1018 | viewM = proj3d._view_transformation_uvw(u, v, w, E) | |
| 1019 | - perspM = proj3d.persp_transformation(100, -100, 1) | ||
| 1019 | + perspM = proj3d._persp_transformation(100, -100, 1) | ||
| 1020 | 1020 | M = np.dot(perspM, viewM) | |
| 1021 | 1021 | return M | |
| 1022 | 1022 | ||
@@ -1083,7 +1083,7 @@ def test_proj_axes_cube_ortho(): | |||
| 1083 | 1083 | roll = 0 | |
| 1084 | 1084 | u, v, w = proj3d._view_axes(E, R, V, roll) | |
| 1085 | 1085 | viewM = proj3d._view_transformation_uvw(u, v, w, E) | |
| 1086 | - orthoM = proj3d.ortho_transformation(-1, 1) | ||
| 1086 | + orthoM = proj3d._ortho_transformation(-1, 1) | ||
| 1087 | 1087 | M = np.dot(orthoM, viewM) | |
| 1088 | 1088 | ||
| 1089 | 1089 | ts = '0 1 2 3 0 4 5 6 7 4'.split() | |
@@ -1104,16 +1104,6 @@ def test_proj_axes_cube_ortho(): | |||
| 1104 | 1104 | ax.set_ylim(-200, 200) | |
| 1105 | 1105 | ||
| 1106 | 1106 | ||
| 1107 | - def test_rot(): | ||
| 1108 | - V = [1, 0, 0, 1] | ||
| 1109 | - rotated_V = proj3d.rot_x(V, np.pi / 6) | ||
| 1110 | - np.testing.assert_allclose(rotated_V, [1, 0, 0, 1]) | ||
| 1111 | - | ||
| 1112 | - V = [0, 1, 0, 1] | ||
| 1113 | - rotated_V = proj3d.rot_x(V, np.pi / 6) | ||
| 1114 | - np.testing.assert_allclose(rotated_V, [0, np.sqrt(3) / 2, 0.5, 1]) | ||
| 1115 | - | ||
| 1116 | - | ||
| 1117 | 1107 | def test_world(): | |
| 1118 | 1108 | xmin, xmax = 100, 120 | |
| 1119 | 1109 | ymin, ymax = -100, 100 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments