Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

True wind with leeway. #5

Open
ieb opened this issue Jul 19, 2017 · 4 comments
Open

True wind with leeway. #5

ieb opened this issue Jul 19, 2017 · 4 comments

Comments

@ieb
Copy link
Contributor

ieb commented Jul 19, 2017

Hi,
I see the True wind doesn't account for leeway. Not sure if it should, but here is some code (originally in C++ running on an ArduinoDue) that does the calc. It uses a slightly different approach to the current True Wind calc. Has been checked and tested, but might have bugs.

function calcTrueWind(awa, aws, stw, leeway) {
  if ( leeway === undefined) {
    leeway = 0;
  }
  awa  = fixAngle(awa);
  var stw_lee = stw*Math.cos(leeway);
  var awa_lee = awa;
  if ( awa_lee > 0 ) {
    awa_lee = awa_lee +  leeway;
  } else {
    awa_lee = awa_lee +  leeway;         
  }
  // this should be a noop, but just in case the leeway downwind caused something wierd.
  awa_lee = fixAngle(awa_lee);

  var ctws = Math.sqrt((stw_lee*stw_lee+aws*aws)-(2*stw_lee*aws*Math.cos(awa_lee)));
  var ctwa = 0.0;
  if ( ctws > 1.0E-3 ) {
    ctwa = (aws*Math.cos(awa_lee)-stw_lee)/ctws;
    if ( ctwa > 0.9999 || ctwa < -0.9999) {
      ctwa = 0.0;
    } else {
      ctwa = Math.acos(ctwa);
    }
  }
  if ( awa_lee < 0.0) {
    ctwa = -ctwa;
  }
  return {
    angle : ctwa,
    speed : ctws
  };
}
function fixAngle(d) {
  if ( d > Math.PI ) d = d - Math.PI;
  if ( d < -Math.PI) d = d + Math.PI;
  return d;
}
@sbender9
Copy link
Member

How are you getting leeway?

@joabakk
Copy link
Contributor

joabakk commented Oct 15, 2017

Leeway could be transverse speed as given from the newer logs. If not defined, it defaults to 0

@ieb
Copy link
Contributor Author

ieb commented Oct 16, 2017

Airmar do have some 2D ultrasonic logs. The earlier generation of these was not particually reliable. The new generation are better but cost around 1000 USD last time I looked. If I had one, I would use that source of data.

I am using leeway estimated from heel, derived from a low cost ($5 ebay) I2C 10Dof board . For Arduino the library support is not great and lacks callibration, for Node.js there is an excellent npm based on RTIMULib2 which allows a calibration procedure and is simple to use.

leewayAngle = Kfactor * roll / ( waterspeed ^2)

KFactor depends on the hull shape, the units of roll and waterspeed The estimate is from Pedrick's paper published in 1981, which is fairly standard. There are more complex ways for what I need this good enough.

@joabakk
Copy link
Contributor

joabakk commented Aug 28, 2018

I see from https://arvelgentry.jimdo.com/app/download/9157993883/Arvel+Gentry+-+Sailboat_Performance_Testing_Techniques.pdf?t=1485748085 that the constant varies from 9 to 16. That's another caclulation to add!

sbender9 pushed a commit that referenced this issue Aug 28, 2018
As discussed in #5 , there is a formula for calculating leeway, so here it is
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants