mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Cleaned up rotation.py
This commit is contained in:
parent
c1cc1a8b24
commit
9550174eba
1 changed files with 16 additions and 20 deletions
|
@ -1,9 +1,8 @@
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
from manimlib.animation.animation import Animation
|
from manimlib.animation.animation import Animation
|
||||||
from manimlib.animation.transform import Transform
|
from manimlib.animation.transform import Transform
|
||||||
from manimlib.constants import *
|
from manimlib.constants import OUT
|
||||||
from manimlib.utils.config_ops import digest_config
|
from manimlib.constants import PI
|
||||||
|
from manimlib.constants import TAU
|
||||||
from manimlib.utils.rate_functions import linear
|
from manimlib.utils.rate_functions import linear
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,18 +12,12 @@ class Rotating(Animation):
|
||||||
"radians": TAU,
|
"radians": TAU,
|
||||||
"run_time": 5,
|
"run_time": 5,
|
||||||
"rate_func": linear,
|
"rate_func": linear,
|
||||||
"in_place": True,
|
|
||||||
"about_point": None,
|
"about_point": None,
|
||||||
"about_edge": None,
|
"about_edge": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
def interpolate_submobject(self, submobject, starting_submobject, alpha):
|
|
||||||
submobject.points = np.array(starting_submobject.points)
|
|
||||||
|
|
||||||
def interpolate_mobject(self, alpha):
|
def interpolate_mobject(self, alpha):
|
||||||
Animation.interpolate_mobject(self, alpha)
|
self.mobject.become(self.starting_mobject)
|
||||||
if self.in_place and self.about_point is None:
|
|
||||||
self.about_point = self.mobject.get_center()
|
|
||||||
self.mobject.rotate(
|
self.mobject.rotate(
|
||||||
alpha * self.radians,
|
alpha * self.radians,
|
||||||
axis=self.axis,
|
axis=self.axis,
|
||||||
|
@ -35,22 +28,25 @@ class Rotating(Animation):
|
||||||
|
|
||||||
class Rotate(Transform):
|
class Rotate(Transform):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"in_place": False,
|
|
||||||
"about_point": None,
|
"about_point": None,
|
||||||
|
"about_edge": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, mobject, angle=np.pi, axis=OUT, **kwargs):
|
def __init__(self, mobject, angle=PI, axis=OUT, **kwargs):
|
||||||
if "path_arc" not in kwargs:
|
if "path_arc" not in kwargs:
|
||||||
kwargs["path_arc"] = angle
|
kwargs["path_arc"] = angle
|
||||||
if "path_arc_axis" not in kwargs:
|
if "path_arc_axis" not in kwargs:
|
||||||
kwargs["path_arc_axis"] = axis
|
kwargs["path_arc_axis"] = axis
|
||||||
digest_config(self, kwargs, locals())
|
self.angle = angle
|
||||||
target = mobject.deepcopy()
|
self.axis = axis
|
||||||
if self.in_place:
|
super().__init__(mobject, **kwargs)
|
||||||
self.about_point = mobject.get_center()
|
|
||||||
|
def create_target(self):
|
||||||
|
target = self.mobject.copy()
|
||||||
target.rotate(
|
target.rotate(
|
||||||
angle,
|
self.angle,
|
||||||
axis=axis,
|
axis=self.axis,
|
||||||
about_point=self.about_point,
|
about_point=self.about_point,
|
||||||
|
about_edge=self.about_edge,
|
||||||
)
|
)
|
||||||
Transform.__init__(self, mobject, target, **kwargs)
|
return target
|
||||||
|
|
Loading…
Add table
Reference in a new issue