fix: clarify spherical coordinate naming in docstrings and variables#4678
Open
YizukiAme wants to merge 1 commit intoManimCommunity:mainfrom
Open
fix: clarify spherical coordinate naming in docstrings and variables#4678YizukiAme wants to merge 1 commit intoManimCommunity:mainfrom
YizukiAme wants to merge 1 commit intoManimCommunity:mainfrom
Conversation
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
Fixes #3123.
The docstring for
cartesian_to_spherical()previously described the return order as(distance, phi, theta), but the variable namesphiandthetaswap meaning between the math and physics conventions, making the documentation actively misleading.This patch sidesteps the convention ambiguity entirely by replacing
theta/phiwith convention-neutral names:azimuthal_angleandpolar_angle, following the approach suggested by @chopan050.Changes
manim/utils/space_ops.pycartesian_to_spherical(): Rewrote the docstring summary and added aReturnssection (numpydoc format) that explicitly defines each angle geometrically. Renamed internal variablestheta→azimuthal_angle,phi→polar_angle.spherical_to_cartesian(): Updated the parameter docstring fromtheta/phitoazimuthal_angle/polar_anglewith clear definitions. Renamed the unpacking variables to match.manim/mobject/geometry/arc.pyposition_tip()to use the sameazimuthal angle/polar anglevocabulary for cross-file consistency.tests/module/utils/test_space_ops.pytest_polar_coords→test_spherical_coordsand used descriptive variable names (cartesian_point,spherical_point). No assertion values changed.What did NOT change
[r, azimuthal_angle, polar_angle](same as the old[r, theta, phi]).arc.py:position_tip()) access by index, not by name.Verification
py_compilepasses on all modified files.arc.py:position_tip()usesangles[1]/angles[2](index-based), unaffected by variable renames.