Skip to content

Commit

Permalink
Fix issue where the roll is using the wrong path
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 committed Feb 29, 2024
1 parent 8a90bb9 commit d27c012
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 d27c012

Please sign in to comment.