def _sph_to_cart(sph):
 assert ((sph.ndim == 2) and (sph.shape[1] == 3))
 sph = np.atleast_2d(sph)
 out = np.empty((len(sph), 3))
 out[:, 2] = (sph[:, 0] * np.cos(sph[:, 2]))
 xy = (sph[:, 0] * np.sin(sph[:, 2]))
 out[:, 0] = (xy * np.cos(sph[:, 1]))
 out[:, 1] = (xy * np.sin(sph[:, 1]))
 return out

def _sph_to_cart ( sph ) : assert ( ( sph . ndim == 2 ) and ( sph . shape [ 1 ] == 3 ) ) sph = np . atleast_2d ( sph ) out = np . empty ( ( len ( sph ) , 3 ) ) out [ : , 2 ] = ( sph [ : , 0 ] * np . cos ( sph [ : , 2 ] ) ) xy = ( sph [ : , 0 ] * np . sin ( sph [ : , 2 ] ) ) out [ : , 0 ] = ( xy * np . cos ( sph [ : , 1 ] ) ) out [ : , 1 ] = ( xy * np . sin ( sph [ : , 1 ] ) ) return out
convert spherical coordinates to cartesion coordinates .