Skip to content

Commit

Permalink
Fix issue where the roll is using the wrong path (#129)
Browse files Browse the repository at this point in the history
Fix issue where calculated leeway is invalid if STW is 0
  • Loading branch information
rogerlittin authored Mar 2, 2024
1 parent 8a90bb9 commit 7c2b125
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions calcs/leeway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 }]
}
Expand Down

0 comments on commit 7c2b125

Please sign in to comment.