SignalK / signalk-derived-data

Generates deltas for values derived from signalk values
Apache License 2.0
18 stars 30 forks source link

Bearings as Direction [0,360] instead of Angles [-180,180] #106

Open RhumbRunner opened 2 years ago

RhumbRunner commented 2 years ago

Calculations for Course DTG, XTE, BRG, etc (based on courseGreatCircle.nextPoint / previousPoint) creates negative values for the bearingTrue and bearingMagnetic which is the calculated angle from North (0 Deg True) to the next point. So to get the compass bearing to steer to the next point you would have to subtract the value from 360. Shouldn't it always be a value (in Degrees) between 0 and 360? or expressed in radians 0 to 6.283185 (2xPi)? The negative numbers are seen only when the bearingTrue should be from 180 to 360. It seems to work right when its between 0 and 180. Both Freeboard and Kip don't have a way to convert the negative values back to the real heading you would need to know. Seems like a massive error in the plugin to me?

Bottom line... Shouldn't all course values be direction [0,360] in stead of angles [-180,180]

RhumbRunner commented 2 years ago

I don't know how to Fork but, here is my code that puts out the directions in a direction [0,360] in the SI Radians. if someone could evaluate it and possible merge it into the next release... Thanks courseData.js.txt