mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Mildly more efficient CameraFrame.get_view_matrix()
This commit is contained in:
parent
c064b11e2a
commit
058914fdd2
1 changed files with 6 additions and 7 deletions
|
@ -38,6 +38,7 @@ class CameraFrame(Mobject):
|
|||
|
||||
self.default_orientation = Rotation.identity()
|
||||
self.view_matrix = np.identity(4)
|
||||
self.id4x4 = np.identity(4)
|
||||
self.camera_location = OUT # This will be updated by set_points
|
||||
self.euler_axes = euler_axes
|
||||
|
||||
|
@ -100,17 +101,15 @@ class CameraFrame(Mobject):
|
|||
into the camera's internal coordinate system
|
||||
"""
|
||||
if self._data_has_changed:
|
||||
shift = np.identity(4)
|
||||
rotation = np.identity(4)
|
||||
scale_mat = np.identity(4)
|
||||
shift = self.id4x4.copy()
|
||||
rotation = self.id4x4.copy()
|
||||
|
||||
scale = self.get_scale()
|
||||
shift[:3, 3] = -self.get_center()
|
||||
rotation[:3, :3] = self.get_inverse_camera_rotation_matrix()
|
||||
scale = self.get_scale()
|
||||
np.dot(rotation, shift, out=self.view_matrix)
|
||||
if scale > 0:
|
||||
scale_mat[:3, :3] /= self.get_scale()
|
||||
|
||||
self.view_matrix = np.dot(scale_mat, np.dot(rotation, shift))
|
||||
self.view_matrix[:3, :4] /= scale
|
||||
|
||||
return self.view_matrix
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue