Move mobject positioning methods into own class - #4944
Draft
GniLudio wants to merge 69 commits into
Draft
Conversation
GniLudio
marked this pull request as draft
August 19, 2026 22:30
GniLudio
marked this pull request as draft
August 25, 2026 09:19
GniLudio
marked this pull request as ready for review
August 28, 2026 11:36
GniLudio
marked this pull request as draft
August 30, 2026 09:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview: What does this pull request change?
Moves the
Mobjectpositioning methods into their own class. Additionally, cleans up a lot of implementations.Motivation and Explanation: Why and how do your changes improve the library?
Key Changes
Structure
A brief overview of the class structure:
Deprecations
There are several methods that were renamed or have more powerful alternatives now. For compatibility reason, they are redirect to the renamed/alternative method marked as deprecated for now. For some of these it probably makes sense to have the redirect without deprecating them, like
move_toandshift.Feel free to make suggestions...
List
set_position(function(self.get_position()))apply_array_function(get|set)_depthget_positionget_coordinateget_positionget_position(get|set)_heightget_dim_sizeset_coordset_dim_sizeset_depthset_pointsset_xset_yset_zset_widthset_heightset_positionrotateset_dim_sizeset_coordinatetranslatestretchalign_on_borderalign_on_border(get|set)_widthTODOs
next_tomethod belongs also insidePositionable, but the implementation requires access to the submobjects. Feel free to make suggestions on how to handle this.PositionableforOpenGLMobjectin a following PR, so that the diff of this PR stays reasonable.Test & Benchmark
I used randomized testing to ensure that no behavior was modified. The test succeeds for all (tested) methods and outputs a speed comparison.
These speedups are a nice to have, but are hardly noticeable in real-world use-cases. For example the Lissajous benchmark got less than a 1% speedup (521s -> 517s). The only significant change is the improvements to
length_over_dim(and the width/height/depth respectively) on mobjects with a very large amount of points.To run the test yourself, switch to the main branch, download the positionable.py and test.py and run the
test.py.Reviewer Checklist