Algorithm Request: Comparison against a range that wraps


Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3321
Posted: 01:51am 25 Jun 2021      

Vegipete's concept is the same as one I used for time, though different code and it works well. For angles another method is to convert numbers over 180 to negative. But only if they are within the "window" distance of 0 / 360.
Eg.

if (X > 180) AND (Y-window < 0)  then X = X - 360
if (Y > 180) AND (X-window < 0)  then Y = Y - 360

Then perform the tolerance window test.

Phil

Edit I think that's how it went, many years ago.
Edited 2021-06-25 12:02 by phil99