Skip to content

[Experimental] Make bounding_box=None if it can't be calculated and raise error on derived values such as get_center()#4555

Draft
chopan050 wants to merge 5 commits intoManimCommunity:experimentalfrom
chopan050:exp_bounding_box_none
Draft

[Experimental] Make bounding_box=None if it can't be calculated and raise error on derived values such as get_center()#4555
chopan050 wants to merge 5 commits intoManimCommunity:experimentalfrom
chopan050:exp_bounding_box_none

Conversation

@chopan050
Copy link
Contributor

@chopan050 chopan050 commented Jan 31, 2026

Currently, the bounding_box of an empty OpenGLMobject (a Mobject with no points and whose family also has no points) simply defaults to a 3x3 array of zeroes. This causes interesting side effects:

  • get_center(), get_corner(), get_edge()... all return ORIGIN
  • get_coord(), get_x(), get_y(), get_z()... all return 0
  • is_point_touching() returns True if the given point is close enough to ORIGIN and False if it's not, even though the point is in neither case really touching anything because the Mobject has no physical presence
  • mob.move_to(OpenGLVMobject()) moves mob to ORIGIN
  • Transform(mob, OpenGLVMobject()), while it expectedly shrinks mob until it disappears, also moves it to ORIGIN in the process
  • in general, an empty OpenGLMobject usually gets treated in the same way as an OpenGLMobject consisting of one or multiple points at ORIGIN, even though they're conceptually different and are, in other places, handled differently. Hypothetically, if we were to use PMobject and also work with bounding boxes, they would exhibit the same behavior.

This PR changes that. Now, an empty OpenGLMobject has a bounding_box of None, making it more different from an OpenGLMobject with points at ORIGIN. This allows handling the side effects in the following way:

  • get_center(), get_corner(), get_edge()... raise a RuntimeError because calculating a point makes no sense in these cases
  • get_coord(), get_x(), get_y(), get_z()... also raise a RuntimeError
  • is_point_touching() always returns False
  • mob.move_to(OpenGLVMobject()) does nothing
  • Transform(mob, OpenGLVMobject()) only shrinks mob until it disappears

…aise error on derived values such as get_center()
@chopan050 chopan050 marked this pull request as draft January 31, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant