Rework positioning - #4944
Draft
GniLudio wants to merge 14 commits into
Draft
Conversation
GniLudio
marked this pull request as draft
August 19, 2026 22:30
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?
Cleans up and moves the positioning methods from
Mobjectinto a separate class.This PR is still work in progress. Opened already, so I can get some feedback on the
Positionableclass.PR #4923 was a proof of concept for this.
Motivation and Explanation: Why and how do your changes improve the library?
Discussion
Mobjects with no points
Should the methods have explicit handling for mobjects with no points?
Matching methods
Currently, setters always have a separate
match_*method to replicate another mobject. Instead of declaring separate methods, it would be quite easy to integrate that directly into the setter methods. Themove_tomethod already does it that way, as there isn't amatch_positionmethod.In-between critical points
Currently,
get_critical_pointis restricted bynp.sign(direction), as that preserves the old behavior.Is there a reason to keep that restriction?
Without the restriction, things like
get_critical_point(0.5*DL)and `get_critical_point(2*RIGHT) would be possible.Hierarchy
This is the current method hierarchy. Any suggestions on how to improve this?
Excluding deprecated methods
Including deprecated methods
Further Information and Comments
Test
The
test.pychecks whether any method behavior differs between theMobjectandPositionableclass.The test can be run using
python test.py.Changes
Surprisingly, cleaning up the implementations made all methods faster.
But keep in mind that the test is completely randomized and only includes up to 100 points.
align_on_borderframeparameteralign_toapply_array_functionreplacement for
apply_points_function_about_pointapply_complex_functionapply_functionapply_function_to_positionmove_to(function(self.get_center()))insteadapply_matrixapply_points_function_about_pointapply_array_functioninsteadcenterdepthget_depthinsteaddepthset_depthinsteadflipget_bottomget_boundary_pointget_bounding_boxget_centerget_center_of_massget_coordget_cornerget_critical_pointinsteadget_critical_pointget_depthdepthget_dim_sizeget_edge_centerget_critical_pointinsteadget_extremum_along_dimget_heightheightget_leftget_nadirget_rightget_topget_widthwidthget_xget_yget_zget_zenithheightget_heightinsteadheightset_heightinsteadis_off_screenlength_over_dimget_dim_sizeinsteadmatch_coordmatch_depthmatch_dim_sizematch_heightmatch_pointscopy_submobjectsparametermatch_widthmatch_xmatch_ymatch_zmove_tonext_topose_at_anglemade kwargs explicit
reduce_across_dimensionrescale_to_fitrotaterotate_about_originrotateinsteadscalescale_to_fitscale_to_fit_depthscale_to_fit_heightscale_to_fit_widthset_coordset_depthdepthset_dim_sizerescale_to_fitset_heightheightset_widthwidthset_xset_yset_zshift*vectorstovectorshift_onto_screenstretchstretch_about_pointstretchinsteadstretch_to_fitstretch_to_fit_depthstretch_to_fit_heightstretch_to_fit_widthto_cornerto_edgewidthget_widthinsteadwidthset_widthinsteadReviewer Checklist