1
$\begingroup$

What would be the most performing way to check whether a number of degrees (e.g. $10^\circ$) is within a range of degrees $\pm 30^\circ$ outgoing from $355^\circ$?

For a better understanding of my (novice) question, here's an image I just painted. a is the heading I want to check, b is the given heading with the tolerance of $\pm30^\circ$.

EDIT: The range can possibly be up to $180$ degrees (dynamically).

little painting of the situation

$\endgroup$

1 Answer 1

2
$\begingroup$

Subtract 30 from 355 to get 325. Add 30 to 355 to get 385 --- but that exceeds 360, s0 subtract 360 to get 25. So you have evrything between 325 and 360, and everything between 0 and 25. Since 10 is between 0 and 25, you have 10.

$\endgroup$
1
  • $\begingroup$ This solution is quite simple for the purpose of programming. Thanks! $\endgroup$ Dec 27, 2013 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .