Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

New :class:`~.Mobject` method, :meth:`~.Mobject.get_midpoint` (#1234)

kolibril13894c7fe1f975
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index 4cff59d5a..8bb9e5424 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -1781,6 +1781,29 @@ class Mobject(Container):
index = np.argmax(np.dot(all_points, np.array(direction).T))
return all_points[index]
+ def get_midpoint(self) -> np.ndarray:
+ """Get coordinates of the middle of the path that forms the :class:`~.Mobject`.
+
+ Examples
+ --------
+
+ .. manim:: AngleMidPoint
+ :save_last_frame:
+
+ class AngleMidPoint(Scene):
+ def construct(self):
+ line1 = Line(ORIGIN, 2*RIGHT)
+ line2 = Line(ORIGIN, 2*RIGHT).rotate_about_origin(80*DEGREES)
+
+ a = Angle(line1, line2, radius=1.5, other_angle=False)
+ d = Dot(a.get_midpoint()).set_color(RED)
+
+ self.add(line1, line2, a, d)
+ self.wait()
+
+ """
+ return self.point_from_proportion(0.5)
+
def get_top(self) -> np.ndarray:
"""Get top coordinates of a box bounding the :class:`~.Mobject`"""
return self.get_edge_center(UP)