mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Fix docstring for cartesian_to_spherical to match return order
This commit is contained in:
parent
0e83f4b09a
commit
77636c06c1
1 changed files with 18 additions and 14 deletions
|
|
@ -809,21 +809,25 @@ 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).
|
||||
"""Returns an array of numbers corresponding to each
|
||||
spherical coordinate value (distance, theta, phi).
|
||||
|
||||
Parameters
|
||||
----------
|
||||
vec
|
||||
A numpy array or a sequence of floats ``[x, y, z]``.
|
||||
"""
|
||||
norm = np.linalg.norm(vec)
|
||||
if norm == 0:
|
||||
return np.zeros(3)
|
||||
r = norm
|
||||
phi = np.arccos(vec[2] / r)
|
||||
theta = np.arctan2(vec[1], vec[0])
|
||||
return np.array([r, theta, phi])
|
||||
Parameters
|
||||
----------
|
||||
vec
|
||||
A numpy array or a sequence of floats ``[x, y, z]``.
|
||||
|
||||
Returns
|
||||
-------
|
||||
:class:`numpy.ndarray`
|
||||
An array of three floats ``[r, theta, phi]`` where:
|
||||
|
||||
r - The distance between the point and the origin.
|
||||
|
||||
theta - The azimuthal angle of the point to the positive x-axis.
|
||||
|
||||
phi - The vertical angle of the point to the positive z-axis.
|
||||
"""
|
||||
|
||||
|
||||
def spherical_to_cartesian(spherical: Sequence[float]) -> np.ndarray:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue