Skip to content

Commit 5017a49

Browse files
kolibril13abhijithmuthyalapre-commit-ci[bot]
authored
Add parameter about_point for rotate (#1238)
* about_point parameter for rotate * Update manim/mobject/mobject.py * Update manim/mobject/mobject.py Co-authored-by: Abhijith Muthyala <[email protected]> * added about_point to opengl_mobject.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Abhijith Muthyala <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9a525a8 commit 5017a49

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

manim/mobject/mobject.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,18 +1055,24 @@ def rotate_about_origin(self, angle, axis=OUT, axes=[]):
10551055
"""Rotates the :class:`~.Mobject` about the ORIGIN, which is at [0,0,0]."""
10561056
return self.rotate(angle, axis, about_point=ORIGIN)
10571057

1058-
def rotate(self, angle, axis=OUT, **kwargs):
1058+
def rotate(
1059+
self,
1060+
angle,
1061+
axis=OUT,
1062+
about_point: Union[np.ndarray, List, None] = None,
1063+
**kwargs,
1064+
):
10591065
"""Rotates the :class:`~.Mobject` about a certain point."""
10601066
if config.renderer == "opengl":
10611067
rot_matrix_T = rotation_matrix_transpose(angle, axis)
10621068
self.apply_points_function(
1063-
lambda points: np.dot(points, rot_matrix_T), **kwargs
1069+
lambda points: np.dot(points, rot_matrix_T), about_point, **kwargs
10641070
)
10651071
return self
10661072
else:
10671073
rot_matrix = rotation_matrix(angle, axis)
10681074
self.apply_points_function_about_point(
1069-
lambda points: np.dot(points, rot_matrix.T), **kwargs
1075+
lambda points: np.dot(points, rot_matrix.T), about_point, **kwargs
10701076
)
10711077
return self
10721078

manim/mobject/opengl_mobject.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import random
44
import sys
55
from functools import wraps
6+
from typing import List, Union
67

78
import moderngl
89
import numpy as np
@@ -56,7 +57,7 @@ def __init__(
5657
# Must match in attributes of vert shader
5758
# Event listener
5859
listen_to_events=False,
59-
**kwargs
60+
**kwargs,
6061
):
6162

6263
self.color = color
@@ -614,7 +615,13 @@ def func(points):
614615
def rotate_about_origin(self, angle, axis=OUT):
615616
return self.rotate(angle, axis, about_point=ORIGIN)
616617

617-
def rotate(self, angle, axis=OUT, **kwargs):
618+
def rotate(
619+
self,
620+
angle,
621+
axis=OUT,
622+
about_point: Union[np.ndarray, List, None] = None,
623+
**kwargs,
624+
):
618625
rot_matrix_T = rotation_matrix_transpose(angle, axis)
619626
self.apply_points_function(
620627
lambda points: np.dot(points, rot_matrix_T), **kwargs
@@ -1404,7 +1411,7 @@ def get_shader_wrapper(self):
14041411
def get_shader_wrapper_list(self):
14051412
shader_wrappers = it.chain(
14061413
[self.get_shader_wrapper()],
1407-
*[sm.get_shader_wrapper_list() for sm in self.submobjects]
1414+
*[sm.get_shader_wrapper_list() for sm in self.submobjects],
14081415
)
14091416
batches = batch_by_property(shader_wrappers, lambda sw: sw.get_id())
14101417

0 commit comments

Comments
 (0)