Rotates the :class:`~.Mobject` around a specified axis and point. Parameters ---------- angle The angle of rotation in radians. Predefined constants such as ``DEGREES`` can also be used to specify the angle in degrees. axis The rot
(
self,
angle: float,
axis: Vector3DLike = OUT,
*,
about_point: Point3DLike | None = None,
about_edge: Vector3DLike | None = None,
)
| 1322 | return self.rotate(angle, axis, about_point=ORIGIN) |
| 1323 | |
| 1324 | def rotate( |
| 1325 | self, |
| 1326 | angle: float, |
| 1327 | axis: Vector3DLike = OUT, |
| 1328 | *, |
| 1329 | about_point: Point3DLike | None = None, |
| 1330 | about_edge: Vector3DLike | None = None, |
| 1331 | ) -> Self: |
| 1332 | """Rotates the :class:`~.Mobject` around a specified axis and point. |
| 1333 | |
| 1334 | Parameters |
| 1335 | ---------- |
| 1336 | angle |
| 1337 | The angle of rotation in radians. Predefined constants such as ``DEGREES`` |
| 1338 | can also be used to specify the angle in degrees. |
| 1339 | axis |
| 1340 | The rotation axis (see :class:`~.Rotating` for more). |
| 1341 | about_point |
| 1342 | The point about which the mobject rotates. If ``None``, rotation occurs around |
| 1343 | the center of the mobject. |
| 1344 | about_edge |
| 1345 | The edge about which to apply the scaling. |
| 1346 | |
| 1347 | Returns |
| 1348 | ------- |
| 1349 | :class:`Mobject` |
| 1350 | ``self`` (for method chaining) |
| 1351 | |
| 1352 | |
| 1353 | .. note:: |
| 1354 | To animate a rotation, use :class:`~.Rotating` or :class:`~.Rotate` |
| 1355 | instead of ``.animate.rotate(...)``. |
| 1356 | The ``.animate.rotate(...)`` syntax only applies a transformation |
| 1357 | from the initial state to the final rotated state |
| 1358 | (interpolation between the two states), without showing proper rotational motion |
| 1359 | based on the angle (from 0 to the given angle). |
| 1360 | |
| 1361 | Examples |
| 1362 | -------- |
| 1363 | |
| 1364 | .. manim:: RotateMethodExample |
| 1365 | :save_last_frame: |
| 1366 | |
| 1367 | class RotateMethodExample(Scene): |
| 1368 | def construct(self): |
| 1369 | circle = Circle(radius=1, color=BLUE) |
| 1370 | line = Line(start=ORIGIN, end=RIGHT) |
| 1371 | arrow1 = Arrow(start=ORIGIN, end=RIGHT, buff=0, color=GOLD) |
| 1372 | group1 = VGroup(circle, line, arrow1) |
| 1373 | |
| 1374 | group2 = group1.copy() |
| 1375 | arrow2 = group2[2] |
| 1376 | arrow2.rotate(angle=PI / 4, about_point=arrow2.get_start()) |
| 1377 | |
| 1378 | group3 = group1.copy() |
| 1379 | arrow3 = group3[2] |
| 1380 | arrow3.rotate(angle=120 * DEGREES, about_point=arrow3.get_start()) |
| 1381 |