'Converts spherical polar coordinates to 3D rectangular cartesian
coordinates.'

def to_cartesian(self):

    if isinstance(self.r, Distance):
        d = self.r.view(u.Quantity)
    else:
        d = self.r
    x = ((d * np.sin(self.theta)) * np.cos(self.phi))
    y = ((d * np.sin(self.theta)) * np.sin(self.phi))
    z = (d * np.cos(self.theta))
    return CartesianRepresentation(x=x, y=y, z=z, copy=False)
