Skip to content

Conversation

@Morkunas
Copy link

Overview: What does this pull request change?

Fixes issue #4445.
Fix about_point view mutation in apply_points_function_about_point

When about_point parameter receives a numpy array view (e.g., from
get_vertices()[0]), the in-place operation mob.points -= about_point
would mutate the view, corrupting the transformation calculation.

This fix copies about_point before using it to prevent view mutation

Motivation and Explanation: Why and how do your changes improve the library?

Bugfix.

Links to added or changed documentation pages

Not applicable

Further Information and Comments

Not applicable.

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

This adds regression tests for issue ManimCommunity#4445 where using get_vertices()[0]
as about_point in transformation methods would cause incorrect results
due to numpy array view mutation.

Tests added:
- test_rotate_about_vertex_view
- test_scale_about_vertex_view
- test_stretch_about_vertex_view
- test_apply_matrix_about_vertex_view
- test_opengl_rotate_about_vertex_view (OpenGL was not affected by the bug)

Related to ManimCommunity#4445
When about_point parameter receives a numpy array view (e.g., from
get_vertices()[0]), the in-place operation `mob.points -= about_point`
would mutate the view, corrupting the transformation calculation.

This fix copies about_point before using it to prevent view mutation.

The OpenGL renderer was not affected by this bug because it uses
`arr - about_point` (creates temporary) instead of `arr -= about_point`
(mutates in-place).

Fixes ManimCommunity#4445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

1 participant