[Therion] Wrong average calculation from compass/backcompass data
Wookey
wookey at wookware.org
Thu May 17 15:02:33 CEST 2018
On 2018-05-17 09:25 +0200, Evaristo Quiroga via Therion wrote:
> El 17/05/2018 a las 0:36, Olly Betts escribió:
> I think the formula is too complicated. I purpose a simpler formula, like:
> If bearing <=180
> AverageBearing = (bearing + (backbearing -180))/2
> else
> AverageBearing = (bearing + (backbearing +180))/2
>
> Your proposed formula gives wrong answers in some cases - consider:
>
> bearing = 80, backbearing = 0
>
> These give AverageBearing = (80 + 0 - 180) / 2 = -50 (equivalent to
> 310), but this should be 130 (average of 80 and 180).
>
>
> In this case is not a problem with my formula, is a serious magnetic anomaly
> (100 degrees difference) and the program should to stop and to send a warning.
Yes a warning should probably be issued about poor data, but it _is_ a
problem with your formula. It's just an example showing that all cases
have to be dealt with correctly, including the wrap-around at 0/360
(or 0/400 for grads) and your simplified formula doesn't.
An example with a much smaller difference between back and foresight
could still be constructed to show the issue:
Fore: 175, Back: 0 AverageBearing= (175+0-180)/2 = -2.5. That's
wrong. It should be 177.5 in this case.
Wookey
--
Principal hats: Linaro, Debian, Wookware, ARM
http://wookware.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mailman.speleo.sk/pipermail/therion/attachments/20180517/fcefca2b/attachment.sig>
More information about the Therion
mailing list