Search code examples
pythonmanim

get_center ignoring submobjects


If I create a Dot and add (as a submobject) a label (Text mobject) above the dot and then call the get_center function, the center of the dot is moved because the function uses the submobjects to calculate the center of the mobject.

>>> v = Dot()
>>> v.get_center()
array([0., 0., 0.])
>>> v.add(Text('a').move_to(UP))
Dot
>>> v.get_center()
array([0. , 0.55121094, 0. ])

How can I get the center of the dot ignoring the submobjects?


Solution

  • A bit clunky, but it does what you are asking for:

    >>> VMobject().set_points(v.points).get_center()
    array([0., 0., 0.])