mirror of
https://github.com/3b1b/manim.git
synced 2025-08-01 17:29:06 +08:00
A few edits to efvgt project
This commit is contained in:
79
efvgt.py
79
efvgt.py
@ -1933,12 +1933,12 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals):
|
||||
positive_reals_words.next_to(positive_reals_line, UP)
|
||||
positive_reals_words.add_background_rectangle()
|
||||
|
||||
half_line, one_line = [
|
||||
third_line, one_line = [
|
||||
DashedLine(
|
||||
self.number_line.number_to_point(num),
|
||||
self.shadow_line.number_to_point(num)
|
||||
)
|
||||
for num in 0.5, 1
|
||||
for num in 0.33, 1
|
||||
]
|
||||
|
||||
self.play(
|
||||
@ -1953,14 +1953,14 @@ class MultiplicativeGroupOfReals(AdditiveGroupOfReals):
|
||||
self.stretch(3)
|
||||
self.stretch(0.33/3, run_time = 3)
|
||||
self.dither()
|
||||
self.play(ShowCreation(half_line), Animation(self.one))
|
||||
self.play(ShowCreation(third_line), Animation(self.one))
|
||||
self.play(
|
||||
ShowCreation(positive_reals_line),
|
||||
Write(positive_reals_words),
|
||||
)
|
||||
self.dither()
|
||||
self.play(
|
||||
ReplacementTransform(half_line, one_line),
|
||||
ReplacementTransform(third_line, one_line),
|
||||
self.number_line.restore,
|
||||
Animation(positive_reals_words),
|
||||
run_time = 2
|
||||
@ -2494,12 +2494,19 @@ class ExponentsAsRepeatedMultiplication(TeacherStudentsScene):
|
||||
Transform(neg_power, neg_one_expression[1]),
|
||||
Write(neg_one_expression)
|
||||
)
|
||||
self.dither()
|
||||
self.dither(2)
|
||||
self.play(
|
||||
self.exponential_rule.next_to,
|
||||
self.get_teacher().get_corner(UP+LEFT), UP, MED_LARGE_BUFF,
|
||||
self.get_teacher().change_mode, "raise_right_hand",
|
||||
)
|
||||
self.dither(2)
|
||||
self.play(
|
||||
imag_power.move_to, UP,
|
||||
imag_power.scale_in_place, 1.5,
|
||||
imag_power.highlight, BLUE,
|
||||
self.get_teacher().change_mode, "raise_right_hand"
|
||||
self.exponential_rule.to_edge, RIGHT,
|
||||
self.get_teacher().change_mode, "speaking"
|
||||
)
|
||||
self.play(*it.chain(*[
|
||||
[pi.change_mode, "pondering", pi.look_at, imag_power]
|
||||
@ -2509,14 +2516,15 @@ class ExponentsAsRepeatedMultiplication(TeacherStudentsScene):
|
||||
|
||||
group_theory_words = TextMobject("Group theory?")
|
||||
group_theory_words.next_to(
|
||||
self.exponential_rule, DOWN+RIGHT, buff = LARGE_BUFF
|
||||
self.exponential_rule, UP, buff = LARGE_BUFF
|
||||
)
|
||||
arrow = Arrow(
|
||||
group_theory_words.get_left(),
|
||||
self.exponential_rule.get_corner(DOWN+RIGHT),
|
||||
group_theory_words,
|
||||
self.exponential_rule,
|
||||
color = WHITE,
|
||||
buff = SMALL_BUFF
|
||||
)
|
||||
VGroup(group_theory_words, arrow).shift(LEFT)
|
||||
group_theory_words.shift_onto_screen()
|
||||
self.play(
|
||||
Write(group_theory_words),
|
||||
ShowCreation(arrow)
|
||||
@ -3147,7 +3155,7 @@ class ComplexExponentiationMultiplierHalf(
|
||||
for last_angle, angle in zip([0]+angles, angles):
|
||||
arc, brace, curved_brace, label = self.get_arc_braces_and_label(angle)
|
||||
if angle == np.pi:
|
||||
label = TexMobject("%.5f"%np.pi)
|
||||
label = TexMobject("%.5f\\dots"%np.pi)
|
||||
label.add_background_rectangle(opacity = 1)
|
||||
label.next_to(curved_brace, UP, buff = SMALL_BUFF)
|
||||
|
||||
@ -3211,6 +3219,23 @@ class WhyE(TeacherStudentsScene):
|
||||
self.play(self.get_teacher().change_mode, "pondering")
|
||||
self.dither(3)
|
||||
|
||||
class ReadFormula(Scene):
|
||||
def construct(self):
|
||||
formula = TexMobject("e^", "{\\pi i}", "=", "-1")
|
||||
formula[1].highlight(GREEN_B)
|
||||
formula[3].highlight(MULTIPLIER_COLOR)
|
||||
formula.scale(2)
|
||||
|
||||
randy = Randolph()
|
||||
randy.shift(2*LEFT)
|
||||
formula.next_to(randy, RIGHT, aligned_edge = UP)
|
||||
|
||||
self.add(randy, formula)
|
||||
self.play(randy.change_mode, "thinking")
|
||||
self.dither()
|
||||
self.play(Blink(randy))
|
||||
self.dither()
|
||||
|
||||
class EfvgtPatreonThanks(PatreonThanks):
|
||||
CONFIG = {
|
||||
"specific_patrons" : [
|
||||
@ -3315,7 +3340,37 @@ class ECLPromo(PiCreatureScene):
|
||||
)
|
||||
self.dither(6)
|
||||
|
||||
|
||||
class ExpTransformation(ComplexTransformationScene):
|
||||
CONFIG = {
|
||||
"camera_class": CameraWithPerspective,
|
||||
}
|
||||
def construct(self):
|
||||
self.camera.camera_distance = 10,
|
||||
self.add_transformable_plane()
|
||||
self.prepare_for_transformation(self.plane)
|
||||
final_plane = self.plane.copy().apply_complex_function(np.exp)
|
||||
cylinder = self.plane.copy().apply_function(
|
||||
lambda (x, y, z) : np.array([x, np.sin(y), -np.cos(y)])
|
||||
)
|
||||
title = TexMobject("z \\to e^z")
|
||||
title.add_background_rectangle()
|
||||
title.scale(1.5)
|
||||
title.next_to(ORIGIN, RIGHT)
|
||||
title.to_edge(UP, buff = MED_SMALL_BUFF)
|
||||
self.add_foreground_mobjects(title)
|
||||
|
||||
self.play(Transform(
|
||||
self.plane, cylinder,
|
||||
run_time = 3,
|
||||
path_arc_axis = RIGHT,
|
||||
path_arc = np.pi,
|
||||
))
|
||||
self.play(Rotate(
|
||||
self.plane, -np.pi/3, UP,
|
||||
run_time = 5
|
||||
))
|
||||
self.play(Transform(self.plane, final_plane, run_time = 3))
|
||||
self.dither(3)
|
||||
|
||||
|
||||
|
||||
|
@ -5,8 +5,9 @@ from mobject import VGroup
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
from number_line import NumberPlane
|
||||
from animation import Animation
|
||||
from animation.transform import ApplyPointwiseFunction
|
||||
from animation.simple_animations import Homotopy, ShowCreation
|
||||
from animation.transform import ApplyPointwiseFunction, MoveToTarget
|
||||
from animation.simple_animations import Homotopy, ShowCreation, \
|
||||
SmoothedVectorizedHomotopy
|
||||
from scene import Scene
|
||||
|
||||
|
||||
|
@ -6,11 +6,26 @@ from topics.geometry import Square
|
||||
from scene import Scene
|
||||
from camera import Camera
|
||||
|
||||
class ThreeDCamera(Camera):
|
||||
class CameraWithPerspective(Camera):
|
||||
CONFIG = {
|
||||
"camera_distance" : 20,
|
||||
}
|
||||
def points_to_pixel_coords(self, points):
|
||||
distance_ratios = np.divide(
|
||||
self.camera_distance,
|
||||
self.camera_distance - points[:,2]
|
||||
)
|
||||
scale_factors = interpolate(0, 1, distance_ratios)
|
||||
adjusted_points = np.array(points)
|
||||
for i in 0, 1:
|
||||
adjusted_points[:,i] *= scale_factors
|
||||
|
||||
return Camera.points_to_pixel_coords(self, adjusted_points)
|
||||
|
||||
class ThreeDCamera(CameraWithPerspective):
|
||||
CONFIG = {
|
||||
"sun_vect" : 3*UP+LEFT,
|
||||
"shading_factor" : 0.5,
|
||||
"camera_distance" : 20,
|
||||
}
|
||||
def __init__(self, *args, **kwargs):
|
||||
Camera.__init__(self, *args, **kwargs)
|
||||
@ -69,17 +84,6 @@ class ThreeDCamera(Camera):
|
||||
self, sorted(vmobjects, cmp = z_cmp)
|
||||
)
|
||||
|
||||
|
||||
def points_to_pixel_coords(self, points):
|
||||
distance_ratios = (self.camera_distance + points[:,2])/self.camera_distance
|
||||
scale_factors = interpolate(0, 1, distance_ratios)
|
||||
adjusted_points = np.array(points)
|
||||
for i in 0, 1:
|
||||
adjusted_points[:,i] *= scale_factors
|
||||
|
||||
return Camera.points_to_pixel_coords(self, adjusted_points)
|
||||
|
||||
|
||||
class ThreeDScene(Scene):
|
||||
CONFIG = {
|
||||
"camera_class" : ThreeDCamera,
|
||||
|
Reference in New Issue
Block a user