(self)
return YawPitch(yaw, pitch)
Calculate the yaw and pitch of this vector
Calculate the yaw and pitch of this vector
Calculate the yaw and pitch of this vector
def yaw_pitch(self):
        """
        Calculate the yaw and pitch of this vector
        """
        if not self:
            return YawPitch(0, 0)
        ground_distance = math.sqrt(self.x ** 2 + self.z ** 2)
        if ground_distance:
            alpha1 = -math.asin(self.x / ground_distance) / math.pi * 180
            alpha2 = math.acos(self.z / ground_distance) / math.pi * 180
            if alpha2 > 90:
                yaw = 180 - alpha1
            else:
                yaw = alpha1
            pitch = math.atan2(-self.y, ground_distance) / math.pi * 180
        else:
            yaw = 0
            y = round(self.y)
            if y > 0:
                pitch = -90
            elif y < 0:
                pitch = 90
            else:
                pitch = 0
        return YawPitch(yaw, pitch)
def yaw_pitch ( self ) : if not self : return YawPitch ( 0 , 0 ) ground_distance = math . sqrt ( self . x ** 2 + self . z ** 2 ) if ground_distance : alpha1 = - math . asin ( self . x / ground_distance ) / math . pi * 180 alpha2 = math . acos ( self . z / ground_distance ) / math . pi * 180 if alpha2 > 90 : yaw = 180 - alpha1 else : yaw = alpha1 pitch = math . atan2 ( - self . y , ground_distance ) / math . pi * 180 else : yaw = 0 y = round ( self . y ) if y > 0 : pitch = - 90 elif y < 0 : pitch = 90 else : pitch = 0 return YawPitch ( yaw , pitch )