Weather routing: Difference between revisions
m
edit docs
m (edit docs) |
|||
Line 52:
function getpolardata(filename)
Read a sailing polar CSV file and return a SailingPolar
A sailing polar file is a CSV file, with ';' used as the comma separator instead of a comma.
Line 160:
sailingspeed(sp::SailingPolar, azimuth, dir, ws)
Calculate the expected net boat speed in a desired direction versus the wind (azimuth).
This is generally different from the actual boat speed in its actual direction.
Directions are in degrees (
and velocity of wind (ws) is in knots.
"""
sailingspeed(sp, azimuth,
Line 177 ⟶ 178:
"""
function bestvectorspeed(sp::SailingPolar, dirtravel, dirwind, windspeed, dircur, velcur)
VMG = boatspeed(sp,
other, idx = findmax([sailingspeed(sp,
if other > VMG
VMG = other
end
dirchosen = deg2rad(dirwind +
wx, wy = VMG * sin(dirchosen), VMG * cos(dirchosen)
curx, cury = velcur * sin(deg2rad(dircur)), velcur * cos(deg2rad(dircur))
Line 201 ⟶ 202:
distance, dir = haversine(lat1, lon1, lat2, lon2)
dir2, vel = bestvectorspeed(sp, dir, p.winddeg, p.windkts, p.currentdeg, p.currentkts)
# minutes/s * m / (knots * (m/s / knot)) = minutes
return (1 / 60) * distance / (vel * 1.94384)
|