本动画通过一个简单的一次函数 ,直观展示直线变化率与斜率的等价关系。
动画围绕两个核心概念展开:
第一部分:基础建立
第二部分:概念引入
第三部分:视觉连接
通过这三个递进环节,观众能够直观理解:一次函数中的系数 ,既是公式中的参数,也代表直线的变化率,更是几何意义上的斜率。
from utils import *config.tex_template = myTemplateclassv3(Scene):defconstruct(self):# ============ 1. 坐标轴和函数图形 ============ ax, ax_x_label, ax_y_label = axes_func() # 获取坐标轴及标签 f = f_func1(0.5, 2) # 定义函数 f(x) = 0.5x + 2 gr = ax.plot(f, x_range=[-1, 13], stroke_width=4, color=GREEN) gr_label = MathTex("y = ax + b", color=GREEN).to_edge(UP, buff=1) self.play(LaggedStart(FadeIn(ax), FadeIn(ax_x_label, ax_y_label), Create(gr), FadeIn(gr_label), lag_ratio=0.2)) self.wait(2)# ============ 2. 黑框遮蔽,显示文字说明 ============ black_sq = Square(color=BLACK).set_opacity(0.8).scale(10) t1 = Tex(r"直线变化率\ ", "=", r"\ 斜率").scale(0.7) self.play(FadeIn(black_sq, t1[0])) self.wait(2) self.play(FadeIn(t1[1])) self.play(FadeIn(t1[2])) self.wait(2)# ============ 3. 高亮公式中的"斜率" ============ gr_label_1 = gr_label.copy() gr_label_1[0][2].set_color(YELLOW) # 高亮 "a"# 绘制箭头,连接公式与说明文字 arrow_t2 = CurvedArrow( gr_label_1[0][2].get_edge_center(DOWN) + DOWN * 0.2, t1[0].get_edge_center(UP) + UP * 0.2, radius=4).set_color(GRAY_C) arrow_t3 = CurvedArrow( gr_label_1[0][2].get_edge_center(DOWN) + DOWN * 0.2, t1[2].get_edge_center(UP) + UP * 0.2, radius=-4).set_color(GRAY_C) self.play(FadeIn(gr_label_1)) self.wait(2) self.play(FadeIn(arrow_t2)) self.wait(2) self.play(FadeIn(arrow_t3)) self.wait(2)# 淡出所有元素 self.play(FadeOut(*self.mobjects)) self.wait(2)%manim -ql -v WARNING v3文章首发:微信公众号:数与理 | 发布日期: 2026 年 3 月 24 日