Calculate heading and distance from dx and dy

def _update(self):
        '''
        Calculate heading and distance from dx and dy
        '''
        try:
            theta_radians = math.atan(float(self.dy)/self.dx)
        except ZeroDivisionError:
            if self.dy > 0: theta_radians = 0.5*math.pi
            elif self.dy < 0: theta_radians = 1.5*math.pi
            self.magnitude = self.dy
        else:
            self.magnitude = 1./(math.cos(theta_radians))*self.dx
        theta = math.degrees(theta_radians)
        self.heading = self._angle_or_heading(theta)