Skip to content

Conversation

@Morkunas
Copy link
Contributor

@Morkunas Morkunas commented Nov 15, 2025

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
@henrikmidtiby henrikmidtiby added the pr:bugfix Bug fix for use in PRs solving a specific issue:bug label Nov 16, 2025
@henrikmidtiby henrikmidtiby changed the title Prevent mutation of about_point views in apply_points_function_about_point Fixes #4445 Prevent mutation of about_point in apply_points_function_about_point - Fixes #4445 Nov 16, 2025
Copy link
Contributor

@henrikmidtiby henrikmidtiby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR with relevant test cases and a solution to the problem.

LGTM!

@github-project-automation github-project-automation bot moved this from 🆕 New to 👍 To be merged in Dev Board Nov 16, 2025
@henrikmidtiby henrikmidtiby merged commit 7e950b3 into ManimCommunity:main Nov 16, 2025
25 checks passed
@github-project-automation github-project-automation bot moved this from 👍 To be merged to ✅ Done in Dev Board Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bugfix Bug fix for use in PRs solving a specific issue:bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

object.rotate(..., about_point) and Rotate(object, ..., about_point) gives different results.

2 participants