Manim's method 9

Overview

I checked manim's method. I tried using ParametricSurface.

Sample code

from manimlib.imports import *

class DSurface(ParametricSurface):
	def __init__(self, **kwargs):
		kwargs = {
			"u_min": -1.5,
			"u_max": 1.5,
			"v_min": -1.5,
			"v_max": 1.5,
			"checkerboard_colors": [GREEN, BLUE],
			"checkerboard_opacity": 0.5
		}
		ParametricSurface.__init__(self, self.func, **kwargs)
	def func(self, x, y):
		return np.array([x, y, x ** 2 + y ** 2])

class test(ThreeDScene):
	def construct(self):
		sphere = ParametricSurface(lambda u, v: np.array([1.5 * np.cos(u) * np.cos(v), 1.5 * np.cos(u) * np.sin(v), 1.5 * np.sin(u)]), v_min = 0, v_max = TAU, u_min = -PI / 2, u_max = PI / 2, checkerboard_colors = [RED_D, RED_E], resolution = (15, 32))
		def param_plane(u, v):
			x = u
			y = v
			z = 0
			return np.array([x, y, z])
		plane = ParametricSurface(param_plane, resolution = (22, 22), v_min = -2, v_max = +2, u_min = -2, u_max = +2, )
		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 = (22, 22), v_min = -2, v_max = +2, u_min = -2, u_max = +2, )
		cylinder = ParametricSurface(lambda u, v: np.array([np.cos(TAU * v), np.sin(TAU * v), 1.0 * (1 - u)]), resolution = (6, 32))
		surface = DSurface()
		axes = ThreeDAxes()
		self.set_camera_orientation(phi = 75 * DEGREES, theta = 30 * DEGREES)
		self.add(axes)
		self.play(ShowCreation(sphere))
		self.wait()
		self.remove(sphere)
		self.play(ShowCreation(plane))
		self.wait()
		self.remove(plane)
		self.play(ShowCreation(gauss_plane))
		self.wait()
		self.remove(gauss_plane)
		self.play(ShowCreation(cylinder))
		self.wait()
		self.remove(cylinder)
		self.play(ShowCreation(surface))
		self.wait()




Generated video

https://www.youtube.com/watch?v=HATdDHmnmD8

that's all.

Recommended Posts

Manim's method 13
Manim's method 2
Manim's method 17
Manim's method 5
Manim's method 3
Manim's method 11
Manim's method 16
Manim's method 20
Manim's method 10
Manim's method 9
Manim's method 6
Manim's method 21
Manim's method 4
Manim's method 8
Manim's method 14
Manim's method 22
Manim's method 19
Manim's method 12
Manim's method part 23
manim's manners
Binary method
Special method
Special method
Understand k-means method
Clustering of clustering method
Dictionary items method
N cross method
Image collection method
Regression analysis method
Gradient method implementation 1
Python-peewee connection method
Class method static method
youtube-dl update method
Monte Carlo method
Mode-Matching Method Simulation_Python
Johnson method (python)
[Python] Semi-Lagrange method