Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed camera bugs

Grant Sanderson98801413e9ad
diff --git a/camera/camera.py b/camera/camera.py
index 344ab98c6..5c74bdf88 100644
--- a/camera/camera.py
+++ b/camera/camera.py
@@ -547,7 +547,7 @@ class Camera(object):
points[violator_indices] = rescaled
return 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 shown
return points
diff --git a/camera/three_d_camera.py b/camera/three_d_camera.py
index 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_rgb
from utils.space_ops import rotation_about_z
from utils.space_ops import rotation_matrix
from utils.space_ops import center_of_mass
+from utils.simple_functions import fdiv
class ThreeDCamera(Camera):
@@ -166,9 +167,15 @@ class ThreeDCamera(Camera):
points -= frame_center
points = np.dot(points, rot_matrix.T)
zs = points[:, 2]
- zs[zs >= distance] = distance - 0.001
for 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] *= factor
points += frame_center
return points