-
Notifications
You must be signed in to change notification settings - Fork 3
/
sum_formular_for_sine.py
733 lines (593 loc) · 27 KB
/
sum_formular_for_sine.py
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
from manimlib.imports import *
from src.jeff.info_graph import InfoGraph
# projection to y
def projection(x,y):
# (y/np.linalg.norm(y)) * (np.dot(x,y)/np.linalg.norm(y))
return y * np.dot(x, y) / np.dot(y, y)
def unit_vector(x):
return x / np.linalg.norm(x)
# 점x에서, 직선AB와 평행한 단위 벡터
def parallel(x,a,b,length=1):
v = np.subtract(b,a)
u = unit_vector(v) * length
y = np.add(x,u)
return y
def distance(a,b):
return np.linalg.norm(a - b)
def sText(str, color=WHITE):
return Text(str, font='굴림', size=0.3, stroke_width=0, color=color)
def mText(str, color=WHITE):
return Text(str, font='굴림', size=0.7, stroke_width=0, color=color)
def lText(str, color=WHITE):
return Text(str, font='굴림', size=1, stroke_width=0, color=color)
def mTex(str, color=WHITE):
return TexMobject(str, color=color).scale(0.8)
def sTex(str, color=WHITE):
return TexMobject(str, color=color).scale(0.6)
def sTextM(str, color=WHITE):
return TextMobject(str, color=color).scale(0.6)
def mTextM(str, color=WHITE):
return TextMobject(str, color=color).scale(0.8)
def xy(x,y):
return np.array([x,y,0])
def get_triangle(p1,p2,p3):
return Polygon(p1,p2,p3)
class LawOfSineSum(MovingCameraScene):
def addInfoGraph(self):
logo = InfoGraph().scale(1.3)
logo.to_corner(DR).shift(UP*0.5+RIGHT*0.1)
self.add(logo)
def construct(self):
self.addInfoGraph()
self.s1()
self.s2()
self.s3()
self.s4()
self.s5()
self.s6()
self.s7()
self.s8()
def s1(self):
# 삼각함수의 덧셈정리 중 사인함수의 덧셈에 대해 알아보겠습니다.
# t1 = mText("삼각함수의 덧셈정리중 사인함수의 덧셈정리")
t1 = lText("삼각함수의 덧셈정리중 사인함수의 덧셈정리", color=BLUE)
t1.to_edge(UP).to_edge(LEFT).shift(RIGHT)
t2 = mTex(r"\sin (\alpha + \beta) = \sin \alpha \cos \beta + \cos \alpha \sin \beta")
t2.next_to(t1, DOWN, aligned_edge=LEFT).shift(RIGHT*0.5)
self.wait()
self.add_sound(r"res\sound\s1\01_삼각함수의_덧셈정리_중_싸인함수의_덧셈에_대해_알아보겠습니다.mp3")
self.play(
LaggedStart(
ShowCreation(t1),
ShowCreation(t2),
),
run_time=3,
)
self.wait(3)
# 알파 플러스 베타에 대한 싸인값을, 알파와 베타의 각 싸인 값, 코싸인 값으로 나타내보는 것이 덧셈정리입니다.
t3 = mTextM(r"$\rightarrow \sin (\alpha + \beta)$ 를 $\sin \alpha, \sin \beta, \cos \alpha, \cos \beta$로 표현 ")
t3.next_to(t2,DOWN, aligned_edge=LEFT)
self.add_sound(r"res\sound\s1\02_알파_플러스_베타에_대한_싸인값을_알파와_베타의_각_싸인_값_코싸인_값으로_나타내보는_.mp3")
self.play(ShowCreation(t3), run_time=4)
self.wait(6)
self.to_be_removed = VGroup(t3,)
def s2(self):
# 먼저 기본으로 알아야할 것은, 삼각형에서 싸인값 코싸인값이겠죠
p1,p2,p3 = xy(-5,-2),xy(-1,-2),xy(-1,1)
a,b,c = Line(p1,p2), Line(p2,p3), Line(p3,p1)
tri = VGroup(a,b,c)
x,y,d=-1,-2,0.3
elbow = VGroup(Line(xy(x,y+d),xy(x-d,y+d)),Line(xy(x-d,y+d),xy(x-d,y)))
arc = Arc(arc_center=p1, start_angle=0, angle=np.arcsin(3/5))
theta = mTex(r"\theta").next_to(arc, RIGHT).shift(LEFT*0.1+UP*0.1)
at = mTex("a").next_to(a,DOWN)
bt = mTex("b").next_to(b, RIGHT)
ct = mTex("c").next_to(c.point_from_proportion(0.5), UP)
line_text = VGroup(at,bt,ct)
h_at = mText("밑변(가로)", color=RED).next_to(at,DOWN)
h_bt = mText("높이(세로)", color=RED).next_to(bt, DOWN,aligned_edge=LEFT)
h_ct = mText("빗변", color=RED).next_to(ct, DOWN, aligned_edge=RIGHT).shift(LEFT*0.6)
line_h_text = VGroup(h_at, h_bt, h_ct)
self.add_sound(r"res\sound\s1\03_먼저_기본으로_알아야할_것은_삼각형에서_싸인값_코싸인값이겠죠.mp3")
self.play( #5
LaggedStart(
ShowCreation(tri),
ShowCreation(elbow),
ShowCreation(arc),
ShowCreation(theta),
ShowCreation(line_text),
ShowCreation(line_h_text),
),
run_time=3,
)
self.wait(1.5)
# 직각 삼각형이 있을 때, 각 쎄타에 대한 싸인 값은, 빗변분의 세로이고,
# 코싸인값은 빗변분의 가로입니다.
t1 = mTex(r"\sin \theta = ").next_to(bt,RIGHT).shift(RIGHT*2+UP)
t2 = mTex(r"\frac {b}{c}").next_to(t1)
t3 = mTex(r"\cos \theta = ").next_to(t1,DOWN, aligned_edge=LEFT).shift(DOWN)
t4 = mTex(r"\frac {a}{c}").next_to(t3)
self.add_sound(r"res\sound\s1\04_직각_삼각형이__있을_때_각_쎄타에_대한_싸인_값은_빗변분의_세로이고_코싸인값은_빗변.mp3")
self.play(ShowCreation(t1), run_time=2)
self.play(TransformFromCopy(VGroup(ct,bt),t2),run_time=2)
self.wait()
self.play(ShowCreation(t3), run_time=2)
self.play(TransformFromCopy(VGroup(ct, at), t4), run_time=2)
self.wait(2)
# 만약 빗변이 1이라고 하면, 싸인 쎄타는 세로이고, 코싸인 세타는 가로값이 됩니다.
# 머리에 세겨 둡시다.
self.add_sound(r"res\sound\s1\05_만약_빗변이_1이라고_하면_싸인_쎄타는_세로이고_코싸인_세타는_가로값이_됩니다_머리에.mp3")
t_1 = mTex("1", color=YELLOW).move_to(ct)
t_sin = mTex(r"= \sin \theta",color=YELLOW).next_to(bt,RIGHT)
t_cos = mTex(r"= \cos \theta", color=YELLOW).next_to(at, RIGHT)
self.play(
LaggedStart(
FadeIn(c),
Transform(ct,t_1),
),
run_time=1,
)
self.play(
LaggedStart(
FadeIn(b),
ShowCreation(t_sin),
), run_time=1.5,
)
self.play( #15
LaggedStart(
FadeIn(a),
ShowCreation(t_cos),
), run_time=1.5,
)
self.play(
LaggedStart(
FadeIn(t_sin), FadeIn(t_cos),
),run_time=1.5,
)
self.wait(3.5)
self.to_be_removed.add(tri, elbow, arc,theta, line_text, line_h_text)
self.to_be_removed.add(t1,t2,t3,t4)
self.to_be_removed.add(t_1, t_sin, t_cos)
def s3(self):
# 이제 정리를 유도해 보겠습니다.
self.add_sound(r"res\sound\s2\01_이제_정리를_유도해_보겠습니다.mp3")
self.play(FadeOut(self.to_be_removed),run_time=2)
self.wait(1)
# 먼저, 반지름이 1인 원을 그려보겠습니다.
pO = xy(-5,-2)
circle = Circle(radius=1,).move_to(pO)
origin_dot = Dot(color=RED).move_to(circle.get_center())
self.add_sound(r"res\sound\s2\01_먼저_반지름이_1인_원을_그려보겠습니다.mp3")
self.play(
LaggedStart(
ShowCreation(circle),
ShowCreation(origin_dot)
),run_time=1,
)
self.play(circle.scale,4, run_time=2)
line_x = Line(circle.get_left(), circle.get_right(), color=RED, stroke_width=2)
line_y = Line(circle.get_bottom(),circle.get_top(), color=RED, stroke_width=2)
t_1 = mTex("1", color=RED).next_to(line_y.point_from_proportion(0.75), LEFT)
self.play(
LaggedStart(
ShowCreation(line_x),
ShowCreation(line_y),
ShowCreation(t_1),
),run_time=0.5,
)
self.wait()
# 각각의 각이, 알파와 베타가 되도록 점을 찍어보면,
pA = circle.point_from_proportion(0.25/3)
pB = circle.point_from_proportion(0.25*2/3)
dotA = Dot().move_to(pA)
dotB = Dot().move_to(pB)
tA = mTex("A").next_to(dotA, RIGHT).shift(LEFT*0.1)
tB = mTex("B").next_to(dotB, RIGHT).shift(LEFT*0.25,UP*0.25)
lineX = Line(pO, circle.get_right())
lineOA = Line(pO, pA)
lineOB = Line(pO, pB)
arcA = ArcBetweenPoints(lineX.point_from_proportion(0.2),lineOA.point_from_proportion(0.2))
arcB = ArcBetweenPoints(lineOA.point_from_proportion(0.2), lineOB.point_from_proportion(0.2))
alphaT = sTex(r"\alpha").next_to(arcA.point_from_proportion(0.5), RIGHT)
betaT = sTex(r"\beta").next_to(arcB.point_from_proportion(0.5), RIGHT).shift(LEFT*0.1,UP*0.2)
self.add_sound(r"res\sound\s2\02_각각의_각이_알파와_베타가_되도록_점을_찍어보면.mp3")
self.play( #24
LaggedStart(
ShowCreation(dotA),
ShowCreation(tA),
ShowCreation(lineOA),
ShowCreation(arcA),
ShowCreation(alphaT),
ShowCreation(dotB),
ShowCreation(tB),
ShowCreation(lineOB),
ShowCreation(arcB),
ShowCreation(betaT),
),run_time=4,
)
self.wait()
# 알파에 대한 삼각형은 이렇게,
pP = xy(pA[0],pO[1])
lineAP = Line(pA,pP)
linePO = Line(pP,pO)
pPP = xy(linePO.point_from_proportion(0.1)[0],lineAP.point_from_proportion(0.85)[1] )
elbowP = VGroup(
Line(lineAP.point_from_proportion(0.85), pPP),
Line(pPP, linePO.point_from_proportion(0.1)),
)
triA = VGroup(lineAP, linePO, lineOA, elbowP)
self.add_sound(r"res\sound\s2\03_알파에_대한_삼각형은_이렇게.mp3")
self.play(
Succession(
ShowCreation(lineAP),
ShowCreation(linePO),
ShowCreation(lineOA),
ShowCreation(elbowP),
),run_time=1.5,
)
self.play(WiggleOutThenIn(triA), run_time=4)
self.wait()
# 베타에 대한 삼각형은 이렇게 되고,
pQ = pO + projection(lineOB.get_vector(), lineOA.get_vector())
lineBQ = Line(pB, pQ)
lineQO = Line(pQ, pO)
pY = lineBQ.point_from_proportion(0.85)
dQY = distance(pQ,pY)
pZ = parallel(pY,pQ,pO,length=dQY)
pX = parallel(pZ, pB, pQ, length=dQY)
elbowQ = VGroup(
Line(pY,pZ), Line(pZ,pX),
)
triB = VGroup(lineBQ, lineQO, lineOB, elbowQ)
self.add_sound(r"res\sound\s2\04_베타에_대한_삼각형은_이렇게_되고.mp3")
self.play(
Succession(
ShowCreation(lineBQ),
ShowCreation(lineQO),
ShowCreation(lineOB),
ShowCreation(elbowQ),
), run_time=1.5,
)
self.play(WiggleOutThenIn(triB), run_time=4)
self.wait()
# 알파 플러스 베타에 대한 삼각형은 이렇게 됩니다.
arcAB = ArcBetweenPoints(lineX.point_from_proportion(0.1), lineOB.point_from_proportion(0.1))
alphabetaT = sTex(r"\alpha + \beta").next_to(arcAB.get_start(),DOWN, buff=0.15)
pR = xy(pB[0], pO[1])
lineBR = Line(pB, pR)
lineRO = Line(pR, pO)
pRR = xy(lineRO.point_from_proportion(0.15)[0], lineBR.point_from_proportion(0.92)[1])
elbowR = VGroup(
Line(lineBR.point_from_proportion(0.92), pRR),
Line(pRR, lineRO.point_from_proportion(0.15)),
)
triC = VGroup(lineBR, lineRO, lineOB, elbowR)
self.add_sound(r"res\sound\s2\05_알파_플러스_베타에_대한_삼각형은_이렇게_됩니다.mp3")
self.play(
Succession(
ShowCreation(arcAB),
ShowCreation(alphabetaT),
ShowCreation(lineBR),
ShowCreation(lineRO),
ShowCreation(lineOB),
ShowCreation(elbowR),
), run_time=2.5,
)
self.play(WiggleOutThenIn(triC), run_time=4)
self.wait(2)
# 베타에 대한 삼각형에서, 빗변이 1이기에, 세로변은 싸인 베타이고, 밑 변은 코싸인 베타입니다.
t_b1 = mTex("1",color=YELLOW).next_to(lineOB.point_from_proportion(0.5),LEFT,buff=0.1)
t_bsin = mTex(r"\sin \beta",color=YELLOW).move_to(lineBQ.point_from_proportion(0.5))
t_bcos = mTex(r"\cos \beta", color=YELLOW).move_to(lineQO.point_from_proportion(0.5)).rotate(12*DEGREES)
self.add_sound(r"res\sound\s2\06_베타에_대한_삼각형에서_빗변이_1이기에_세로변은_싸인_베타이고_밑_변은_코싸인_베타입.mp3")
self.play(WiggleOutThenIn(triB), run_time=2)
self.play(ShowCreation(t_b1), run_time=1)
self.wait(2)
self.play(ShowCreation(t_bsin), run_time=1)
self.wait(1)
self.play(ShowCreation(t_bcos), run_time=1)
self.wait(3)
# 알파에 대한 삼각형에서, 세로 변은 싸인 알파, 밑 변은 코싸인 알파입니다.
t_asin = mTex(r"\sin \alpha", color=YELLOW).move_to(lineAP.point_from_proportion(0.5))
t_acos = mTex(r"\cos \alpha", color=YELLOW).next_to(linePO.point_from_proportion(0.5), DOWN, buff=0.1)
self.add_sound(r"res\sound\s2\07_알파에_대한_삼각형에서_세로_변은_싸인_알파_밑_변은_코싸인_알파입니다.mp3")
self.play(WiggleOutThenIn(triA), run_time=2)
self.wait(1)
self.play(ShowCreation(t_asin), run_time=1)
self.wait(1)
self.play(ShowCreation(t_acos), run_time=1)
self.wait(4)
# 알파 플러스 베타에 대한 싸인값은,
self.add_sound(r"res\sound\s2\08_알파_플러스_베타에_대한_싸인값은.mp3")
self.play(WiggleOutThenIn(triC), run_time=3)
# 이 삼각형에서 세로 변 이것에 해당합니다.
self.add_sound(r"res\sound\s2\09_이_삼각형에서_세로_변_이것에_해당합니다.mp3")
self.play(lineBR.set_color, BLUE, run_time=2)
self.play(WiggleOutThenIn(lineBR), run_time=2)
self.wait(1)
# 즉, 사인함수의 덧셈정리는, 이 세로 변 값을,
self.add_sound(r"res\sound\s2\10_즉_사인함수의_덧셈정리는_이_세로_변_값을.mp3")
self.wait(3)
self.play(WiggleOutThenIn(lineBR, run_time=2))
self.wait(0.5)
# 싸인 베타, 코싸인 베타, 싸인 알파, 코싸인 알파을 이용해서 나타내는 것입니다.
self.add_sound(r"res\sound\s2\11_싸인_베타_코싸인_베타_싸인_알파_코싸인_알파을_이용해서_나타내는_것입니다.mp3")
sine_texts = VGroup(t_bsin, t_bcos, t_asin, t_acos)
self.play(WiggleOutThenIn(sine_texts, run_time=6))
self.wait(3)
self.pB, self.pO, self.pQ, self.pR = pB, pO, pQ, pR
self.lineBR =lineBR
self.arcA = arcA
self.alphaT = alphaT
self.t_bcos = t_bcos
self.t_bsin = t_bsin
self.elbowQ = elbowQ
self.elbowR = elbowR
def s4(self):
pB, pO, pQ, pR = self.pB, self.pO, self.pQ, self.pR
lineBR = self.lineBR
# 이 세로 변을 적당히 두 개로 나눠보겠습니다.
pS = xy(pR[0], pQ[1])
lineQS = Line(pQ,pS)
lineBS = Line(pB,pS, stroke_width=6,color=GREEN)
lineSR = Line(pS,pR, stroke_width=6,color=RED)
self.add_sound(r"res\sound\s3\01_이_세로_변을_적당히_두_개로_나눠보겠습니다.mp3")
self.play(WiggleOutThenIn(lineBR), run_time=3)
self.wait(1)
self.play(
AnimationGroup(
ShowCreation(lineQS),
ShowCreation(lineBS),
ShowCreation(lineSR),
lag_ratio=1,
), run_time=2,
)
self.play(
LaggedStart(
WiggleOutThenIn(lineBS),
WiggleOutThenIn(lineSR),
), run_time=2,
)
self.wait(0.5)
# 이렇게 나눠서, 아래를 엑스, 윗 부분을 "와이"라 하겠습니다.
self.add_sound(r"res\sound\s3\02_이렇게_나눠서_아래를_엑스_윗_부분을_Y라고_하겠습니다.mp3")
self.wait(2)
tx = mTex("x",color=RED).next_to(lineSR.point_from_proportion(0.5),RIGHT, buff=0.15)
ty = mTex("y",color=GREEN).next_to(lineBS.point_from_proportion(0.7),RIGHT, buff=0.15)
self.play(ShowCreation(tx))
self.wait(0.5)
self.play(ShowCreation(ty)) #65
self.wait(3)
# 이렇게 하면, 싸인 알파 플러스 베타는 엑스 더하기 와이가 됩니다.
self.add_sound(r"res\sound\s3\03_이렇게_하면_싸인_알파_플러스_베타는_엑스_더하기_와이가_됩니다.mp3")
t_sin_ab = TexMobject(r"\sin (\alpha + \beta) =", "x + y", color=YELLOW).scale(0.8)
t_sin_ab.next_to(lineBS.get_start(),RIGHT).shift(RIGHT+UP*0.5)
# t1 = mTex(r"\sin (\alpha + \beta) = x + y",color=YELLOW).next_to(lineBS.get_start(),RIGHT).shift(RIGHT+UP*0.5)
self.play(Write(t_sin_ab), run_time=2)
self.wait(3)
# 이렇게 나눈것은,
pT = xy(pQ[0], pR[1])
lineQT = Line(pQ, pT, color=RED, stroke_width=6)
self.add_sound(r"res\sound\s3\04_이렇게_나눈_것은.mp3")
self.wait(2)
self.play(ShowCreation(lineQT))
# 엑스의 값은, 이 값과 같기에,
self.add_sound(r"res\sound\s3\05_엑스의_값은_이_값과_같기에.mp3")
self.play(WiggleOutThenIn(lineQT), run_time=3)
self.wait()
# 삼각형 이 것을 이용하겠다는 것이고,
lineTO = Line(pT, pO, stroke_width=6, color=RED)
lineOQ = Line(pO, pQ, stroke_width=6, color=RED)
triX = VGroup(lineQT, lineTO, lineOQ)
self.add_sound(r"res\sound\s3\06_삼각형_이_것을_이용하겠다는_것이고.mp3")
self.play(ShowCreation(triX))
self.play(WiggleOutThenIn(triX), run_time=4)
self.wait(1)
# y의 값은, 삼각형 이 것을 이용하기 위해서입니다.
lineSQ = Line(pS, pQ, stroke_width=6, color=GREEN)
lineQB = Line(pQ,pB, stroke_width=6, color=GREEN)
triY = VGroup(lineBS, lineSQ, lineQB)
self.add_sound(r"res\sound\s3\07_y의_값은_삼각형_이_것을_이용하기_위해서입니다.mp3")
self.play(ShowCreation(triY))
self.play(WiggleOutThenIn(triY), run_time=4)
self.wait(2)
self.triX = triX
self.tx = tx
self.ty = ty
self.lineBS = lineBS
self.lineSQ=lineSQ
self.lineQB = lineQB
self.t_sin_ab = t_sin_ab
def s5(self):
triX = self.triX
tx = self.tx
arcA = self.arcA
alphaT=self.alphaT
t_bcos=self.t_bcos
t_bcos2 = t_bcos.copy()
triX2 = VGroup(triX, arcA, alphaT, t_bcos2).copy()
tx2 = tx.copy()
# 먼저 x를 구해 볼게요.
self.add_sound(r"res\sound\s4\01_먼저_x를_구해_볼게요.mp3")
self.play( #79
triX2.shift, 6 * RIGHT, run_time=4,
)
self.play(tx2.next_to, triX2.get_right(),{"direction":RIGHT}, run_time=2)
self.wait(2)
# 이 삼각형에서 빗변이 코싸인 베타, 세로변이 엑스니깐,
self.add_sound(r"res\sound\s4\02_이_삼각형에서_빗변이_코싸인_베타_세로변이_엑스니깐.mp3")
self.play(Indicate(triX2[3]), run_time=2)
self.wait(1)
self.play(Indicate(tx2), run_time=2)
self.wait(0.5)
# 싸인 알파는, 코싸인 베타 분의 엑스가됩니다.
self.add_sound(r"res\sound\s4\03_싸인_알파는_코싸인_베타_분의_엑스가됩니다.mp3")
t_sin_alpha = mTex(r"\sin \alpha = \frac {x}{\cos \beta}",color=YELLOW).next_to(triX2,DOWN,aligned_edge=LEFT)
self.play(Write(t_sin_alpha), run_time=3)
self.wait(4)
# 따라서, 엑스는 싸인 알파, 코싸인 베타가 됩니다.
self.add_sound(r"res\sound\s4\04_따라서_엑스는_싸인_알파_코싸인_베타가_됩니다.mp3")
t_x_equal = mTex(r"x = \sin \alpha \cos \beta",color=YELLOW).next_to(t_sin_alpha,DOWN,aligned_edge=LEFT)
boxX = SurroundingRectangle(t_x_equal)
self.play(Write(t_x_equal), run_time=3)
self.wait()
self.play(Write(boxX))
self.wait(3)
self.boxX = boxX
def s6(self):
t_bsin=self.t_bsin.copy()
ty = self.ty.copy()
lineBS=self.lineBS.copy()
lineSQ=self.lineSQ.copy()
lineQB=self.lineQB.copy()
pQ = self.pQ
pO = self.pO
pB = self.pB
elbowQ = self.elbowQ
elbowR = self.elbowR
alphaT = self.alphaT
# 이제 y값을 구해보겠습니다.
shifted_triX = VGroup(lineBS,lineSQ,lineQB,t_bsin)
self.add_sound(r"res\sound\s5\01_이제_y값을_구해보겠습니다.mp3")
self.play(shifted_triX.shift, RIGHT*3, run_time=3)
self.play(ty.shift, RIGHT*2.5, run_time=2)
# 여기서 이 각은 알파가 됩니다.
n_pB = shifted_triX[0].get_top()
pArcS = shifted_triX[0].point_from_proportion(0.2)
pArcE = shifted_triX[2].point_from_proportion(0.83)
arc = ArcBetweenPoints(pArcS, pArcE)
tAlpha = mTex(r"\alpha",color=YELLOW).next_to(n_pB,RIGHT,buff=0.3).shift(DOWN*0.1)
#B에 있는 알파와 아크
pArcS = self.lineBS.point_from_proportion(0.2)
pArcE = self.lineQB.point_from_proportion(0.83)
arcB = ArcBetweenPoints(pArcS, pArcE)
alpha_in_B = mTex(r"\alpha", YELLOW).next_to(pB, RIGHT, buff=0.1).shift(DOWN * 0.1)
self.add_sound(r"res\sound\s5\02_여기서_이_각은_알파가_됩니다.mp3")
self.play(
ShowCreation(arc),
ShowCreation(tAlpha),
run_time=2
)
#B에 있는
self.play(
ShowCreation(arcB),
Write(alpha_in_B),
run_time=1,
)
self.wait(2)
# 왜냐하면, 이 각은 서로 마주보는 각이기에 같고,
self.add_sound(r"res\sound\s5\03_왜냐하면_이_각은_서로_마주보는_각이기에_같고.mp3")
Tx = pB[0]
Ty = ((pQ[1]-pO[1])/(pQ[0]-pO[0]))*(Tx - pO[0])+pO[1]
pT = xy(Tx,Ty)
dot1 = Dot(radius=0.04,color=GREEN).move_to(pT).shift(DOWN*0.1+LEFT*0.05)
dot2 = Dot(radius=0.04, color=GREEN).move_to(pT).shift(UP * 0.1 + RIGHT * 0.05)
self.camera_frame.save_state()
self.play(
self.camera_frame.shift, LEFT*2+DOWN*0.5,
self.camera_frame.scale, 0.6,
run_time=2,
)
self.play(
ShowCreation(dot1),
ShowCreation(dot2),
)
self.play(
Indicate(dot1, scale_factor=1.5, run_time=2),
Indicate(dot2,scale_factor=1.5, run_time=2),
)
self.wait(2)
# 여기와 여기가 직각이기에,
self.add_sound(r"res\sound\s5\04_여기와_여기가_직각이기에.mp3")
self.play(
Indicate(elbowQ, scale_factor=1.4),
Indicate(elbowR, scale_factor=1.4),
Flash(elbowQ, run_time=2),
Flash(elbowR, run_time=2),
)
self.wait(2)
# 이 각이 알파가 됩니다.
self.add_sound(r"res\sound\s5\05_이_각이_알파가_됩니다.mp3")
self.play(
ShowCreation(arcB),
Write(alpha_in_B),
run_time=1,
)
self.play(
Indicate(arcB),
TransformFromCopy(alphaT,alpha_in_B),
run_time=4,
)
self.wait(2.5)
self.play(self.camera_frame.restore)
self.wait()
self.shifted_triX = shifted_triX
self.shifted_ty = ty
def s7(self):
triX = self.shifted_triX
ty = self.shifted_ty
t_sinb = triX[3]
# 이제 이 삼각형에서,
self.add_sound(r"res\sound\s6\01_이제_이_삼각형에서.mp3")
self.wait()
self.play(WiggleOutThenIn(triX), run_time=2)
self.wait(2)
# 빗 변은 싸인 베타이고, 밑 변이 와이 이기에
self.add_sound(r"res\sound\s6\02_빗_변은_싸인_베타이고_밑_변이_와이_이기에.mp3")
self.play(Indicate(t_sinb,scale_factor=1.3),run_time=2)
self.play(Indicate(ty, scale_factor=1.3), run_time=2)
self.wait()
# 코싸인 알파는 싸인 베타 분의 와이이고,
self.add_sound(r"res\sound\s6\03_코싸인_알파는_싸인_베타_분의_와이이고.mp3")
t_cos_alpha = mTex(r"\cos \alpha = \frac {y}{\sin \beta}", color=YELLOW).next_to(triX.get_top(), RIGHT).shift(RIGHT+DOWN*0.5)
self.play(Write(t_cos_alpha), run_time=3)
self.wait(3)
# 따라서 와이는, 코싸인 알파, 싸인 베타가 됩니다.
self.add_sound(r"res\sound\s6\04_따라서_와이는_코싸인_알파_싸인_베타가_됩니다.mp3")
t_y_equal = mTex(r"y = \cos \alpha \sin \beta", color=YELLOW).next_to(t_cos_alpha, DOWN, aligned_edge=LEFT)
boxY = SurroundingRectangle(t_y_equal)
self.play(Write(t_y_equal), run_time=3)
self.wait(2)
self.play(Write(boxY))
self.wait()
self.boxY = boxY
def s8(self):
t_sin_ab = self.t_sin_ab
boxX = self.boxX
boxY = self.boxY
t_sincos = mTex(r"\sin \alpha \cos \beta",color=YELLOW).next_to(t_sin_ab[0],RIGHT)
t_plus = mTex("+",color=YELLOW).next_to(t_sincos)
t_cossin = mTex(r"\cos \alpha \sin \beta", color=YELLOW).next_to(t_plus)
# 이제 엑스 더하기 와이를 해보면,
self.add_sound(r"res\sound\s7\01_이제_엑스_더하기_와이를_해보면.mp3")
self.play(Indicate(t_sin_ab, scale_factor=1.4, run_time=2))
self.play(Flash(t_sin_ab[1], run_time=2))
self.play(FadeOut(t_sin_ab[1]))
self.play(boxX.move_to, t_sincos, run_time=3)
self.play(
Transform(boxX, t_sincos),
Write(t_plus),
)
self.wait()
self.play(boxY.move_to, t_cossin, run_time=3)
self.play(Transform(boxY, t_cossin),)
self.wait()
# 싸인 알파, 코싸인 베타, 더하기, 코싸인 알파, 싸인 베타가 됩니다.
self.add_sound(r"res\sound\s7\02_싸인_알파_코싸인_베타_더하기_코싸인_알파_싸인_베타가_됩니다.mp3")
self.play(Indicate(VGroup(t_sincos,t_plus,t_cossin)))
self.wait(5)
# 간략히 하면, 싸인 알파 더하기 베타는, "씬 코 코 씬" 입니다.
h1 = mText("씬",color=RED).next_to(t_sincos, DOWN, aligned_edge=LEFT)
h2 = mText("코",color=RED).next_to(h1, RIGHT, buff=0.8)
h3 = mText("코", color=RED).next_to(t_cossin, DOWN, aligned_edge=LEFT)
h4 = mText("씬", color=RED).next_to(h3, RIGHT, buff=0.8)
self.add_sound(r"res\sound\s7\03_간략히_하면_싸인_알파_더하기_베타는_씬코_코씬입니다_박수.mp3")
box = SurroundingRectangle(VGroup(t_sin_ab[0],t_sincos,t_plus,t_cossin))
self.play(ShowCreation(box, run_time=2))
self.play(
LaggedStart(
Write(h1), Write(h2), Write(h3), Write(h4),
),
run_time=3,
)
self.wait(12)