def spherical_to_cartesian(r, lat, lon):
 if (not hasattr(r, u'unit')):
  r = (r * u.dimensionless_unscaled)
 if (not hasattr(lat, u'unit')):
  lat = (lat * u.radian)
 if (not hasattr(lon, u'unit')):
  lon = (lon * u.radian)
 sph = SphericalRepresentation(distance=r, lat=lat, lon=lon)
 cart = sph.represent_as(CartesianRepresentation)
 return (cart.x, cart.y, cart.z)

def spherical_to_cartesian ( r , lat , lon ) : if ( not hasattr ( r , u'unit' ) ) : r = ( r * u . dimensionless_unscaled ) if ( not hasattr ( lat , u'unit' ) ) : lat = ( lat * u . radian ) if ( not hasattr ( lon , u'unit' ) ) : lon = ( lon * u . radian ) sph = SphericalRepresentation ( distance = r , lat = lat , lon = lon ) cart = sph . represent_as ( CartesianRepresentation ) return ( cart . x , cart . y , cart . z )
converts spherical polar coordinates to rectangular cartesian coordinates .