Skip to content

Commit 58fce57

Browse files
committed
Add docstring for .rotate() and related See (also) in Mobject
1 parent 7edb2c3 commit 58fce57

File tree

2 files changed

+5
-75
lines changed

2 files changed

+5
-75
lines changed

docs/source/examples.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ Animations
299299
path.become(previous_path)
300300
path.add_updater(update_path)
301301
self.add(path, dot)
302-
self.play(Rotating(dot, angle=PI, about_point=RIGHT, run_time=2))
302+
self.play(Rotating(dot, radians=PI, about_point=RIGHT, run_time=2))
303303
self.wait()
304304
self.play(dot.animate.shift(UP))
305305
self.play(dot.animate.shift(LEFT))

manim/animation/rotation.py

+4-74
Original file line numberDiff line numberDiff line change
@@ -19,93 +19,27 @@
1919

2020

2121
class Rotating(Animation):
22-
"""Animation that rotates a Mobject.
23-
24-
Parameters
25-
----------
26-
mobject
27-
The mobject to be rotated.
28-
angle
29-
The rotation angle in radians. Predefined constants such as ``DEGREES``
30-
can also be used to specify the angle in degrees.
31-
axis
32-
The rotation axis as a numpy vector.
33-
about_point
34-
The rotation center.
35-
about_edge
36-
If ``about_point`` is ``None``, this argument specifies
37-
the direction of the bounding box point to be taken as
38-
the rotation center.
39-
run_time
40-
The duration of the animation in seconds.
41-
rate_func
42-
The function defining the animation progress based on the relative
43-
runtime (see :mod:`~.rate_functions`) .
44-
**kwargs
45-
Additional keyword arguments passed to :class:`~.Animation`.
46-
47-
Examples
48-
--------
49-
.. manim:: RotatingDemo
50-
51-
class RotatingDemo(Scene):
52-
def construct(self):
53-
circle = Circle(radius=1, color=BLUE)
54-
line = Line(start=ORIGIN, end=RIGHT)
55-
arrow = Arrow(start=ORIGIN, end=RIGHT, buff=0, color=GOLD)
56-
vg = VGroup(circle,line,arrow)
57-
self.add(vg)
58-
anim_kw = {"about_point": arrow.get_start(), "run_time": 1}
59-
self.play(Rotating(arrow, 180*DEGREES, **anim_kw))
60-
self.play(Rotating(arrow, PI, **anim_kw))
61-
self.play(Rotating(vg, PI, about_point=RIGHT))
62-
self.play(Rotating(vg, PI, axis=UP, about_point=ORIGIN))
63-
self.play(Rotating(vg, PI, axis=RIGHT, about_edge=UP))
64-
self.play(vg.animate.move_to(ORIGIN))
65-
66-
.. manim:: RotatingDifferentAxis
67-
68-
class RotatingDifferentAxis(ThreeDScene):
69-
def construct(self):
70-
axes = ThreeDAxes()
71-
cube = Cube()
72-
arrow2d = Arrow(start=[0, -1.2, 1], end=[0, 1.2, 1], color=YELLOW_E)
73-
cube_group = VGroup(cube,arrow2d)
74-
self.set_camera_orientation(gamma=0, phi=40*DEGREES, theta=40*DEGREES)
75-
self.add(axes, cube_group)
76-
play_kw = {"run_time": 1.5}
77-
self.play(Rotating(cube_group, PI), **play_kw)
78-
self.play(Rotating(cube_group, PI, axis=UP), **play_kw)
79-
self.play(Rotating(cube_group, 180*DEGREES, axis=RIGHT), **play_kw)
80-
self.wait(0.5)
81-
82-
See also
83-
--------
84-
:class:`~.Rotate`, :meth:`~.Mobject.rotate`
85-
86-
"""
87-
8822
def __init__(
8923
self,
9024
mobject: Mobject,
91-
angle: np.ndarray = TAU,
9225
axis: np.ndarray = OUT,
26+
radians: np.ndarray = TAU,
9327
about_point: np.ndarray | None = None,
9428
about_edge: np.ndarray | None = None,
95-
run_time: float = 2,
29+
run_time: float = 5,
9630
rate_func: Callable[[float], float] = linear,
9731
**kwargs,
9832
) -> None:
9933
self.axis = axis
100-
self.angle = angle
34+
self.radians = radians
10135
self.about_point = about_point
10236
self.about_edge = about_edge
10337
super().__init__(mobject, run_time=run_time, rate_func=rate_func, **kwargs)
10438

10539
def interpolate_mobject(self, alpha: float) -> None:
10640
self.mobject.become(self.starting_mobject)
10741
self.mobject.rotate(
108-
self.rate_func(alpha) * self.angle,
42+
self.rate_func(alpha) * self.radians,
10943
axis=self.axis,
11044
about_point=self.about_point,
11145
about_edge=self.about_edge,
@@ -146,10 +80,6 @@ def construct(self):
14680
Rotate(Square(side_length=0.5), angle=2*PI, rate_func=linear),
14781
)
14882
149-
See also
150-
--------
151-
:class:`~.Rotating`, :meth:`~.Mobject.rotate`
152-
15383
"""
15484

15585
def __init__(

0 commit comments

Comments
 (0)