get_center ignoring submobjects

Question:

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?

Asked By: andpe

||

Answers:

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

>>> VMobject().set_points(v.points).get_center()
array([0., 0., 0.])
Answered By: Benjamin Hackl
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.