Advertisement
NikaGreg

Untitled

Jun 11th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. from manim import *
  2.  
  3. class IntersectionScene(ThreeDScene):
  4.     def construct(self):
  5.         # конус
  6.         radius = 1
  7.         height = 2
  8.  
  9.         surface = Surface(
  10.             lambda u, v: np.array([
  11.                 radius * v * np.cos(u),
  12.                 radius * v * np.sin(u),
  13.                 height * (1 - v)
  14.             ]),
  15.             u_range=[0, 2 * PI],
  16.             v_range=[0, 1],
  17.             resolution=(20, 20),
  18.         ).set_color(TEAL, 0.6).set_fill(TEAL, 0.6)
  19.        
  20.         # плоскость
  21.         plane = Surface(
  22.             lambda u, v: np.array([u, v, z.get_value()]),
  23.             u_range=[-2, 2],
  24.             v_range=[-2, 2],
  25.             resolution=(20, 20),
  26.         ).set_color(YELLOW, 0.6).set_fill(YELLOW, 0.6)
  27.        
  28.         # пересечение
  29.         intersection = always_redraw(lambda:
  30.             Intersection(
  31.                 surface, plane,
  32.                 fill_color = GREEN,
  33.                 fill_opacity = 1,
  34.                 stroke_color = GREEN,
  35.                 stroke_opacity = 1
  36.             )
  37.         )
  38.        
  39.         self.set_camera_orientation(phi=75 * DEGREES, theta=45 * DEGREES)
  40.         self.add(surface, plane, intersection)
  41.         self.wait()
  42.         self.play(plane.animate.shift(2 * OUT), run_time = 4)
  43.         self.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement