function newHeading(m,h){ 
      //log_debug("newHeading()");
      var s = Math.abs(m - h);
      var delta = (m>h)?1:-1;
      if (s>=180){s=360-s; delta = -delta;} 
      if (s<2) return h;
      if (s<3) return h;
      var hd = h + delta*(1 + Math.round(s/5));
      if (hd<0) hd+=360;
      if (hd>360)hd-= 360;
      return hd;
    }
// stops violent compass swings and wobbles, takes 3ms
stops violent compass swings and wobbles, takes 3ms
stops violent compass swings and wobbles takes 3ms
function newHeading(m,h){ 
      var s = Math.abs(m - h);
      var delta = (m>h)?1:-1;
      if (s>=180){s=360-s; delta = -delta;} 
      if (s<2) return h;
      if (s<3) return h;
      var hd = h + delta*(1 + Math.round(s/5));
      if (hd<0) hd+=360;
      if (hd>360)hd-= 360;
      return hd;
    }
function newHeading ( m , h ) { var s = Math . abs ( m - h ) ; var delta = ( m > h ) ? 1 : - 1 ; if ( s >= 180 ) { s = 360 - s ; delta = - delta ; } if ( s < 2 ) return h ; if ( s < 3 ) return h ; var hd = h + delta * ( 1 + Math . round ( s / 5 ) ) ; if ( hd < 0 ) hd += 360 ; if ( hd > 360 ) hd -= 360 ; return hd ; }
stops violent compass swings and wobbles, takes 3ms
stops violent compass swings and wobbles takes 3ms
//log_debug("newHeading()");