1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
| from math import gamma from re import A from manimlib import * import numpy as np
class main(Scene): def construct(self):
title2 = Text("椭圆 · Part I · 基本性质", font="HarmonyOS Sans SC").scale(2) self.play(ShowCreation(title2)) self.play(title2.animate.scale(0.5).to_corner(UL)) axesL = Axes( x_range=(-3,3,0.5), y_range=(-2,2,0.5), height=4, width=6 ).shift(UP*0.5+LEFT*4) self.play( ShowCreation(axesL), Write(axesL.get_axis_labels()))
a = 2 b = 1.5 ellipseL = Ellipse(width=4,height=3).set_color(BLUE).move_to(axesL) self.play(ShowCreation(ellipseL))
f = np.sqrt(7)/2 dF1 = Dot(axesL.c2p(-f,0)).set_color(ORANGE) dF2 = Dot(axesL.c2p(f,0)).set_color(ORANGE) tF1 = Tex(r"F1").set_color(ORANGE).scale(0.5).next_to(dF1, direction=DOWN*1/2) tF2 = Tex(r"F2").set_color(ORANGE).scale(0.5).next_to(dF2, direction=DOWN*1/2) gF = VGroup(dF1, tF1, dF2, tF2) self.play(ShowCreation(gF)) funcL = Tex(r"\frac{x^2}{a^2}+\frac{y^2}{b^2}=1(a>b>0)", isolate=["\frac{x^2}{a^2}+\frac{y^2}{b^2}=1"],color=BLUE).scale(0.75).move_to(axesL).shift(DOWN*2.5) funcL.move_to(axesL).shift(DOWN*3) self.play(Write(funcL)) self.wait(0.5)
line = Line(start=UP*4, end=DOWN*4) self.play(ShowCreation(line))
stitle = Text("基本性质", font="HarmonyOS Sans SC").to_edge(UP).shift(RIGHT*3.5) self.play(TransformFromCopy(title2, stitle)) self.wait(1)
self.save_state()
self.play(*[ApplyWave(mob) for mob in gF]) 焦点 = Text("F1,F2 (±c,0): 焦点", font="HarmonyOS Sans SC").set_color(ORANGE).scale(0.75).move_to(stitle).shift(DOWN+LEFT*1.5) self.play(Write(焦点)) 焦距线 = Line(start=dF1, end=dF2).set_color(ORANGE) 焦距1 = Tex(r"\left|F_1F_2\right|").scale(0.75).next_to(焦点).set_color(ORANGE) 焦距2 = Text(": 焦距", font="HarmonyOS Sans SC").scale(0.75).next_to(焦距1).set_color(ORANGE) self.play(ShowCreationThenDestruction(焦距线), run_time=1.5, rate_func=double_smooth) self.play(Write(焦距1), Write(焦距2)) self.wait(1)
dA1 = Dot(axesL.c2p(-2,0)).set_color(GREEN) dA2 = Dot(axesL.c2p(2,0)).set_color(GREEN) tA1 = Tex(r"A_1").set_color(GREEN).scale(0.5).next_to(dA1, direction=DOWN*1/2) tA2 = Tex(r"A_2").set_color(GREEN).scale(0.5).next_to(dA2, direction=DOWN*1/2) gA = VGroup(dA1, tA1, dA2, tA2) self.play(ShowCreation(gA)) 左右顶点 = Text("A1,A2 (±a,0): 左右顶点", font="HarmonyOS Sans SC").set_color(GREEN).scale(0.75).move_to(焦点).shift(DOWN) self.play(Write(左右顶点)) 长轴 = Line(start=dA1, end=dA2).set_color(GREEN) 长轴1 = Tex(r"\left|A_1A_2\right|").scale(0.75).next_to(左右顶点).set_color(GREEN) 长轴2 = Text(": 长轴", font="HarmonyOS Sans SC").scale(0.75).next_to(长轴1).set_color(GREEN) self.play(ShowCreationThenDestruction(长轴), run_time=1.5, rate_func=double_smooth) self.play(Write(长轴1), Write(长轴2)) self.wait(1)
dB1 = Dot(axesL.c2p(0,-1.5)).set_color(GOLD) dB2 = Dot(axesL.c2p(0,1.5)).set_color(GOLD) tB1 = Tex(r"B_1").set_color(GOLD).scale(0.5).next_to(dB1, direction=DOWN*1/2) tB2 = Tex(r"B_2").set_color(GOLD).scale(0.5).next_to(dB2, direction=DOWN*1/2) gB = VGroup(dB1, tB1, dB2, tB2) self.play(ShowCreation(gB)) 上下顶点 = Text("B1,B2 (±b,0): 上下顶点", font="HarmonyOS Sans SC").set_color(GOLD).scale(0.75).move_to(左右顶点).shift(DOWN) self.play(Write(上下顶点)) 短轴 = Line(start=dB1, end=dB2).set_color(GOLD) 短轴1 = Tex(r"\left|B_1B_2\right|").scale(0.75).next_to(上下顶点).set_color(GOLD) 短轴2 = Text(": 短轴", font="HarmonyOS Sans SC").scale(0.75).next_to(短轴1).set_color(GOLD) self.play(ShowCreationThenDestruction(短轴), run_time=1.5, rate_func=double_smooth) self.play(Write(短轴1), Write(短轴2)) self.wait(2)
self.restore()
e_t = Text("离心率", font="HarmonyOS Sans SC").scale(0.85).move_to(line, aligned_edge=LEFT).to_edge(UP).shift(DOWN*1.5+RIGHT*0.25) self.play(Write(e_t)) e_d = Tex(r"e=\frac{c}{a}", isolate=["e="]).scale(0.75).next_to(e_t) self.play(Write(e_d)) e_d2 = Tex(r"=\frac{\left|F_1F_2\right|}{\left|PF_1\right|+\left|PF_2\right|}").scale(0.75).next_to(e_d) self.play(TransformFromCopy(e_d, e_d2))
M1 = Dot(color=YELLOW_D).move_to(ellipseL.pfp(0.3)) M2 = Dot(color=YELLOW_D).move_to(ellipseL.pfp(0.58)) CMF = Polygon(M1.get_center(), M2.get_center(), dF2.get_center()).set_color(YELLOW_D) CMF_t = Text("焦点三角形", font="HarmonyOS Sans SC").scale(0.85).move_to(line, aligned_edge=LEFT).shift(RIGHT*0.25).match_y(e_d).shift(DOWN) CMF_d = Tex(r"C_{\triangle ABF_2}=4a").scale(0.75).next_to(CMF_t) self.play(Write(CMF_t)) self.play(ShowCreation(M1), ShowCreation(M2)) self.play(ShowCreation(CMF)) self.play(Write(CMF_d)) self.wait(2) CMF_a = VGroup(M1, M2, CMF) self.play(*[FadeOut(mob) for mob in CMF_a])
h = b*b/a dH1 = Dot(axesL.c2p(-f,h), color=YELLOW_D) dH2 = Dot(axesL.c2p(-f,-h), color=YELLOW_D) lH = Line(dH1, dH2).set_color(YELLOW_D) gH = VGroup(dH1, dH2, lH) h_t = Text("通径", font="HarmonyOS Sans SC").scale(0.85).move_to(line, aligned_edge=LEFT).shift(RIGHT*0.25).match_y(CMF_t).shift(DOWN) self.play(Write(h_t)) self.play(ShowCreation(gH)) h_d = Tex(r"=\frac{2b^2}{a}").scale(0.75).next_to(h_t) self.play(Write(h_d)) self.wait(2) self.play(*[FadeOut(mob) for mob in gH])
P = Dot(color=YELLOW_D).move_to(ellipseL.pfp(0.15)) P_l = Tex(r"P").scale(0.7).set_color(YELLOW_D).next_to(P) PF1 = Line(P, dF1).set_color(YELLOW_D) PF2 = Line(P, dF2).set_color(YELLOW_D) gP = VGroup(P, PF1, PF2, P_l) p_t = Text("椭圆上一点P", font="HarmonyOS Sans SC").scale(0.85).move_to(line, aligned_edge=LEFT).shift(RIGHT*0.25).match_y(h_t).shift(DOWN) self.play(ShowCreation(gP)) self.play(Write(p_t)) p_1 = Tex(r"\left|PF\right|\in\ \left[a-c,a+c\right]").scale(0.75).move_to(line, aligned_edge=LEFT).shift(RIGHT).match_y(p_t).shift(DOWN) self.play(Write(p_1)) p_2 = Tex(r"\left|PF_1\right|\bullet\left|PF_2\right|=\left[b^2,a^2\right]").scale(0.75).move_to(line, aligned_edge=LEFT).shift(RIGHT).match_y(p_1).shift(DOWN) self.play(Write(p_2)) self.wait(2)
self.restore() self.play(ShowCreation(gP)) a_1 = PF1.get_angle() a1=a_1 a_2 = PF2.get_angle() a2 = a_2-a_1 theta = Arc(start_angle=a1, angle=a2, arc_center=P.get_center(), radius=0.5) t_l = Tex(r"\theta").scale(0.7).set_color(GREEN).next_to(theta, DOWN) gt = VGroup(theta, t_l) self.play(ShowCreation(gt)) S_d = Tex(r'S_{\triangle F_1PF_2}=b^2\bullet tan\frac{\theta}{2}', t2c={'\theta':GREEN}).scale(0.85).move_to(line, aligned_edge=LEFT).to_edge(UP).shift(DOWN*1.5+RIGHT*0.25) self.play(Write(S_d)) func_derivation = VGroup( Tex(r"S_{\triangle F_1PF_2}=\frac{1}{2}\bullet\left|PF_1\right|\bullet\left|PF_2\right|\bullet\sin{\theta}", isolate=["\left|PF_1\right|\bullet\left|PF_2\right|"]).scale(0.6).match_x(stitle).to_edge(UP).shift(DOWN*2.5), Tex(r"\left|F_1F_2\right|^2=\left|PF_1\right|^2+\left|PF_2\right|^2-2\left|PF_1\right|\bullet\left|PF_2\right|\bullet\cos{\theta}", isolate=["\left|F_1F_2\right|^2=", "\left|PF_1\right|\bullet\left|PF_2\right|", "\bullet\cos{\theta}"]).scale(0.6).match_x(stitle).to_edge(UP).shift(DOWN*3.5), Tex(r"{\left|F_1F_2\right|^2=\left(\left|PF_1\right|+\left|PF_2\right|\right)}^2-2\left|PF_1\right|\bullet\left|PF_2\right|\bullet\left(1+\cos{\theta}\right)", isolate=["\left|F_1F_2\right|^2=", "\left|PF_1\right|\bullet\left|PF_2\right|", "\left(1+\cos{\theta}\right)"]).scale(0.5).match_x(stitle).to_edge(UP).shift(DOWN*4.5), Tex(r"{4c}^2={4a}^2-2\left|PF_1\right|\bullet\left|PF_2\right|\bullet\left(1+\cos{\theta}\right)", isolate=["\left|PF_1\right|\bullet\left|PF_2\right|", "\left(1+\cos{\theta}\right)"]).scale(0.6).match_x(stitle).to_edge(UP).shift(DOWN*5.5), Tex(r"\left|PF_1\right|\bullet\left|PF_2\right|=\frac{2b^2}{\left(1+\cos{\theta}\right)}").scale(0.6).match_x(stitle).to_edge(UP).shift(DOWN*6.5) ) self.play(Write(func_derivation[0])) self.play(TransformFromCopy(func_derivation[0], func_derivation[1])) self.play(TransformFromCopy(func_derivation[1], func_derivation[2])) self.play(TransformFromCopy(func_derivation[2], func_derivation[3])) self.play(TransformFromCopy(func_derivation[3], func_derivation[4])) self.play(ShowCreationThenDestructionAround(func_derivation[4])) self.play(Indicate(S_d)) self.wait(2)
self.restore() self.add(P) PA = VGroup( Line(P, dA1), Line(P,dA2) ) PA.set_color(YELLOW_D) PA_d = Tex(r"k_{PA_1}\bullet k_{PA_2}=-\frac{b^2}{a^2}").scale(0.8).move_to(line, aligned_edge=LEFT).to_edge(UP).shift(DOWN*1.5+RIGHT*0.25) self.play(ShowCreation(gA)) self.play(ShowCreation(PA)) self.play(Write(PA_d)) self.wait(2)
|