From 6ccbbe8e5d69b7e5d90c5426dd80fe76c128f29b Mon Sep 17 00:00:00 2001 From: Taksh Date: Wed, 1 Jul 2026 20:23:05 +0530 Subject: [PATCH] docs(space_ops): correct cartesian_to_spherical return order The docstring claimed the function returns (distance, phi, theta), but it returns [r, theta, phi] (matching spherical_to_cartesian). Fix the description and document each returned value. Fixes #3123 Co-authored-by: Cursor --- manim/utils/space_ops.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/manim/utils/space_ops.py b/manim/utils/space_ops.py index 0aa57b93c6..fe9a001112 100644 --- a/manim/utils/space_ops.py +++ b/manim/utils/space_ops.py @@ -810,12 +810,24 @@ def earclip_triangulation(verts: np.ndarray, ring_ends: list) -> list: def cartesian_to_spherical(vec: Vector3DLike) -> np.ndarray: """Returns an array of numbers corresponding to each - polar coordinate value (distance, phi, theta). + spherical coordinate value ``(r, theta, phi)``. + + This is the inverse of :func:`spherical_to_cartesian` and uses the same + coordinate order, so the two functions round-trip. Parameters ---------- vec A numpy array or a sequence of floats ``[x, y, z]``. + + Returns + ------- + np.ndarray + A numpy array ``[r, theta, phi]`` where: + + * ``r`` is the distance between the point and the origin. + * ``theta`` is the azimuthal angle to the positive x-axis. + * ``phi`` is the vertical angle to the positive z-axis. """ norm = np.linalg.norm(vec) if norm == 0: