dassencio / nmeagen

A drawing tool for generating GPS logs in NMEA format.
https://nmeagen.org
GNU General Public License v3.0
24 stars 8 forks source link

Angle Conversion Bug Results in Wrong Bearing #12

Closed schmidfrieder closed 4 months ago

schmidfrieder commented 5 months ago

Hi, thanks for publishing the codebase for your nice NMEA generator. I noticed that the bearing calculated and written into the nmea-messages differs from the bearing (or azimuth) i get when calculating it myself or using an online calculator. The calculation itself seems to be correct, but i possibly found an error in the angle conversion from degrees to radians. The function degreesToRadians at line 627 in main.js seems to be wrong. After changing this, the bearing is identical to the azimuth i got from an online calculator.

current implementation: function degreesToRadians(degrees) { return degrees / 180.0 / Math.PI; } proposed implementation:
function degreesToRadians(degrees) { return degrees / 180.0 * Math.PI; }

dassencio commented 4 months ago

Fixed in https://github.com/dassencio/nmeagen/commit/4cd7349739d5fece259fca014e93bdfff1b56128. Thank you for reporting and investigating this bug 🙂