2016-03-07 19:07:00 -08:00
|
|
|
import numpy as np
|
|
|
|
import itertools as it
|
|
|
|
|
|
|
|
from helpers import *
|
|
|
|
|
|
|
|
from mobject.tex_mobject import TexMobject, TextMobject, Brace
|
|
|
|
from mobject import Mobject
|
|
|
|
from mobject.image_mobject import ImageMobject
|
|
|
|
from topics.three_dimensions import Stars
|
|
|
|
|
|
|
|
from animation import Animation
|
2016-03-08 23:13:41 -08:00
|
|
|
from animation.transform import *
|
|
|
|
from animation.simple_animations import *
|
2016-03-07 19:07:00 -08:00
|
|
|
from animation.playground import TurnInsideOut, Vibrate
|
2016-03-08 23:13:41 -08:00
|
|
|
from topics.geometry import *
|
2016-03-07 19:07:00 -08:00
|
|
|
from topics.characters import Randolph, Mathematician
|
|
|
|
from topics.functions import ParametricFunction, FunctionGraph
|
2016-03-08 23:13:41 -08:00
|
|
|
from topics.number_line import *
|
2016-03-07 19:07:00 -08:00
|
|
|
from mobject.region import Region, region_from_polygon_vertices
|
|
|
|
from scene import Scene
|
|
|
|
|
|
|
|
|
|
|
|
class PhysicalIntuition(Scene):
|
|
|
|
def construct(self):
|
|
|
|
n_terms = 4
|
|
|
|
def func((x, y, ignore)):
|
|
|
|
z = complex(x, y)
|
|
|
|
if (np.abs(x%1 - 0.5)<0.01 and y < 0.01) or np.abs(z)<0.01:
|
|
|
|
return ORIGIN
|
|
|
|
out_z = 1./(2*np.tan(np.pi*z)*(z**2))
|
|
|
|
return out_z.real*RIGHT - out_z.imag*UP
|
|
|
|
arrows = Mobject(*[
|
|
|
|
Arrow(ORIGIN, np.sqrt(2)*point)
|
|
|
|
for point in compass_directions(4, RIGHT+UP)
|
|
|
|
])
|
|
|
|
arrows.highlight(YELLOW)
|
|
|
|
arrows.ingest_sub_mobjects()
|
|
|
|
all_arrows = Mobject(*[
|
|
|
|
arrows.copy().scale(0.3/(x)).shift(x*RIGHT)
|
|
|
|
for x in range(1, n_terms+2)
|
|
|
|
])
|
|
|
|
terms = TexMobject([
|
|
|
|
"\\dfrac{1}{%d^2} + "%(x+1)
|
|
|
|
for x in range(n_terms)
|
|
|
|
]+["\\cdots"])
|
|
|
|
terms.shift(2*UP)
|
|
|
|
plane = NumberPlane(color = BLUE_E)
|
|
|
|
axes = Mobject(NumberLine(), NumberLine().rotate(np.pi/2))
|
|
|
|
axes.highlight(WHITE)
|
|
|
|
|
|
|
|
for term in terms.split():
|
|
|
|
self.play(ShimmerIn(term, run_time = 0.5))
|
|
|
|
self.dither()
|
|
|
|
self.play(ShowCreation(plane), ShowCreation(axes))
|
|
|
|
self.play(*[
|
|
|
|
Transform(*pair)
|
|
|
|
for pair in zip(terms.split(), all_arrows.split())
|
|
|
|
])
|
|
|
|
self.play(PhaseFlow(
|
|
|
|
func, plane,
|
|
|
|
run_time = 5,
|
|
|
|
virtual_time = 8
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-08 23:13:41 -08:00
|
|
|
class TimeLine(Scene):
|
|
|
|
def construct(self):
|
|
|
|
dated_events = [
|
|
|
|
{
|
|
|
|
"date" : 1696,
|
|
|
|
"text": "Johann Bernoulli poses Brachistochrone problem",
|
|
|
|
"picture" : "Johann_Bernoulli2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"date" : 1662,
|
|
|
|
"text" : "Fermat states his principle of least time",
|
|
|
|
"picture" : "Pierre_de_Fermat"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
speical_dates = [2016] + [
|
|
|
|
obj["date"] for obj in dated_events
|
|
|
|
]
|
|
|
|
centuries = range(1600, 2100, 100)
|
|
|
|
timeline = NumberLine(
|
|
|
|
numerical_radius = 300,
|
|
|
|
number_at_center = 1800,
|
|
|
|
unit_length_to_spatial_width = SPACE_WIDTH/100,
|
|
|
|
tick_frequency = 10,
|
|
|
|
numbers_with_elongated_ticks = centuries
|
|
|
|
)
|
|
|
|
timeline.add_numbers(*centuries)
|
|
|
|
centers = [
|
|
|
|
Point(timeline.number_to_point(year))
|
|
|
|
for year in speical_dates
|
|
|
|
]
|
|
|
|
timeline.add(*centers)
|
|
|
|
timeline.shift(-centers[0].get_center())
|
|
|
|
|
|
|
|
self.add(timeline)
|
|
|
|
self.dither()
|
2016-03-17 23:54:42 -07:00
|
|
|
run_times = iter([3, 1])
|
2016-03-08 23:13:41 -08:00
|
|
|
for point, event in zip(centers[1:], dated_events):
|
|
|
|
self.play(ApplyMethod(
|
|
|
|
timeline.shift, -point.get_center(),
|
2016-03-17 23:54:42 -07:00
|
|
|
run_time = run_times.next()
|
2016-03-08 23:13:41 -08:00
|
|
|
))
|
|
|
|
picture = ImageMobject(event["picture"], invert = False)
|
|
|
|
picture.scale_to_fit_width(2)
|
|
|
|
picture.to_corner(UP+RIGHT)
|
|
|
|
event_mob = TextMobject(event["text"])
|
|
|
|
event_mob.shift(2*LEFT+2*UP)
|
2016-03-17 23:54:42 -07:00
|
|
|
date_mob = TexMobject(str(event["date"]))
|
|
|
|
date_mob.scale(0.5)
|
|
|
|
date_mob.shift(0.6*UP)
|
|
|
|
line = Line(event_mob.get_bottom(), 0.2*UP)
|
2016-03-08 23:13:41 -08:00
|
|
|
self.play(
|
|
|
|
ShimmerIn(event_mob),
|
2016-03-17 23:54:42 -07:00
|
|
|
ShowCreation(line),
|
|
|
|
ShimmerIn(date_mob)
|
2016-03-08 23:13:41 -08:00
|
|
|
)
|
|
|
|
self.play(FadeIn(picture))
|
2016-03-17 23:54:42 -07:00
|
|
|
self.dither(3)
|
|
|
|
self.play(*map(FadeOut, [event_mob, date_mob, line, picture]))
|
2016-03-07 19:07:00 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|