Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from manim import *
- config.pixel_height=1920
- config.pixel_width=1080
- config.frame_height=16
- config.frame_width=9
- config.frame_rate=60
- class t(Scene):
- def construct(self):
- def H(P1,P2,P3):
- z = (P1[0],P1[1])
- a = (P2[0],P2[1])
- b = (P3[0],P3[1])
- c=complex
- T=lambda A,B: abs(c(*A)-c(*B))
- g=[((a[0]+b[0])/2,(a[1]+b[1])/2)
- for a,b in[[a,b],[z,a],[b,z]]
- ]
- 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]])]
- i=[u for u in m(g)if u!='']
- C=i[0][1]
- D=i[0][0][1]-(C*i[0][0][0])
- A=i[1][1]
- B=i[1][0][1]-(A*i[1][0][0])
- j=[u for u in m([z,b,a])if u!='']
- C=j[0][1]
- D=j[0][0][1]-(C*j[0][0][0])
- A=j[1][1]
- B=j[1][0][1]-(A*j[1][0][0])
- I=(B-D)/(C-A)
- J=C*I+D
- return np.array([I,J,0])
- a, b = np.sqrt(3.25), 1,
- ellipse = Ellipse(2*a, 2*b, color="green")
- focus1, focus2 = np.array([-1.5, 0, 0]), np.array([1.5, 0, 0])
- moving_point = ValueTracker(0.001)
- moving_dot = always_redraw(lambda: Dot(ellipse.point_from_proportion(moving_point.get_value())))
- triangle = always_redraw(lambda: Polygon(focus1, focus2, moving_dot.get_center()))
- orthocenter_dot=always_redraw(lambda:Dot(H(focus1, focus2, moving_dot.get_center())))
- center_path_ortho1=TracedPath(orthocenter_dot.get_center, stroke_color=PURPLE)
- self.add(ellipse, moving_dot, triangle,orthocenter_dot,center_path_ortho1)
- self.play(moving_point.animate.set_value(0.499), run_time=6, rate_func=linear)
- center_path_ortho1.suspend_updating()
- moving_point.set_value(0.501)
- center_path_ortho2=TracedPath(orthocenter_dot.get_center, stroke_color=PURPLE)
- self.add(triangle,orthocenter_dot,center_path_ortho2)
- self.play(moving_point.animate.set_value(0.999), run_time=6, rate_func=linear)
Add Comment
Please, Sign In to add comment