Refactored line.py file#4752
Open
GoThrones wants to merge 8 commits into
Open
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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?
The changes of this PR are completely backwards compatible.
This PR makes following changes:
(1) In Line class, modified the _pointify method to convert 2D points to 3D points. This will work for all subclass of Line.
(2) In Arrow class, added explicit start, end, and tip_shape parameters in init, while maintaining full backwards compatibility via *args.
(3) In DoubleArrow class, added explicit start, end, tip_shape_at_start, tip_shape_at_end parameters. Also, this PR renames tip_shape_start/tip_shape_end to tip_shape_at_start/tip_shape_at_end with deprecation warnings for the old names.
tip_shape_start/end gives the impression that it's the starting point of the tip itself, not that of the mobject to which the tip is attached.
(4) In Vector class, improved the init with better parameter handling and refactored the coordinate_label method supporting both start and end labels. Also, the positioning of labels has been improved, which is can be seen in this video below. In the main branch, there is only end label, and no provision of start label. Also, in the main branch, if the Vector is rotating, then the labels jump suddenly, when the vector points towards negative direction from positive direction, and vice-a-versa.
Here's the code, which i used to demonstrate this:
This video is from the PR branch. In the video, the Matrix box is flickering because it's size is not constant throughout, and that is because of the + or - sign before the numbers in addition to the width of the numbers themselves. But in main branch, the matrix box itself was shifting from right to left or from left to right, because of the code. So that caused sudden jump in the box's position, in addition to the existing flicker due to + or - sign before the numbers. Jumping of the box itself has been cured by this PR.
VectorCoordinateLabel1.mp4
(5) Some minor modifications in VectorScene class.
(6) The reference frame for test_vector_to_coords was regenerated because the improved coordinate_label method of Vector class, positions the coordinate label differently from the original implementation. The new positioning places the label along the vector's direction using buff and buff_multiplier, which is more geometrically correct than the original approach which only checked whether the vector was pointing left or right.
Motivation and Explanation: Why and how do your changes improve the library?
The Arrow class, Vector class, DoubleArrowClass etc, didn't had explicit parameters start, end, tip shape, etc.
Further Information and Comments
Reviewer Checklist