Fix Line.add_tip() distorting polyline paths#4650
Open
BrightonXX wants to merge 1 commit intoManimCommunity:mainfrom
Open
Fix Line.add_tip() distorting polyline paths#4650BrightonXX wants to merge 1 commit intoManimCommunity:mainfrom
BrightonXX wants to merge 1 commit intoManimCommunity:mainfrom
Conversation
0876b68 to
a41aba2
Compare
Contributor
|
in the fixed add_tip() situation: shouldn't the arrowhead generate at the end of the line, right after crossing the red dot. |
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.
Fixes #4444
Overview: What does this pull request change?
This PR fixes a geometry bug in
Line.add_tip()/OpenGLLine.add_tip()when working with polylines created viaset_points_as_corners(...), as reported in #4444 by @tobiasBora.Before this patch, adding a tip shortened the path by resetting the whole line's start and end points. That behavior is fine for a single straight segment, but for multi-segment polylines it remaps the entire path and shifts interior corners.
With this patch, plain
Line/OpenGLLinepaths withpath_arc == 0trim only the first or last boundary segment to the tip base, so the existing elbow geometry stays intact.Motivation and Explanation: Why and how do your changes improve the library?
An example is:
Expected behavior:
(-3, 1, 0)stays fixedActual behavior before this patch:
To fix this,
LineandOpenGLLinenow trim only the boundary segment whenpath_arc == 0, while other cases still fall back to the existing generic implementation.I also added regression tests covering both end tips and start tips preserving the polyline corner.
Links to added or changed documentation pages
No documentation pages were changed.
Further Information and Comments
Local tests run:
python -m pytest -o addopts='' tests/module/mobject/geometry/test_unit_geometry.py -qI also ran targeted checks locally for:
Arrow/DoubleArrowLinepath_arc != 0OpenGLLineVisual comparison:
The red dot marks the intended elbow corner. Before this patch,
add_tip()remaps the whole polyline when shortening it for the tip. After the patch, the corner stays fixed and only the boundary segment is trimmed.Animated comparison video:
Issue4444Animated.mp4
Reviewer Checklist