Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

[3D CAMERA] Add parameter to set the camera position.

frozar2c85f66dddd4
diff --git a/topics/three_dimensions.py b/topics/three_dimensions.py
index 809979f5b..ba9611cb8 100644
--- a/topics/three_dimensions.py
+++ b/topics/three_dimensions.py
@@ -139,10 +139,14 @@ class ThreeDCamera(CameraWithPerspective):
z = curr_z
return np.array([x, y, z])
- def set_position(self, phi = None, theta = None, distance = None):
+ def set_position(self, phi = None, theta = None, distance = None,
+ center_x = None, center_y = None, center_z = None):
point = self.get_spherical_coords(phi, theta, distance)
self.rotation_mobject.move_to(point)
self.phi, self.theta, self.distance = point
+ center_of_rotation = self.get_center_of_rotation(center_x, center_y, center_z)
+ self.moving_center.move_to(center_of_rotation)
+ self.space_center = self.moving_center.points[0]
def get_view_transformation_matrix(self):
return (self.default_distance / self.get_distance()) * np.dot(
@@ -163,8 +167,9 @@ class ThreeDScene(Scene):
"ambient_camera_rotation" : None,
}
- def set_camera_position(self, phi = None, theta = None, distance = None):
- self.camera.set_position(phi, theta, distance)
+ def set_camera_position(self, phi = None, theta = None, distance = None,
+ center_x = None, center_y = None, center_z = None):
+ self.camera.set_position(phi, theta, distance, center_x, center_y, center_z)
def begin_ambient_camera_rotation(self, rate = 0.01):
self.ambient_camera_rotation = AmbientMovement(
@@ -180,9 +185,9 @@ class ThreeDScene(Scene):
self.ambient_camera_rotation = None
def move_camera(
- self,
+ self,
phi = None, theta = None, distance = None,
- center_x = None, center_y = None, center_z = None,
+ center_x = None, center_y = None, center_z = None,
added_anims = [],
**kwargs
):