-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docstring for Mobject.rotate
and Rotating
class
#4147
Open
irvanalhaq9
wants to merge
20
commits into
ManimCommunity:main
Choose a base branch
from
irvanalhaq9:add-rotate-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+132
−5
Open
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7c61e16
Add docstring for Mobject.rotate
irvanalhaq9 1e129f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 750d721
Add docstring for Rotating class
irvanalhaq9 5c89706
Merge branch 'add-rotate-docs' of https://github.com/irvanalhaq9/mani…
irvanalhaq9 a5f7d95
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7909467
Add 'See also' in the docs
irvanalhaq9 e280aff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1086b7a
Improve 'See also' in the docs
irvanalhaq9 bb7990b
Improve 'See also' in the docs
irvanalhaq9 65ccf5c
Add .animate propery in 'See also' in the docs
irvanalhaq9 dee17bb
Add reference for rotate() method in .animate docs
irvanalhaq9 4ef7893
Improve 'seealso' in override_animate docs
irvanalhaq9 e5a7953
Merge branch 'main' into add-rotate-docs
irvanalhaq9 f7e2588
Remove wrong parameter 'angle' for Rotating class in add_updater example
irvanalhaq9 5849201
Add example for 3D rotation by Rotating class
irvanalhaq9 40e8c5d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] be27667
Change line2d to arrow2d
irvanalhaq9 da71bd0
Add Rotate, rotate, .animate in 'See also' add_updater, and add add_u…
irvanalhaq9 e5aadf0
Add description for axis parameter in Rotating class, like Mobject.ro…
irvanalhaq9 f4987d8
Improve description for axis parameter in Mobject.rotate
irvanalhaq9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -387,7 +387,7 @@ def construct(self): | |
will interpolate the :class:`~.Mobject` between its points prior to | ||
``.animate`` and its points after applying ``.animate`` to it. This may | ||
result in unexpected behavior when attempting to interpolate along paths, | ||
or rotations. | ||
or rotations (see :meth:`.rotate`). | ||
If you want animations to consider the points between, consider using | ||
:class:`~.ValueTracker` with updaters instead. | ||
|
||
|
@@ -1011,7 +1011,7 @@ def dot_position(mobject): | |
label.add_updater(dot_position) | ||
self.add(dot, label) | ||
|
||
self.play(Rotating(dot, about_point=ORIGIN, angle=TAU, run_time=TAU, rate_func=linear)) | ||
self.play(Rotating(dot, about_point=ORIGIN, radians=TAU, run_time=TAU, rate_func=linear)) | ||
|
||
.. manim:: DtUpdater | ||
|
||
|
@@ -1282,7 +1282,67 @@ def rotate( | |
about_point: Point3DLike | None = None, | ||
**kwargs, | ||
) -> Self: | ||
"""Rotates the :class:`~.Mobject` about a certain point.""" | ||
"""Rotates the :class:`~.Mobject` around a specified axis and point. | ||
|
||
The rotation is counterclockwise by the given ``angle`` (following the right-hand rule). | ||
|
||
.. note:: | ||
To animate a rotation, use :class:`~.Rotating` or :class:`~.Rotate` | ||
instead of ``.animate.rotate(...)``. | ||
The ``.animate.rotate(...)`` syntax only applies a transformation | ||
from the initial state to the final rotated state | ||
(interpolation between the two states), without showing proper rotational motion | ||
based on the angle (from 0 to the given angle). | ||
|
||
Parameters | ||
---------- | ||
angle | ||
The angle of rotation in radians. Predefined constants such as ``DEGREES`` | ||
can also be used to specify the angle in degrees. | ||
For example, ``PI`` (180 degrees) or ``120 * DEGREES`` (120 degrees). | ||
axis | ||
Rotation axis (3D vector). Defaults to ``OUT`` (z-axis), producing 2D rotations | ||
perpendicular to the screen. Use other axes (e.g., ``UP``) for 3D rotations. | ||
about_point | ||
The point about which the mobject rotates. If ``None``, rotation occurs around | ||
the center of the mobject. | ||
**kwargs | ||
Additional keyword arguments passed to :meth:`apply_points_function_about_point`, | ||
such as ``about_edge``. | ||
|
||
Returns | ||
------- | ||
:class:`Mobject` | ||
``self`` (for method chaining) | ||
|
||
Examples | ||
-------- | ||
|
||
.. manim:: RotateMethodExample | ||
:save_last_frame: | ||
|
||
class RotateMethodExample(Scene): | ||
def construct(self): | ||
circle = Circle(radius=1, color=BLUE) | ||
line = Line(start=ORIGIN, end=RIGHT) | ||
arrow1 = Arrow(start=ORIGIN, end=RIGHT, buff=0, color=GOLD) | ||
group1 = VGroup(circle, line, arrow1) | ||
|
||
group2 = group1.copy() | ||
arrow2 = group2[2] | ||
arrow2.rotate(angle=PI / 4, about_point=arrow2.get_start()) | ||
|
||
group3 = group1.copy() | ||
arrow3 = group3[2] | ||
arrow3.rotate(angle=111 * DEGREES, about_point=arrow3.get_start()) | ||
|
||
self.add(VGroup(group1, group2, group3).arrange(RIGHT, buff=1)) | ||
|
||
See also | ||
-------- | ||
:class:`~.Rotating`, :class:`~.Rotate`, :attr:`~.Mobject.animate`, :meth:`apply_points_function_about_point` | ||
|
||
""" | ||
rot_matrix = rotation_matrix(angle, axis) | ||
self.apply_points_function_about_point( | ||
lambda points: np.dot(points, rot_matrix.T), about_point, **kwargs | ||
|
@@ -3143,7 +3203,7 @@ def override_animate(method) -> types.FunctionType: | |
|
||
.. seealso:: | ||
|
||
:attr:`Mobject.animate` | ||
:attr:`~.Mobject.animate` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a tilde ( |
||
.. note:: | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes an incorrect
parameter
in the documentation example ofadd_updater
. TheRotating
class usesradians
instead ofangle
as its parameter.