mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Removed ContinualAnimation, reimplemented some of its occurances in the old_projects, added warnings for the rest
This commit is contained in:
parent
3b9c085cf1
commit
b2c7e83843
13 changed files with 136 additions and 139 deletions
|
@ -1,53 +0,0 @@
|
||||||
import copy
|
|
||||||
|
|
||||||
from manimlib.constants import *
|
|
||||||
from manimlib.mobject.mobject import Mobject
|
|
||||||
from manimlib.utils.config_ops import digest_config
|
|
||||||
|
|
||||||
|
|
||||||
class ContinualAnimation(object):
|
|
||||||
CONFIG = {
|
|
||||||
"start_up_time": 1,
|
|
||||||
"wind_down_time": 1,
|
|
||||||
"end_time": np.inf,
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, mobject, **kwargs):
|
|
||||||
assert(isinstance(mobject, Mobject))
|
|
||||||
digest_config(self, kwargs, locals())
|
|
||||||
self.internal_time = 0
|
|
||||||
self.external_time = 0
|
|
||||||
self.setup()
|
|
||||||
self.update(0)
|
|
||||||
|
|
||||||
def setup(self):
|
|
||||||
# To implement in subclass
|
|
||||||
pass
|
|
||||||
|
|
||||||
def begin_wind_down(self, wind_down_time=None):
|
|
||||||
if wind_down_time is not None:
|
|
||||||
self.wind_down_time = wind_down_time
|
|
||||||
self.end_time = self.external_time + self.wind_down_time
|
|
||||||
|
|
||||||
def update(self, dt):
|
|
||||||
# TODO, currenty time moves slower for a
|
|
||||||
# continual animation during its start up
|
|
||||||
# to help smooth things out. Does this have
|
|
||||||
# unwanted consequences?
|
|
||||||
self.external_time += dt
|
|
||||||
if self.external_time < self.start_up_time:
|
|
||||||
dt *= float(self.external_time) / self.start_up_time
|
|
||||||
elif self.external_time > self.end_time - self.wind_down_time:
|
|
||||||
dt *= np.clip(
|
|
||||||
float(self.end_time - self.external_time) / self.wind_down_time,
|
|
||||||
0, 1
|
|
||||||
)
|
|
||||||
self.internal_time += dt
|
|
||||||
self.update_mobject(dt)
|
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
|
||||||
# To implement in subclass
|
|
||||||
pass
|
|
||||||
|
|
||||||
def copy(self):
|
|
||||||
return copy.deepcopy(self)
|
|
|
@ -7,10 +7,8 @@ from manimlib.animation.fading import FadeIn
|
||||||
from manimlib.animation.fading import FadeOut
|
from manimlib.animation.fading import FadeOut
|
||||||
from manimlib.animation.transform import Transform
|
from manimlib.animation.transform import Transform
|
||||||
from manimlib.constants import *
|
from manimlib.constants import *
|
||||||
from manimlib.continual_animation.continual_animation import ContinualAnimation
|
|
||||||
from manimlib.mobject.geometry import AnnularSector
|
from manimlib.mobject.geometry import AnnularSector
|
||||||
from manimlib.mobject.geometry import Annulus
|
from manimlib.mobject.geometry import Annulus
|
||||||
from manimlib.mobject.mobject import Mobject
|
|
||||||
from manimlib.mobject.svg.svg_mobject import SVGMobject
|
from manimlib.mobject.svg.svg_mobject import SVGMobject
|
||||||
from manimlib.mobject.types.vectorized_mobject import VMobject
|
from manimlib.mobject.types.vectorized_mobject import VMobject
|
||||||
from manimlib.mobject.types.vectorized_mobject import VectorizedPoint
|
from manimlib.mobject.types.vectorized_mobject import VectorizedPoint
|
||||||
|
@ -70,8 +68,7 @@ class SwitchOff(LaggedStartMap):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Only AmbientLights and Spotlights can be switched off")
|
"Only AmbientLights and Spotlights can be switched off")
|
||||||
light.submobjects = light.submobjects[::-1]
|
light.submobjects = light.submobjects[::-1]
|
||||||
LaggedStartMap.__init__(self,
|
LaggedStartMap.__init__(self, FadeOut, light, **kwargs)
|
||||||
FadeOut, light, **kwargs)
|
|
||||||
light.submobjects = light.submobjects[::-1]
|
light.submobjects = light.submobjects[::-1]
|
||||||
|
|
||||||
|
|
||||||
|
@ -596,11 +593,8 @@ class LightSource(VMobject):
|
||||||
self.shadow.mark_paths_closed = True
|
self.shadow.mark_paths_closed = True
|
||||||
|
|
||||||
|
|
||||||
class ScreenTracker(ContinualAnimation):
|
# Redefining what was once a ContinualAnimation class
|
||||||
def __init__(self, light_source, **kwargs):
|
# as a function
|
||||||
self.light_source = light_source
|
def ScreenTracker(light_source):
|
||||||
dummy_mob = Mobject()
|
light_source.add_updater(lambda m: m.update())
|
||||||
ContinualAnimation.__init__(self, dummy_mob, **kwargs)
|
return light_source
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
|
||||||
self.light_source.update()
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ from manimlib.animation.transform import MoveToTarget, ApplyMethod
|
||||||
from manimlib.camera.camera import Camera
|
from manimlib.camera.camera import Camera
|
||||||
from manimlib.constants import *
|
from manimlib.constants import *
|
||||||
from manimlib.container.container import Container
|
from manimlib.container.container import Container
|
||||||
from manimlib.continual_animation.continual_animation import ContinualAnimation
|
|
||||||
from manimlib.mobject.mobject import Mobject
|
from manimlib.mobject.mobject import Mobject
|
||||||
from manimlib.mobject.svg.tex_mobject import TextMobject
|
from manimlib.mobject.svg.tex_mobject import TextMobject
|
||||||
from manimlib.scene.scene_file_writer import SceneFileWriter
|
from manimlib.scene.scene_file_writer import SceneFileWriter
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.warn("""
|
||||||
|
Warning: This file makes use of
|
||||||
|
ContinualAnimation, which has since
|
||||||
|
been deprecated
|
||||||
|
""")
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import mpmath
|
import mpmath
|
||||||
|
|
|
@ -5,6 +5,13 @@ from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
from once_useful_constructs.light import *
|
from once_useful_constructs.light import *
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.warn("""
|
||||||
|
Warning: This file makes use of
|
||||||
|
ContinualAnimation, which has since
|
||||||
|
been deprecated
|
||||||
|
""")
|
||||||
|
|
||||||
import types
|
import types
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,14 @@
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from once_useful_constructs.light import *
|
from once_useful_constructs.light import *
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.warn("""
|
||||||
|
Warning: This file makes use of
|
||||||
|
ContinualAnimation, which has since
|
||||||
|
been deprecated
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
import types
|
import types
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,9 @@ class SlidingBlocks(VGroup):
|
||||||
return clack_data
|
return clack_data
|
||||||
|
|
||||||
|
|
||||||
class ClackFlashes(ContinualAnimation):
|
# TODO, this is untested after turning it from a
|
||||||
|
# ContinualAnimation into a VGroup
|
||||||
|
class ClackFlashes(VGroup):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"flash_config": {
|
"flash_config": {
|
||||||
"run_time": 0.5,
|
"run_time": 0.5,
|
||||||
|
@ -209,9 +211,8 @@ class ClackFlashes(ContinualAnimation):
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, clack_data, **kwargs):
|
def __init__(self, clack_data, **kwargs):
|
||||||
digest_config(self, kwargs)
|
VGroup.__init__(self, **kwargs)
|
||||||
self.flashes = []
|
self.flashes = []
|
||||||
group = Group()
|
|
||||||
last_time = 0
|
last_time = 0
|
||||||
for location, time in clack_data:
|
for location, time in clack_data:
|
||||||
if (time - last_time) < self.min_time_between_flashes:
|
if (time - last_time) < self.min_time_between_flashes:
|
||||||
|
@ -225,24 +226,23 @@ class ClackFlashes(ContinualAnimation):
|
||||||
flash.start_time = time
|
flash.start_time = time
|
||||||
flash.end_time = time + flash.run_time
|
flash.end_time = time + flash.run_time
|
||||||
self.flashes.append(flash)
|
self.flashes.append(flash)
|
||||||
ContinualAnimation.__init__(self, group, **kwargs)
|
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
self.time = 0
|
||||||
total_time = self.get_time()
|
self.add_updater(lambda m: m.update(dt))
|
||||||
group = self.mobject
|
|
||||||
|
def update(self, dt):
|
||||||
|
time = self.time
|
||||||
|
self.time += dt
|
||||||
for flash in self.flashes:
|
for flash in self.flashes:
|
||||||
if flash.start_time < total_time < flash.end_time:
|
if flash.start_time < time < flash.end_time:
|
||||||
if flash.mobject not in group:
|
if flash.mobject not in self.submobjects:
|
||||||
group.add(flash.mobject)
|
self.add(flash.mobject)
|
||||||
flash.update(
|
flash.update(
|
||||||
(total_time - flash.start_time) / flash.run_time
|
(time - flash.start_time) / flash.run_time
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if flash.mobject in group:
|
if flash.mobject in self.submobjects:
|
||||||
group.remove(flash.mobject)
|
self.remove(flash.mobject)
|
||||||
|
|
||||||
def get_time(self):
|
|
||||||
return self.external_time
|
|
||||||
|
|
||||||
|
|
||||||
class Wall(Line):
|
class Wall(Line):
|
||||||
|
|
|
@ -5,7 +5,7 @@ DEFAULT_SCALAR_FIELD_COLORS = [BLUE_E, GREEN, YELLOW, RED]
|
||||||
|
|
||||||
# Quick note to anyone coming to this file with the
|
# Quick note to anyone coming to this file with the
|
||||||
# intent of recreating animations from the video. Some
|
# intent of recreating animations from the video. Some
|
||||||
# of these, especially those involving StreamLineAnimation,
|
# of these, especially those involving AnimatedStreamLines,
|
||||||
# can take an extremely long time to run, but much of the
|
# can take an extremely long time to run, but much of the
|
||||||
# computational cost is just for giving subtle little effects
|
# computational cost is just for giving subtle little effects
|
||||||
# which don't matter too much. Switching the line_anim_class
|
# which don't matter too much. Switching the line_anim_class
|
||||||
|
@ -349,41 +349,39 @@ class VectorField(VGroup):
|
||||||
return vect
|
return vect
|
||||||
|
|
||||||
|
|
||||||
# Continual animations
|
# Redefining what was once a ContinualAnimation class
|
||||||
|
# as a function
|
||||||
|
def VectorFieldFlow(mobject, func):
|
||||||
|
mobject.add_updater(
|
||||||
|
lambda m, dt: m.shift(
|
||||||
|
func(m.get_center()) * dt
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return mobject
|
||||||
|
|
||||||
|
|
||||||
class VectorFieldFlow(ContinualAnimation):
|
# Redefining what was once a ContinualAnimation class
|
||||||
CONFIG = {
|
# as a function
|
||||||
"mode": None,
|
def VectorFieldSubmobjectFlow(mobject, func):
|
||||||
}
|
def apply_nudge(mob, dt):
|
||||||
|
for submob in mob:
|
||||||
def __init__(self, mobject, func, **kwargs):
|
|
||||||
"""
|
|
||||||
Func should take in a vector in R3, and output a vector in R3
|
|
||||||
"""
|
|
||||||
self.func = func
|
|
||||||
ContinualAnimation.__init__(self, mobject, **kwargs)
|
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
|
||||||
self.apply_nudge(dt)
|
|
||||||
|
|
||||||
def apply_nudge(self, dt):
|
|
||||||
self.mobject.shift(self.func(self.mobject.get_center()) * dt)
|
|
||||||
|
|
||||||
|
|
||||||
class VectorFieldSubmobjectFlow(VectorFieldFlow):
|
|
||||||
def apply_nudge(self, dt):
|
|
||||||
for submob in self.mobject:
|
|
||||||
x, y = submob.get_center()[:2]
|
x, y = submob.get_center()[:2]
|
||||||
if abs(x) < FRAME_WIDTH and abs(y) < FRAME_HEIGHT:
|
if abs(x) < FRAME_WIDTH and abs(y) < FRAME_HEIGHT:
|
||||||
submob.shift(self.func(submob.get_center()) * dt)
|
submob.shift(func(submob.get_center()) * dt)
|
||||||
|
|
||||||
|
mobject.add_updater(apply_nudge)
|
||||||
|
return mobject
|
||||||
|
|
||||||
|
|
||||||
class VectorFieldPointFlow(VectorFieldFlow):
|
# Redefining what was once a ContinualAnimation class
|
||||||
|
# as a function
|
||||||
|
def VectorFieldPointFlow(mobject, func):
|
||||||
def apply_nudge(self, dt):
|
def apply_nudge(self, dt):
|
||||||
self.mobject.apply_function(
|
self.mobject.apply_function(
|
||||||
lambda p: p + self.func(p) * dt
|
lambda p: p + func(p) * dt
|
||||||
)
|
)
|
||||||
|
mobject.add_updater(apply_nudge)
|
||||||
|
return mobject
|
||||||
|
|
||||||
|
|
||||||
# TODO: Make it so that you can have a group of stream_lines
|
# TODO: Make it so that you can have a group of stream_lines
|
||||||
|
@ -413,7 +411,9 @@ class ShowPassingFlashWithThinningStrokeWidth(AnimationGroup):
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
class StreamLineAnimation(ContinualAnimation):
|
# TODO, this is untested after turning it from a
|
||||||
|
# ContinualAnimation into a VGroup
|
||||||
|
class AnimatedStreamLines(VGroup):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"lag_range": 4,
|
"lag_range": 4,
|
||||||
"line_anim_class": ShowPassingFlash,
|
"line_anim_class": ShowPassingFlash,
|
||||||
|
@ -425,16 +425,16 @@ class StreamLineAnimation(ContinualAnimation):
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, stream_lines, **kwargs):
|
def __init__(self, stream_lines, **kwargs):
|
||||||
digest_config(self, kwargs)
|
VGroup.__init__(self, **kwargs)
|
||||||
self.stream_lines = stream_lines
|
self.stream_lines = stream_lines
|
||||||
group = VGroup()
|
|
||||||
for line in stream_lines:
|
for line in stream_lines:
|
||||||
line.anim = self.line_anim_class(line, **self.line_anim_config)
|
line.anim = self.line_anim_class(line, **self.line_anim_config)
|
||||||
line.time = -self.lag_range * random.random()
|
line.time = -self.lag_range * random.random()
|
||||||
group.add(line.anim.mobject)
|
self.add(line.anim.mobject)
|
||||||
ContinualAnimation.__init__(self, group, **kwargs)
|
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
self.add_updater(lambda m, dt: m.update(dt))
|
||||||
|
|
||||||
|
def update(self, dt):
|
||||||
stream_lines = self.stream_lines
|
stream_lines = self.stream_lines
|
||||||
for line in stream_lines:
|
for line in stream_lines:
|
||||||
line.time += dt
|
line.time += dt
|
||||||
|
@ -442,22 +442,26 @@ class StreamLineAnimation(ContinualAnimation):
|
||||||
line.anim.update(adjusted_time / line.anim.run_time)
|
line.anim.update(adjusted_time / line.anim.run_time)
|
||||||
|
|
||||||
|
|
||||||
class JigglingSubmobjects(ContinualAnimation):
|
# TODO, this is untested after turning it from a
|
||||||
|
# ContinualAnimation into a VGroup
|
||||||
|
class JigglingSubmobjects(VGroup):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"amplitude": 0.05,
|
"amplitude": 0.05,
|
||||||
"jiggles_per_second": 1,
|
"jiggles_per_second": 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, group, **kwargs):
|
def __init__(self, group, **kwargs):
|
||||||
|
VGroup.__init__(self, **kwargs)
|
||||||
for submob in group.submobjects:
|
for submob in group.submobjects:
|
||||||
submob.jiggling_direction = rotate_vector(
|
submob.jiggling_direction = rotate_vector(
|
||||||
RIGHT, np.random.random() * TAU,
|
RIGHT, np.random.random() * TAU,
|
||||||
)
|
)
|
||||||
submob.jiggling_phase = np.random.random() * TAU
|
submob.jiggling_phase = np.random.random() * TAU
|
||||||
ContinualAnimation.__init__(self, group, **kwargs)
|
self.add(submob)
|
||||||
|
self.add_updater(lambda m, dt: m.update(dt))
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
def update(self, dt):
|
||||||
for submob in self.mobject.submobjects:
|
for submob in self.submobjects:
|
||||||
submob.jiggling_phase += dt * self.jiggles_per_second * TAU
|
submob.jiggling_phase += dt * self.jiggles_per_second * TAU
|
||||||
submob.shift(
|
submob.shift(
|
||||||
self.amplitude *
|
self.amplitude *
|
||||||
|
@ -670,7 +674,7 @@ class TestVectorField(Scene):
|
||||||
min_magnitude=0,
|
min_magnitude=0,
|
||||||
max_magnitude=2,
|
max_magnitude=2,
|
||||||
)
|
)
|
||||||
self.add(StreamLineAnimation(
|
self.add(AnimatedStreamLines(
|
||||||
lines,
|
lines,
|
||||||
line_anim_class=ShowPassingFlash
|
line_anim_class=ShowPassingFlash
|
||||||
))
|
))
|
||||||
|
@ -930,7 +934,7 @@ class CylinderModel(Scene):
|
||||||
line_anim_class = ShowPassingFlashWithThinningStrokeWidth
|
line_anim_class = ShowPassingFlashWithThinningStrokeWidth
|
||||||
else:
|
else:
|
||||||
line_anim_class = ShowPassingFlash
|
line_anim_class = ShowPassingFlash
|
||||||
return StreamLineAnimation(
|
return AnimatedStreamLines(
|
||||||
stream_lines,
|
stream_lines,
|
||||||
line_anim_class=line_anim_class,
|
line_anim_class=line_anim_class,
|
||||||
)
|
)
|
||||||
|
@ -1447,7 +1451,7 @@ class IntroduceVectorField(Scene):
|
||||||
vector_field.func,
|
vector_field.func,
|
||||||
**self.stream_line_config
|
**self.stream_line_config
|
||||||
)
|
)
|
||||||
stream_line_animation = StreamLineAnimation(
|
stream_line_animation = AnimatedStreamLines(
|
||||||
stream_lines,
|
stream_lines,
|
||||||
**self.stream_line_animation_config
|
**self.stream_line_animation_config
|
||||||
)
|
)
|
||||||
|
@ -1771,7 +1775,7 @@ class DefineDivergence(ChangingElectricField):
|
||||||
self.vector_field.func,
|
self.vector_field.func,
|
||||||
**self.stream_line_config
|
**self.stream_line_config
|
||||||
)
|
)
|
||||||
stream_line_animation = StreamLineAnimation(
|
stream_line_animation = AnimatedStreamLines(
|
||||||
stream_lines,
|
stream_lines,
|
||||||
**self.stream_line_animation_config
|
**self.stream_line_animation_config
|
||||||
)
|
)
|
||||||
|
@ -1990,7 +1994,7 @@ class DivergenceAtSlowFastPoint(Scene):
|
||||||
self.vector_field.func,
|
self.vector_field.func,
|
||||||
**self.stream_lines_config
|
**self.stream_lines_config
|
||||||
)
|
)
|
||||||
stream_line_animation = StreamLineAnimation(stream_lines)
|
stream_line_animation = AnimatedStreamLines(stream_lines)
|
||||||
stream_line_animation.update(3)
|
stream_line_animation.update(3)
|
||||||
self.add(stream_line_animation)
|
self.add(stream_line_animation)
|
||||||
|
|
||||||
|
@ -2292,7 +2296,7 @@ class PureCylinderFlow(Scene):
|
||||||
|
|
||||||
self.modify_flow(stream_lines)
|
self.modify_flow(stream_lines)
|
||||||
|
|
||||||
stream_line_animation = StreamLineAnimation(stream_lines)
|
stream_line_animation = AnimatedStreamLines(stream_lines)
|
||||||
stream_line_animation.update(3)
|
stream_line_animation.update(3)
|
||||||
|
|
||||||
self.add(stream_line_animation)
|
self.add(stream_line_animation)
|
||||||
|
@ -2384,7 +2388,7 @@ class IntroduceCurl(IntroduceVectorField):
|
||||||
self.vector_field.func,
|
self.vector_field.func,
|
||||||
**self.stream_line_config
|
**self.stream_line_config
|
||||||
)
|
)
|
||||||
stream_line_animation = StreamLineAnimation(
|
stream_line_animation = AnimatedStreamLines(
|
||||||
stream_lines,
|
stream_lines,
|
||||||
**self.stream_line_animation_config
|
**self.stream_line_animation_config
|
||||||
)
|
)
|
||||||
|
@ -3453,7 +3457,7 @@ class PhaseSpaceOfPopulationModel(ShowTwoPopulations, PiCreatureScene, MovingCam
|
||||||
max_magnitude=vector_field.max_magnitude,
|
max_magnitude=vector_field.max_magnitude,
|
||||||
virtual_time=4,
|
virtual_time=4,
|
||||||
)
|
)
|
||||||
stream_line_animation = StreamLineAnimation(
|
stream_line_animation = AnimatedStreamLines(
|
||||||
stream_lines,
|
stream_lines,
|
||||||
)
|
)
|
||||||
self.add(stream_line_animation)
|
self.add(stream_line_animation)
|
||||||
|
@ -4344,7 +4348,7 @@ class ZToHalfFlowNearWall(ComplexTransformationScene, MovingCameraScene):
|
||||||
stroke_width=2,
|
stroke_width=2,
|
||||||
max_magnitude=10,
|
max_magnitude=10,
|
||||||
)
|
)
|
||||||
stream_line_animation = StreamLineAnimation(stream_lines)
|
stream_line_animation = AnimatedStreamLines(stream_lines)
|
||||||
|
|
||||||
self.add(stream_line_animation)
|
self.add(stream_line_animation)
|
||||||
self.wait(7)
|
self.wait(7)
|
||||||
|
|
|
@ -12,12 +12,16 @@ COBALT = "#0047AB"
|
||||||
# updater instead
|
# updater instead
|
||||||
|
|
||||||
|
|
||||||
class Orbiting(ContinualAnimation):
|
# TODO, this is untested after turning it from a
|
||||||
|
# ContinualAnimation into a VGroup
|
||||||
|
class Orbiting(VGroup):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"rate": 7.5,
|
"rate": 7.5,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, planet, star, ellipse, **kwargs):
|
def __init__(self, planet, star, ellipse, **kwargs):
|
||||||
|
VGroup.__init__(self, **kwargs)
|
||||||
|
self.add(planet)
|
||||||
self.planet = planet
|
self.planet = planet
|
||||||
self.star = star
|
self.star = star
|
||||||
self.ellipse = ellipse
|
self.ellipse = ellipse
|
||||||
|
@ -25,9 +29,9 @@ class Orbiting(ContinualAnimation):
|
||||||
self.proportion = 0
|
self.proportion = 0
|
||||||
planet.move_to(ellipse.point_from_proportion(0))
|
planet.move_to(ellipse.point_from_proportion(0))
|
||||||
|
|
||||||
ContinualAnimation.__init__(self, planet, **kwargs)
|
self.add_updater(lambda m, dt: m.update(dt))
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
def update(self, dt):
|
||||||
# time = self.internal_time
|
# time = self.internal_time
|
||||||
|
|
||||||
planet = self.planet
|
planet = self.planet
|
||||||
|
@ -53,22 +57,27 @@ class Orbiting(ContinualAnimation):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class SunAnimation(ContinualAnimation):
|
# TODO, this is untested after turning it from a
|
||||||
|
# ContinualAnimation into a Group
|
||||||
|
class SunAnimation(Group):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"rate": 0.2,
|
"rate": 0.2,
|
||||||
"angle": 60 * DEGREES,
|
"angle": 60 * DEGREES,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, sun, **kwargs):
|
def __init__(self, sun, **kwargs):
|
||||||
|
Group.__init__(self, **kwargs)
|
||||||
self.sun = sun
|
self.sun = sun
|
||||||
self.rotated_sun = sun.deepcopy()
|
self.rotated_sun = sun.deepcopy()
|
||||||
self.rotated_sun.rotate(60 * DEGREES)
|
self.rotated_sun.rotate(60 * DEGREES)
|
||||||
ContinualAnimation.__init__(
|
self.time = 0
|
||||||
self, Group(sun, self.rotated_sun), **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
def update_mobject(self, dt):
|
self.add(self.sun, self.rotated_sun)
|
||||||
time = self.internal_time
|
self.add_updater(lambda m, dt: m.update(dt))
|
||||||
|
|
||||||
|
def update(self, dt):
|
||||||
|
time = self.time
|
||||||
|
self.time += dt
|
||||||
a = (np.sin(self.rate * time * TAU) + 1) / 2.0
|
a = (np.sin(self.rate * time * TAU) + 1) / 2.0
|
||||||
self.rotated_sun.rotate(-self.angle)
|
self.rotated_sun.rotate(-self.angle)
|
||||||
self.rotated_sun.move_to(self.sun)
|
self.rotated_sun.move_to(self.sun)
|
||||||
|
|
|
@ -5,6 +5,14 @@ import cv2
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.warn("""
|
||||||
|
Warning: This file makes use of
|
||||||
|
ContinualAnimation, which has since
|
||||||
|
been deprecated
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
from nn.network import *
|
from nn.network import *
|
||||||
|
|
||||||
#force_skipping
|
#force_skipping
|
||||||
|
|
|
@ -4141,7 +4141,7 @@ class ReferernceSpheresFelixView(ShowRotationsJustWithReferenceCircles):
|
||||||
ShowRotationsJustWithReferenceCircles.move_camera(self, **kwargs)
|
ShowRotationsJustWithReferenceCircles.move_camera(self, **kwargs)
|
||||||
|
|
||||||
def begin_ambient_camera_rotation(self, rate):
|
def begin_ambient_camera_rotation(self, rate):
|
||||||
self.ambient_camera_rotation = ContinualAnimation(VectorizedPoint())
|
self.ambient_camera_rotation = VectorizedPoint()
|
||||||
|
|
||||||
def capture_mobjects_in_camera(self, mobjects, **kwargs):
|
def capture_mobjects_in_camera(self, mobjects, **kwargs):
|
||||||
mobs_on_xy = [
|
mobs_on_xy = [
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
import scipy
|
import scipy
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
from old_projects.fourier import *
|
from old_projects.fourier import *
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.warn("""
|
||||||
|
Warning: This file makes use of
|
||||||
|
ContinualAnimation, which has since
|
||||||
|
been deprecated
|
||||||
|
""")
|
||||||
|
|
||||||
FREQUENCY_COLOR = RED
|
FREQUENCY_COLOR = RED
|
||||||
USE_ALMOST_FOURIER_BY_DEFAULT = False
|
USE_ALMOST_FOURIER_BY_DEFAULT = False
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
from big_ol_pile_of_manim_imports import *
|
from big_ol_pile_of_manim_imports import *
|
||||||
|
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.warn("""
|
||||||
|
Warning: This file makes use of
|
||||||
|
ContinualAnimation, which has since
|
||||||
|
been deprecated
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
E_COLOR = BLUE
|
E_COLOR = BLUE
|
||||||
M_COLOR = YELLOW
|
M_COLOR = YELLOW
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue