Algorithm Request: Comparison against a range that wraps


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3313
Posted: 06:09am 25 Jun 2021      

Found my old code fragment for compass. my previous post is messed up.

'window comparator
window=10 : x=356 : y=3
if (y>=360-window) and (x<window) then : y=y-360 :endif
if (x>=360-window) and (y<window) then : x=x-360 :endif
? abs(x-y)
if (abs(x-y) =< window) then : ?"within range" :else :? "No match" :endif