0

Alright I'm using a low-pass method() for a compass-like project in android. I got some troubles when my azimut is to the North (mooving from 0 to 360 then...). I thought the problem could come from my low pass function.

What do you think about it :

private float[] lowPass( float[] input, float[] output ) {
    if ( output == null || (output[0] == 0.0 && output[1] == 0.0 && output[2] == 0.0)) {
        return input;
    }
    else {
        for (int i = 0; i < input.length; i++) {
            output[i] = output[i] + 0.15f * (input[i] - output[i]);
            // 0.25
        }
        return output;
    }
}

I saw that radians angles must be use instead of degrees... Can the problem come from here ?

thank's for your help !

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Mayoul
  • 626
  • 10
  • 24
  • For reasons well documented here on SO, and on about 1,000,001 other sites around the 'net, comparison of floats for equality (i.e. expressions such as `output[0] == 0.0`) are fraught with hazard. Try something like `abs(output[0]) – High Performance Mark Sep 05 '17 at 15:25
  • Averaging compass readings is surprisingly difficult. I doubt you will be able to compute a simple moving average. The problem is discussed in detail here: https://stackoverflow.com/questions/491738/how-do-you-calculate-the-average-of-a-set-of-circular-data – Kevin Boone Sep 06 '17 at 10:14

0 Answers0