Skip to content

Commit 7c61e16

Browse files
committed
Add docstring for Mobject.rotate
1 parent d521bc9 commit 7c61e16

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

manim/mobject/mobject.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,67 @@ def rotate(
12821282
about_point: Point3DLike | None = None,
12831283
**kwargs,
12841284
) -> Self:
1285-
"""Rotates the :class:`~.Mobject` about a certain point."""
1285+
"""Rotates the :class:`~.Mobject` around a specified axis and point.
1286+
1287+
The rotation is counterclockwise by the given ``angle`` (following the right-hand rule).
1288+
1289+
.. note::
1290+
To animate a rotation, use :class:`~.Rotating` or :class:`~.Rotate`
1291+
instead of ``.animate.rotate(...)``.
1292+
The ``.animate.rotate(...)`` method only applies a transformation
1293+
from the initial state to the final rotated state
1294+
(interpolation between the two states), without showing proper rotational motion
1295+
based on the angle (from 0 to the given angle).
1296+
1297+
Parameters
1298+
----------
1299+
angle
1300+
The angle of rotation in radians. Predefined constants such as ``DEGREES``
1301+
can also be used to specify the angle in degrees.
1302+
For example, ``PI`` (180 degrees) or ``120 * DEGREES`` (120 degrees).
1303+
axis
1304+
Rotation axis (3D vector). Defaults to ``OUT`` (z-axis), producing 2D rotations
1305+
perpendicular to the screen. Use other axes (e.g., ``UP``) for 3D rotations.
1306+
about_point
1307+
The point about which the mobject rotates. If ``None``, rotation occurs around
1308+
the center of the mobject.
1309+
**kwargs
1310+
Additional keyword arguments passed to :meth:`apply_points_function_about_point`,
1311+
such as ``about_edge``.
1312+
1313+
Returns
1314+
-------
1315+
:class:`Mobject`
1316+
``self`` (for method chaining)
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=111 * 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`, :meth:`apply_matrix`, :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

0 commit comments

Comments
 (0)