parameters: (h1, h2, f)
return_statement: return degrees(atan2(hy, hx))
docstring: Combine two angles carefully
      @return the angle that is a mixture of h1 and h2
      @param h1 first angle in degrees
      @param h2 second angle in degrees
      @param f the mixing constant - 0 is 100% h1 and 1 is 100% h2
docstring_summary: Combine two angles carefully
docstring_tokens: Combine two angles carefully
function: def mix_angles(h1, h2, f):
      """
      Combine two angles carefully
      @return the angle that is a mixture of h1 and h2
      @param h1 first angle in degrees
      @param h2 second angle in degrees
      @param f the mixing constant - 0 is 100% h1 and 1 is 100% h2
      """
      # combine headings carefully to avoid a 'flip'
      rh1,rh2 = radians(h1), radians(h2)
      # average direction of the two headings
      hy = sin(rh1) * (1-f) + sin(rh2) * f
      hx = cos(rh1) * (1-f) + cos(rh2) * f
      # angle of that direction in degrees
      return degrees(atan2(hy, hx))
function_tokens: def mix_angles ( h1 , h2 , f ) : # combine headings carefully to avoid a 'flip' rh1 , rh2 = radians ( h1 ) , radians ( h2 ) # average direction of the two headings hy = sin ( rh1 ) * ( 1 - f ) + sin ( rh2 ) * f hx = cos ( rh1 ) * ( 1 - f ) + cos ( rh2 ) * f # angle of that direction in degrees return degrees ( atan2 ( hy , hx ) )