1#this is just an easy way to do this ,
2#not optimised for better scientific calculations
3import math as m
4def cartesian_to_spherical(x,y,z):
5 r = m.sqrt((x**2) +(y**2)+(z**2))
6 theta = m.acos(z/r)
7 phi = m.atan(y/x)
8 print(f'r = {r},\nθ = {m.degrees(theta)},\nΦ={m.degrees(phi)}')
9# !this done now speherical is below
10def spherical_to_cartesian(r,theta,phi):
11 x =r*(m.sin(m.radians(theta)))*(m.cos(m.radians(phi)))
12 y =r*(m.sin(m.radians(theta)))*(m.sin(m.radians(phi)))
13 z =r*(m.cos(m.radians(theta)))
14 print(f'x = {x}\ny = {y}\nz = {z}')