title: Find if an angle is within X degrees from another
body: <p>I need an algorithm to figure out if one angle is within a certain amount of degrees from another angle.</p>
  
  <p>My first thought was <code>(a-x &lt; b) &amp;&amp; (a+x &gt; b)</code>, but it fails when it has to work with angles that wrap around from -179 to 180.</p>
  
  <p><img src="https://imgkk.com/i/CQmC4h.png" /></p>
  
  <p>In the diagram above, the region (green) that the angle must be between wraps between the negative and positive sides. How can I determine whether the angle (the red line) falls inside this region?</p>