Skip to content

Commit 82a186c

Browse files
committed
Add docstring for .rotate() and related See (also) in Mobject
1 parent 3c6a1ee commit 82a186c

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

manim/mobject/mobject.py

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ def construct(self):
387387
will interpolate the :class:`~.Mobject` between its points prior to
388388
``.animate`` and its points after applying ``.animate`` to it. This may
389389
result in unexpected behavior when attempting to interpolate along paths,
390-
or rotations.
390+
or rotations (see :meth:`.rotate`).
391391
If you want animations to consider the points between, consider using
392-
:class:`~.ValueTracker` with updaters instead.
392+
:class:`~.ValueTracker` with updaters instead (see :meth:`.add_updater`).
393393
394394
"""
395395
return _AnimationBuilder(self)
@@ -1029,6 +1029,9 @@ def construct(self):
10291029
:meth:`get_updaters`
10301030
:meth:`remove_updater`
10311031
:class:`~.UpdateFromFunc`
1032+
:class:`~.Rotating`
1033+
:meth:`rotate`
1034+
:attr:`~.Mobject.animate`
10321035
"""
10331036
if index is None:
10341037
self.updaters.append(update_function)
@@ -1282,7 +1285,64 @@ def rotate(
12821285
about_point: Point3DLike | None = None,
12831286
**kwargs,
12841287
) -> Self:
1285-
"""Rotates the :class:`~.Mobject` about a certain point."""
1288+
"""Rotates the :class:`~.Mobject` around a specified axis and point.
1289+
1290+
Parameters
1291+
----------
1292+
angle
1293+
The angle of rotation in radians. Predefined constants such as ``DEGREES``
1294+
can also be used to specify the angle in degrees.
1295+
axis
1296+
The rotation axis (see :class:`~.Rotating` for more).
1297+
about_point
1298+
The point about which the mobject rotates. If ``None``, rotation occurs around
1299+
the center of the mobject.
1300+
**kwargs
1301+
Additional keyword arguments passed to :meth:`apply_points_function_about_point`,
1302+
such as ``about_edge``.
1303+
1304+
Returns
1305+
-------
1306+
:class:`Mobject`
1307+
``self`` (for method chaining)
1308+
1309+
1310+
.. note::
1311+
To animate a rotation, use :class:`~.Rotating` or :class:`~.Rotate`
1312+
instead of ``.animate.rotate(...)``.
1313+
The ``.animate.rotate(...)`` syntax only applies a transformation
1314+
from the initial state to the final rotated state
1315+
(interpolation between the two states), without showing proper rotational motion
1316+
based on the angle (from 0 to the given angle).
1317+
1318+
Examples
1319+
--------
1320+
1321+
.. manim:: RotateMethodExample
1322+
:save_last_frame:
1323+
1324+
class RotateMethodExample(Scene):
1325+
def construct(self):
1326+
circle = Circle(radius=1, color=BLUE)
1327+
line = Line(start=ORIGIN, end=RIGHT)
1328+
arrow1 = Arrow(start=ORIGIN, end=RIGHT, buff=0, color=GOLD)
1329+
group1 = VGroup(circle, line, arrow1)
1330+
1331+
group2 = group1.copy()
1332+
arrow2 = group2[2]
1333+
arrow2.rotate(angle=PI / 4, about_point=arrow2.get_start())
1334+
1335+
group3 = group1.copy()
1336+
arrow3 = group3[2]
1337+
arrow3.rotate(angle=120 * DEGREES, about_point=arrow3.get_start())
1338+
1339+
self.add(VGroup(group1, group2, group3).arrange(RIGHT, buff=1))
1340+
1341+
See also
1342+
--------
1343+
:class:`~.Rotating`, :class:`~.Rotate`, :attr:`~.Mobject.animate`, :meth:`apply_points_function_about_point`
1344+
1345+
"""
12861346
rot_matrix = rotation_matrix(angle, axis)
12871347
self.apply_points_function_about_point(
12881348
lambda points: np.dot(points, rot_matrix.T), about_point, **kwargs
@@ -3143,7 +3203,7 @@ def override_animate(method) -> types.FunctionType:
31433203
31443204
.. seealso::
31453205
3146-
:attr:`Mobject.animate`
3206+
:attr:`~.Mobject.animate`
31473207
31483208
.. note::
31493209

0 commit comments

Comments
 (0)