that_one_nigga_you_k

elipse

May 31st, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1. from manim import *
  2.  
  3. config.pixel_height=1920
  4. config.pixel_width=1080
  5. config.frame_height=16
  6. config.frame_width=9
  7. config.frame_rate=60
  8.  
  9. class t(Scene):
  10.     def construct(self):
  11.         def H(P1,P2,P3):
  12.             z = (P1[0],P1[1])
  13.             a = (P2[0],P2[1])
  14.             b = (P3[0],P3[1])
  15.             c=complex
  16.             T=lambda A,B: abs(c(*A)-c(*B))
  17.             g=[((a[0]+b[0])/2,(a[1]+b[1])/2)
  18.                for a,b in[[a,b],[z,a],[b,z]]
  19.             ]
  20.             m=lambda f:[(a,0) if (b[1][0]-b[0][0])==0 else (a,-1/((b[1][1]-b[0][1])/(b[1][0]-b[0][0])))if(b[1][1]-b[0][1])else''for a,b in zip(f,[[a,b],[z,a],[b,z]])]
  21.             i=[u for u in m(g)if u!='']
  22.             C=i[0][1]
  23.             D=i[0][0][1]-(C*i[0][0][0])
  24.             A=i[1][1]
  25.             B=i[1][0][1]-(A*i[1][0][0])
  26.             j=[u for u in m([z,b,a])if u!='']
  27.             C=j[0][1]
  28.             D=j[0][0][1]-(C*j[0][0][0])
  29.             A=j[1][1]
  30.             B=j[1][0][1]-(A*j[1][0][0])
  31.             I=(B-D)/(C-A)
  32.             J=C*I+D
  33.             return np.array([I,J,0])
  34.  
  35.         a, b = np.sqrt(3.25), 1,
  36.         ellipse = Ellipse(2*a, 2*b, color="green")
  37.         focus1, focus2 = np.array([-1.5, 0, 0]), np.array([1.5, 0, 0])
  38.         moving_point = ValueTracker(0.001)
  39.         moving_dot = always_redraw(lambda: Dot(ellipse.point_from_proportion(moving_point.get_value())))
  40.         triangle = always_redraw(lambda: Polygon(focus1, focus2, moving_dot.get_center()))
  41.  
  42.         orthocenter_dot=always_redraw(lambda:Dot(H(focus1, focus2, moving_dot.get_center())))
  43.         center_path_ortho1=TracedPath(orthocenter_dot.get_center, stroke_color=PURPLE)
  44.  
  45.         self.add(ellipse, moving_dot, triangle,orthocenter_dot,center_path_ortho1)
  46.         self.play(moving_point.animate.set_value(0.499), run_time=6, rate_func=linear)
  47.         center_path_ortho1.suspend_updating()
  48.         moving_point.set_value(0.501)
  49.         center_path_ortho2=TracedPath(orthocenter_dot.get_center, stroke_color=PURPLE)
  50.         self.add(triangle,orthocenter_dot,center_path_ortho2)
  51.         self.play(moving_point.animate.set_value(0.999), run_time=6, rate_func=linear)    
Add Comment
Please, Sign In to add comment