Skip to content

Commit 894c7fe

Browse files
kolibril13jsonvillanuevapre-commit-ci[bot]behackl
authored
New :class:~.Mobject method, :meth:~.Mobject.get_midpoint (#1234)
* implemented get_midpoint * Update manim/mobject/mobject.py * Update manim/mobject/mobject.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update manim/mobject/mobject.py Co-authored-by: Benjamin Hackl <[email protected]> * Update manim/mobject/mobject.py Co-authored-by: Benjamin Hackl <[email protected]> Co-authored-by: Jason Villanueva <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Benjamin Hackl <[email protected]>
1 parent 401355c commit 894c7fe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

manim/mobject/mobject.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,29 @@ def get_boundary_point(self, direction):
17811781
index = np.argmax(np.dot(all_points, np.array(direction).T))
17821782
return all_points[index]
17831783

1784+
def get_midpoint(self) -> np.ndarray:
1785+
"""Get coordinates of the middle of the path that forms the :class:`~.Mobject`.
1786+
1787+
Examples
1788+
--------
1789+
1790+
.. manim:: AngleMidPoint
1791+
:save_last_frame:
1792+
1793+
class AngleMidPoint(Scene):
1794+
def construct(self):
1795+
line1 = Line(ORIGIN, 2*RIGHT)
1796+
line2 = Line(ORIGIN, 2*RIGHT).rotate_about_origin(80*DEGREES)
1797+
1798+
a = Angle(line1, line2, radius=1.5, other_angle=False)
1799+
d = Dot(a.get_midpoint()).set_color(RED)
1800+
1801+
self.add(line1, line2, a, d)
1802+
self.wait()
1803+
1804+
"""
1805+
return self.point_from_proportion(0.5)
1806+
17841807
def get_top(self) -> np.ndarray:
17851808
"""Get top coordinates of a box bounding the :class:`~.Mobject`"""
17861809
return self.get_edge_center(UP)

0 commit comments

Comments
 (0)