Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Reduce complexity of ThreeDSurfacePlot example (#1341)

kolibril130b1bcb462930
diff --git a/docs/source/examples.rst b/docs/source/examples.rst
index 2175a6905..742eb5ffa 100644
--- a/docs/source/examples.rst
+++ b/docs/source/examples.rst
@@ -508,6 +508,7 @@ Special Camera Settings
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(axes, sphere)
+
.. manim:: ThreeDCameraRotation
:ref_classes: ThreeDScene ThreeDAxes
:ref_methods: ThreeDScene.begin_ambient_camera_rotation ThreeDScene.stop_ambient_camera_rotation
@@ -519,7 +520,7 @@ Special Camera Settings
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(circle,axes)
self.begin_ambient_camera_rotation(rate=0.1)
- self.wait(3)
+ self.wait()
self.stop_ambient_camera_rotation()
self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES)
self.wait()
@@ -535,61 +536,40 @@ Special Camera Settings
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
self.add(circle,axes)
self.begin_3dillusion_camera_rotation(rate=2)
- self.wait(PI)
+ self.wait(PI/2)
self.stop_3dillusion_camera_rotation()
-.. manim:: ThreeDFunctionPlot
- :ref_classes: ThreeDScene ParametricSurface
-
- class ThreeDFunctionPlot(ThreeDScene):
- def construct(self):
- resolution_fa = 22
- self.set_camera_orientation(phi=75 * DEGREES, theta=-30 * DEGREES)
-
- def param_plane(u, v):
- x = u
- y = v
- z = 0
- return np.array([x, y, z])
-
- plane = ParametricSurface(
- param_plane,
- resolution=(resolution_fa, resolution_fa),
- v_min=-2,
- v_max=+2,
- u_min=-2,
- u_max=+2,
- )
- plane.scale_about_point(2, ORIGIN)
-
- def param_gauss(u, v):
- x = u
- y = v
- d = np.sqrt(x * x + y * y)
- sigma, mu = 0.4, 0.0
- z = np.exp(-((d - mu) ** 2 / (2.0 * sigma ** 2)))
- return np.array([x, y, z])
-
- gauss_plane = ParametricSurface(
- param_gauss,
- resolution=(resolution_fa, resolution_fa),
- v_min=-2,
- v_max=+2,
- u_min=-2,
- u_max=+2,
- )
-
- gauss_plane.scale_about_point(2, ORIGIN)
- gauss_plane.set_style(fill_opacity=1)
- gauss_plane.set_style(stroke_color=GREEN)
- gauss_plane.set_fill_by_checkerboard(GREEN, BLUE, opacity=0.1)
-
- axes = ThreeDAxes()
-
- self.add(axes)
- self.play(Write(plane))
- self.play(Transform(plane, gauss_plane))
- self.wait()
+.. manim:: ThreeDSurfacePlot
+ :save_last_frame:
+ :ref_classes: ThreeDScene ParametricSurface
+
+ class ThreeDSurfacePlot(ThreeDScene):
+ def construct(self):
+ resolution_fa = 42
+ self.set_camera_orientation(phi=75 * DEGREES, theta=-30 * DEGREES)
+
+ def param_gauss(u, v):
+ x = u
+ y = v
+ d = np.sqrt(x * x + y * y)
+ sigma, mu = 0.4, 0.0
+ z = np.exp(-((d - mu) ** 2 / (2.0 * sigma ** 2)))
+ return np.array([x, y, z])
+
+ gauss_plane = ParametricSurface(
+ param_gauss,
+ resolution=(resolution_fa, resolution_fa),
+ v_min=-2,
+ v_max=+2,
+ u_min=-2,
+ u_max=+2,
+ )
+
+ gauss_plane.scale_about_point(2, ORIGIN)
+ gauss_plane.set_style(fill_opacity=1,stroke_color=GREEN)
+ gauss_plane.set_fill_by_checkerboard(ORANGE, BLUE, opacity=0.5)
+ axes = ThreeDAxes()
+ self.add(axes,gauss_plane)
Advanced Projects