diff --git a/calcs/leeway.js b/calcs/leeway.js index 76bf520..3f0c278 100644 --- a/calcs/leeway.js +++ b/calcs/leeway.js @@ -4,7 +4,7 @@ module.exports = function (app, plugin) { group: 'heading', optionKey: 'leeway', title: 'Leeway', - derivedFrom: ['navigation.attitude.roll', 'navigation.speedThroughWater'], + derivedFrom: ['navigation.attitude', 'navigation.speedThroughWater'], properties: { kFactor: { type: 'number', @@ -13,12 +13,11 @@ module.exports = function (app, plugin) { default: 12 } }, - calculator: function (roll, stw) { + calculator: function (attitude, stw) { var kFactor = plugin.properties.heading.kFactor - var rollDegrees = roll / Math.PI * 360 + var rollDegrees = attitude.roll / Math.PI * 360 var stwKnots = stw * 1.94384 - var leewayAngle = - kFactor * rollDegrees / Math.pow(stwKnots, 2) / 360 * Math.PI + var leewayAngle = stwKnots <= 0 ? 0 : kFactor * rollDegrees / Math.pow(stwKnots, 2) / 360 * Math.PI // app.debug('roll: ' + rollDegrees + ' stw: ' + stwKnots + ' knots => leeway: ' + leewayAngle/Math.PI*360) return [{ path: 'performance.leeway', value: leewayAngle }] }