Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double nilsegments::getMatch(double true_wind_direction, double true_track_heading, double true_wind_speed,double true_track_speed)
- {
- //formula from https://en.wikipedia.org/wiki/Apparent_wind
- //V = velocity (boat speed over ground, always => 0)
- //W = true wind velocity (always => 0)
- //alpha = true pointing angle in degrees (0 = upwind, 180 = downwind)
- //A = apparent wind velocity (always => 0)
- //A= sqrt ((W^2+V^2+2WV)\cos (alpha))
- double true_wind_heading=fmod((true_wind_direction + 180),360);
- double a = true_wind_heading;
- double b = true_track_heading;
- double diff = (a > b ? a - b : b - a);
- double mod_diff = fmod(diff, 360);
- double alpha = (mod_diff < 180 ? mod_diff : 360 - mod_diff);
- double W=true_wind_speed;
- double V=true_track_speed;
- double W_pow=qPow(W,2);
- double V_pow=qPow(V,2);
- double alpha_cos=qCos(qDegreesToRadians(alpha));
- double A_speed=qSqrt(W_pow+V_pow+(2*W*V*alpha_cos));
- //double A_angle = qRadiansToDegrees(qAcos((W*alpha_cos+V)/A_speed));
- //H=headwind
- double H=A_speed-W;
- return qPow(H,2)/qPow(true_track_speed,2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement