|
82 | 82 | .. manim:: ThreeDFunctionPlot
|
83 | 83 |
|
84 | 84 | class ThreeDFunctionPlot(ThreeDScene):
|
85 |
| - |
86 | 85 | def construct(self):
|
87 |
| - |
88 |
| - resolution_fa=22 |
| 86 | + resolution_fa = 22 |
89 | 87 | self.set_camera_orientation(phi=75 * DEGREES, theta=-30 * DEGREES)
|
90 | 88 |
|
91 |
| - def param_plane(u,v): |
92 |
| - x=u |
93 |
| - y=v |
94 |
| - z=0 |
95 |
| - return np.array([x,y,z]) |
96 |
| - plane = ParametricSurface( param_plane, |
97 |
| - resolution = (resolution_fa,resolution_fa), |
98 |
| - v_min = -2, |
99 |
| - v_max = +2, |
100 |
| - u_min = -2, |
101 |
| - u_max = +2 ) |
102 |
| - plane.scale_about_point(2,ORIGIN) |
103 |
| - |
104 |
| - def param_gauss(u,v): |
105 |
| - x=u |
106 |
| - y=v |
| 89 | + def param_plane(u, v): |
| 90 | + x = u |
| 91 | + y = v |
| 92 | + z = 0 |
| 93 | + return np.array([x, y, z]) |
| 94 | + |
| 95 | + plane = ParametricSurface( |
| 96 | + param_plane, |
| 97 | + resolution=(resolution_fa, resolution_fa), |
| 98 | + v_min=-2, |
| 99 | + v_max=+2, |
| 100 | + u_min=-2, |
| 101 | + u_max=+2, |
| 102 | + ) |
| 103 | + plane.scale_about_point(2, ORIGIN) |
| 104 | + |
| 105 | + def param_gauss(u, v): |
| 106 | + x = u |
| 107 | + y = v |
107 | 108 | d = np.sqrt(x * x + y * y)
|
108 | 109 | sigma, mu = 0.4, 0.0
|
109 |
| - z= np.exp(-((d - mu) ** 2 / (2.0 * sigma ** 2))) |
110 |
| - return np.array([x,y,z]) |
111 |
| - |
112 |
| - gauss_plane = ParametricSurface( param_gauss, |
113 |
| - resolution = (resolution_fa, resolution_fa), |
114 |
| - v_min = -2, |
115 |
| - v_max = +2, |
116 |
| - u_min = -2, |
117 |
| - u_max = +2 ) |
118 |
| - |
119 |
| - gauss_plane.scale_about_point(2,ORIGIN) |
| 110 | + z = np.exp(-((d - mu) ** 2 / (2.0 * sigma ** 2))) |
| 111 | + return np.array([x, y, z]) |
| 112 | + |
| 113 | + gauss_plane = ParametricSurface( |
| 114 | + param_gauss, |
| 115 | + resolution=(resolution_fa, resolution_fa), |
| 116 | + v_min=-2, |
| 117 | + v_max=+2, |
| 118 | + u_min=-2, |
| 119 | + u_max=+2, |
| 120 | + ) |
| 121 | + |
| 122 | + gauss_plane.scale_about_point(2, ORIGIN) |
120 | 123 | gauss_plane.set_style(fill_opacity=1)
|
121 | 124 | gauss_plane.set_style(stroke_color=GREEN)
|
122 |
| - gauss_plane.set_fill_by_checkerboard(GREEN,BLUE,opacity=0.1) |
123 |
| - |
| 125 | + gauss_plane.set_fill_by_checkerboard(GREEN, BLUE, opacity=0.1) |
| 126 | + |
124 | 127 | axes = ThreeDAxes()
|
125 |
| - |
| 128 | + |
126 | 129 | self.add(axes)
|
127 | 130 | self.play(Write(plane))
|
128 |
| - self.play(Transform(plane,gauss_plane)) |
| 131 | + self.play(Transform(plane, gauss_plane)) |
129 | 132 | self.wait()
|
130 |
| - |
|
0 commit comments