A community-maintained Python framework for creating mathematical animations.
Fixed camera bugs
Grant Sanderson98801413e9ad
diff --git a/camera/camera.py b/camera/camera.pyindex 344ab98c6..5c74bdf88 100644--- a/camera/camera.py+++ b/camera/camera.py@@ -547,7 +547,7 @@ class Camera(object):points[violator_indices] = rescaledreturn points- def transform_points_pre_display(self, points, mobject):+ def transform_points_pre_display(self, mobject, points):# Subclasses (like ThreeDCamera) may want to# adjust points before they're shownreturn pointsdiff --git a/camera/three_d_camera.py b/camera/three_d_camera.pyindex bad356e74..fd551d80f 100644--- a/camera/three_d_camera.py+++ b/camera/three_d_camera.py@@ -17,6 +17,7 @@ from utils.color import get_shaded_rgbfrom utils.space_ops import rotation_about_zfrom utils.space_ops import rotation_matrixfrom utils.space_ops import center_of_mass+from utils.simple_functions import fdivclass ThreeDCamera(Camera):@@ -166,9 +167,15 @@ class ThreeDCamera(Camera):points -= frame_centerpoints = np.dot(points, rot_matrix.T)zs = points[:, 2]- zs[zs >= distance] = distance - 0.001for i in 0, 1:- points[:, i] *= distance / (distance - zs)+ # Proper projedtion would involve multiplying+ # x and y by d / (d-z). But for points with high+ # z value, this causes weird artifacts, and applying+ # the exponential helps smooth it out.+ factor = np.exp(zs / distance)+ lt0 = zs < 0+ factor[lt0] = (distance / (distance - zs[lt0]))+ points[:, i] *= factorpoints += frame_centerreturn points