Weather routing: Difference between revisions
m
→{{header|Phix}}: find_range()
m (→{{header|Phix}}: find_range()) |
|||
Line 980:
end function
function
-- Returns the
for i=1 to length(s) do
if s[i]>=v then
end for▼
exit
end if
end for
return {-1,-1}
end function
▲ for i=length(s) to 1 by -1 do
▲ if s[i]<=v then return i end if
▲ end for
function boatspeed(atom pointofsail, windspeed)
--
Line 1,002 ⟶ 999:
-- the previously loaded sailing polar data)
--
integer
uvel = findlast(windspeed, winds),▼
atom wu = winds[uv],
ovel = findfirst(windspeed, winds)▼
▲ if find(-1,{udeg, odeg, uvel, ovel}) then return -1 end if
▲ du = degrees[udeg],
f
if
f = iff(
elsif
f = (
else
f = ((du-pointofsail
end if
atom su = speeds[
res = su
return res
end function
Line 1,167 ⟶ 1,164:
if pyx=0 then exit end if
minpath = prepend(minpath,pyx)
paths[py,px] = 0 -- (be safe, why not)
{py,px} = pyx
end while
|