-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimized manim.utils.bezier.get_smooth_cubic_bezier_handle_points()
#3767
Optimized manim.utils.bezier.get_smooth_cubic_bezier_handle_points()
#3767
Conversation
manim.utils.get_smooth_cubic_bezier_handle_points()
manim.utils.bezier.get_smooth_cubic_bezier_handle_points()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes look good to me - it's nice to have doc strings for more Bézier stuff as well :)
I did notice we don't have any tests for get_smooth_cubic_bezier_handle_points
, so it would be a good idea to add tests for the three functions you added :)
…ptimize-get-smooth-cubic-handles
I just added some tests :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Co-authored-by: adeshpande <[email protected]>
Overview: What does this pull request change?
Related PR: #3281
get_smooth_cubic_bezier_handle_points()
get_smooth_cubic_bezier_handle_points_for_open_curve()
andget_smooth_cubic_bezier_handle_points_for_closed_curve()
get_smooth_handle_points()
functiondiag_to_matrix()
and thescipy
importMotivation and Explanation: Why and how do your changes improve the library?
I had a test scene with more than 100 ParametricFunctions in it, which were all being updated. More than half of the render time was spent on
ParametricFunction.generate_points()
, and one of the 3 main culprits wasVMobject.make_smooth()
, which made slow calls toget_smooth_handle_points()
.The main bottleneck for this function is the call to
scipy.linalg.solve_banded()
. Apparently, it spends more time validating the arrays passed as a parameter, than actually solving the system of equations.That's why I decided to manually implement the algorithm for solving these equations. But also, all the matrices follow the same pattern and their coefficients are pretty much always the same, varying only in size, so the diagonals can be hardcoded in the algorithm rather than stored explicitly. Some of them can even be memoized, which is what I did.
Links to added or changed documentation pages
Further Information and Comments
Reviewer Checklist