Spherical to Cartesian Conversion Example#

Convert spherical coordinates (theta, phi) to Cartesian coordinates.

Input spherical coordinates (theta, phi):
[[0.78539816 1.04719755]
 [0.52359878 0.78539816]]

Converted Cartesian coordinates (x, y, z):
[[0.35355339 0.61237244 0.70710678]
 [0.35355339 0.35355339 0.8660254 ]]

import numpy as np
from spheresmooth import spherical_to_cartesian

# Example spherical coordinates
theta_phi = np.array([
    [np.pi / 4, np.pi / 3],
    [np.pi / 6, np.pi / 4]
])

print("Input spherical coordinates (theta, phi):")
print(theta_phi)

# Convert to Cartesian
cartesian = spherical_to_cartesian(theta_phi)

print("\nConverted Cartesian coordinates (x, y, z):")
print(cartesian)

Total running time of the script: (0 minutes 0.001 seconds)

Gallery generated by Sphinx-Gallery