|
35 | 35 | from . import art3d
|
36 | 36 | from . import proj3d
|
37 | 37 | from . import axis3d
|
| 38 | +from . import transform3d |
38 | 39 |
|
39 | 40 |
|
40 | 41 | @_docstring.interpd
|
@@ -236,7 +237,7 @@ def _transformed_cube(self, vals):
|
236 | 237 | (maxx, miny, maxz),
|
237 | 238 | (maxx, maxy, maxz),
|
238 | 239 | (minx, maxy, maxz)]
|
239 |
| - return proj3d._proj_points(xyzs, self.M) |
| 240 | + return self.M.transform(xyzs) |
240 | 241 |
|
241 | 242 | def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
|
242 | 243 | """
|
@@ -423,7 +424,7 @@ def draw(self, renderer):
|
423 | 424 |
|
424 | 425 | # add the projection matrix to the renderer
|
425 | 426 | self.M = self.get_proj()
|
426 |
| - self.invM = np.linalg.inv(self.M) |
| 427 | + self.invM = self.M.inverted() |
427 | 428 |
|
428 | 429 | collections_and_patches = (
|
429 | 430 | artist for artist in self._children
|
@@ -1200,12 +1201,8 @@ def get_proj(self):
|
1200 | 1201 |
|
1201 | 1202 | # Transform to uniform world coordinates 0-1, 0-1, 0-1
|
1202 | 1203 | box_aspect = self._roll_to_vertical(self._box_aspect)
|
1203 |
| - worldM = proj3d.world_transformation( |
1204 |
| - *self.get_xlim3d(), |
1205 |
| - *self.get_ylim3d(), |
1206 |
| - *self.get_zlim3d(), |
1207 |
| - pb_aspect=box_aspect, |
1208 |
| - ) |
| 1204 | + worldM = transform3d.WorldTransform(*self.get_xlim3d(), *self.get_ylim3d(), |
| 1205 | + *self.get_zlim3d(), pb_aspect=box_aspect) |
1209 | 1206 |
|
1210 | 1207 | # Look into the middle of the world coordinates:
|
1211 | 1208 | R = 0.5 * box_aspect
|
@@ -1238,21 +1235,18 @@ def get_proj(self):
|
1238 | 1235 | # Generate the view and projection transformation matrices
|
1239 | 1236 | if self._focal_length == np.inf:
|
1240 | 1237 | # Orthographic projection
|
1241 |
| - viewM = proj3d._view_transformation_uvw(u, v, w, eye) |
1242 |
| - projM = proj3d._ortho_transformation(-self._dist, self._dist) |
| 1238 | + viewM = transform3d.ViewTransform(u, v, w, eye) |
| 1239 | + projM = transform3d.OrthographicTransform(-self._dist, self._dist) |
1243 | 1240 | else:
|
1244 | 1241 | # Perspective projection
|
1245 | 1242 | # Scale the eye dist to compensate for the focal length zoom effect
|
1246 | 1243 | eye_focal = R + self._dist * ps * self._focal_length
|
1247 |
| - viewM = proj3d._view_transformation_uvw(u, v, w, eye_focal) |
1248 |
| - projM = proj3d._persp_transformation(-self._dist, |
1249 |
| - self._dist, |
1250 |
| - self._focal_length) |
| 1244 | + viewM = transform3d.ViewTransform(u, v, w, eye_focal) |
| 1245 | + projM = transform3d.PerspectiveTransform(-self._dist, self._dist, |
| 1246 | + self._focal_length) |
1251 | 1247 |
|
1252 | 1248 | # Combine all the transformation matrices to get the final projection
|
1253 |
| - M0 = np.dot(viewM, worldM) |
1254 |
| - M = np.dot(projM, M0) |
1255 |
| - return M |
| 1249 | + return worldM + viewM + projM |
1256 | 1250 |
|
1257 | 1251 | def mouse_init(self, rotate_btn=1, pan_btn=2, zoom_btn=3):
|
1258 | 1252 | """
|
@@ -1459,7 +1453,7 @@ def _calc_coord(self, xv, yv, renderer=None):
|
1459 | 1453 | zv = -1 / self._focal_length
|
1460 | 1454 |
|
1461 | 1455 | # Convert point on view plane to data coordinates
|
1462 |
| - p1 = np.array(proj3d.inv_transform(xv, yv, zv, self.invM)).ravel() |
| 1456 | + p1 = self.invM.transform([xv, yv, zv]) |
1463 | 1457 |
|
1464 | 1458 | # Get the vector from the camera to the point on the view plane
|
1465 | 1459 | vec = self._get_camera_loc() - p1
|
|
0 commit comments