cartecian to spherical python
#this is just an easy way to do this ,
#not optimised for better scientific calculations
import math as m
def cartesian_to_spherical(x,y,z):
r = m.sqrt((x**2) +(y**2)+(z**2))
theta = m.acos(z/r)
phi = m.atan(y/x)
print(f'r = {r},\nθ = {m.degrees(theta)},\nΦ={m.degrees(phi)}')
# !this done now speherical is below
def spherical_to_cartesian(r,theta,phi):
x =r*(m.sin(m.radians(theta)))*(m.cos(m.radians(phi)))
y =r*(m.sin(m.radians(theta)))*(m.sin(m.radians(phi)))
z =r*(m.cos(m.radians(theta)))
print(f'x = {x}\ny = {y}\nz = {z}')