坐标系与坐标平面--效果:

代码:
| |
| from manim import * |
| |
| class ZBX_ZBPM(Scene): |
| |
| def construct(self): |
| |
| my_plane = NumberPlane( |
| faded_line_ratio=2, |
| x_range=[-8, 8, 1], |
| y_range=[-4, 4, 1], |
| x_length=16, |
| y_length=8, |
| background_line_style={ |
| "stroke_color": TEAL, |
| "stroke_width": 2, |
| "stroke_opacity": 0.4, |
| } |
| ) |
| |
| my_ax=Axes( |
| x_range=[-7, 7, 1], |
| y_range=[-4, 4, 1], |
| x_length=14, |
| y_length=8, |
| |
| |
| axis_config={ |
| "include_numbers": True, |
| "tip_shape": StealthTip, |
| "color": TEAL, |
| "numbers_to_include": np.arange(-4, 6, 2), |
| |
| }, |
| ) |
| d1=my_ax.c2p(2,2) |
| self.add(my_plane,my_ax) |
| self.wait() |
| self.add(Dot(d1)) |
| self.wait() |
| lines_1 = my_ax.get_lines_to_point(d1) |
| self.play(Create(lines_1)) |
| self.wait(2) |
| |
| dot0 = Dot() |
| dot1 = Dot().move_to(LEFT*2) |
| text1 = Tex("$\\vec{a}$") |
| l1=Line(dot0,dot1) |
| R1=VGroup(dot0,dot1,l1,text1) |
| text1.next_to(dot1,LEFT) |
| |
| self.add(R1) |
| self.play(Rotating(R1,radians=2*PI,run_time=5,axis=OUT,about_point=0*RIGHT)) |
| self.wait(2) |
| |
| |
| dot2 = Dot().move_to(RIGHT*2) |
| text2 = Text("A") |
| text2.next_to(dot2,LEFT) |
| self.add(dot2,text2) |
| |
| |
| def update_text(obj): |
| obj.next_to(dot2,LEFT,buff=SMALL_BUFF) |
| |
| text2.add_updater(update_text) |
| self.play(Rotating(dot2,radians=2*PI,run_time=5,axis=OUT,about_point=0*RIGHT)) |
| |
| self.wait() |
| |
| dot3 = Dot() |
| text3 = Text("B") |
| text3.next_to(dot3,RIGHT) |
| l3=Line(dot2,dot3) |
| self.add(text3) |
| R2=VGroup(dot2,dot3,l3) |
| self.add(R2) |
| |
| def update_text(obj): |
| obj.next_to(dot3,RIGHT,buff=SMALL_BUFF) |
| self.play(Rotating(R2,radians=2*PI,run_time=5,axis=OUT,about_point=2*RIGHT),UpdateFromFunc(text3,update_text)) |
| self.wait() |
| self.clear() |
| |
| |
| def x2(x): |
| return x**2 |
| |
| def sinx(x): |
| return np.sin(x) |
| |
| def fx(x): |
| for x in [-2,0]: |
| return x**2 |
| |
| for x in [0,6.28]: |
| return np.sin(x) |
| |
| c1=Circle(color=BLUE,radius=3) |
| |
| self.add(my_plane,my_ax) |
| |
| f1= my_ax.plot(x2,color=YELLOW,x_range=[-2, 0]) |
| f2= my_ax.plot(sinx, x_range=[0, 6.28], color=BLUE) |
| f3= my_ax.plot(fx, x_range=[-2, 0], color=RED) |
| dot4=Dot(color=RED).scale(2) |
| dot5=Dot(my_ax.c2p(3,0)) |
| l2=Line(dot0,dot5) |
| vg1=VGroup(f1,f2) |
| self.add(vg1,l2) |
| def update_dot(obj): |
| |
| obj.move_to(my_ax.c2p(x,np.sin(x))) |
| |
| dot5.add_updater(update_dot) |
| |
| |
| self.play(FadeIn(c1),run_time=4) |
| self.play(MoveAlongPath(dot4,f1),run_time=5,rate_fun=linear) |
| self.play(MoveAlongPath(dot4,f2),run_time=5,rate_fun=linear) |
| self.play(MoveAlongPath(dot4,c1),run_time=5,rate_fun=linear) |
| self.wait() |
| self.clear() |
| |
| self.add(f3) |
| self.wait() |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~