Averaging angles… Again

后端 未结 12 2130
情歌与酒
情歌与酒 2020-12-14 08:26

I want to calculate the average of a set of angles, which represents source bearing (0 to 360 deg) - (similar to wind-direction)

I know it has been

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-14 09:24

    Thank you all for helping me see my problem more clearly.

    I found what I was looking for. It is called Mitsuta method.

    The inputs and output are in the range [0..360).

    This method is good for averaging data that was sampled using constant sampling intervals.

    The method assumes that the difference between successive samples is less than 180 degrees (which means that if we won't sample fast enough, a 330 degrees change in the sampled signal would be incorrectly detected as a 30 degrees change in the other direction and will insert an error into the calculation). Nyquist–Shannon sampling theorem anybody ?

    Here is a c++ code:

    double AngAvrg(const vector& Ang)
    {
        vector::const_iterator iter= Ang.begin();
    
        double fD   = *iter;
        double fSigD= *iter;
    
        while (++iter != Ang.end())
        {
            double fDelta= *iter - fD;
    
                 if (fDelta < -180.) fD+= fDelta + 360.;
            else if (fDelta >  180.) fD+= fDelta - 360.;
            else                     fD+= fDelta       ;
    
            fSigD+= fD;
        }
    
        double fAvrg= fSigD / Ang.size();
    
        if (fAvrg >= 360.) return fAvrg -360.;
        if (fAvrg <  0.  ) return fAvrg +360.;
                           return fAvrg      ;
    }
    

    It is explained on page 51 at http://www.epa.gov/scram001/guidance/met/mmgrma.pdf

    Thank you MaR for sending the link as a comment.

    If the sampled data is constant, but our sampling device has an inaccuracy with a Von Mises distribution, a unit-vectors calculation will be appropriate.

提交回复
热议问题