2018-12-24 12:37:51 -08:00
|
|
|
from manimlib.animation.animation import Animation
|
|
|
|
from manimlib.animation.transform import Transform
|
2019-02-09 15:48:36 -08:00
|
|
|
from manimlib.constants import OUT
|
|
|
|
from manimlib.constants import PI
|
|
|
|
from manimlib.constants import TAU
|
2019-02-05 15:39:58 -08:00
|
|
|
from manimlib.utils.rate_functions import linear
|
2018-03-31 15:11:35 -07:00
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-31 15:11:35 -07:00
|
|
|
class Rotating(Animation):
|
|
|
|
CONFIG = {
|
2018-04-06 13:58:59 -07:00
|
|
|
"axis": OUT,
|
2018-04-10 19:47:41 -07:00
|
|
|
"radians": TAU,
|
2018-04-06 13:58:59 -07:00
|
|
|
"run_time": 5,
|
2019-02-05 15:39:58 -08:00
|
|
|
"rate_func": linear,
|
2018-04-06 13:58:59 -07:00
|
|
|
"about_point": None,
|
|
|
|
"about_edge": None,
|
2018-03-31 15:11:35 -07:00
|
|
|
}
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2019-02-08 11:57:27 -08:00
|
|
|
def interpolate_mobject(self, alpha):
|
2019-02-09 15:48:36 -08:00
|
|
|
self.mobject.become(self.starting_mobject)
|
2018-03-31 15:11:35 -07:00
|
|
|
self.mobject.rotate(
|
2018-04-06 13:58:59 -07:00
|
|
|
alpha * self.radians,
|
|
|
|
axis=self.axis,
|
|
|
|
about_point=self.about_point,
|
|
|
|
about_edge=self.about_edge,
|
2018-03-31 15:11:35 -07:00
|
|
|
)
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-31 15:11:35 -07:00
|
|
|
class Rotate(Transform):
|
|
|
|
CONFIG = {
|
2018-04-06 13:58:59 -07:00
|
|
|
"about_point": None,
|
2019-02-09 15:48:36 -08:00
|
|
|
"about_edge": None,
|
2018-03-31 15:11:35 -07:00
|
|
|
}
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2019-02-09 15:48:36 -08:00
|
|
|
def __init__(self, mobject, angle=PI, axis=OUT, **kwargs):
|
2018-03-31 15:11:35 -07:00
|
|
|
if "path_arc" not in kwargs:
|
|
|
|
kwargs["path_arc"] = angle
|
|
|
|
if "path_arc_axis" not in kwargs:
|
|
|
|
kwargs["path_arc_axis"] = axis
|
2019-02-09 15:48:36 -08:00
|
|
|
self.angle = angle
|
|
|
|
self.axis = axis
|
|
|
|
super().__init__(mobject, **kwargs)
|
|
|
|
|
|
|
|
def create_target(self):
|
|
|
|
target = self.mobject.copy()
|
2018-03-31 15:11:35 -07:00
|
|
|
target.rotate(
|
2019-02-09 15:48:36 -08:00
|
|
|
self.angle,
|
|
|
|
axis=self.axis,
|
2018-04-06 13:58:59 -07:00
|
|
|
about_point=self.about_point,
|
2019-02-09 15:48:36 -08:00
|
|
|
about_edge=self.about_edge,
|
2018-03-31 15:11:35 -07:00
|
|
|
)
|
2019-02-09 15:48:36 -08:00
|
|
|
return target
|