algorithm - Find if an angle is within X degrees from another -


I need an algorithm to figure out that an angle is within a certain degree from the other angle.

My first thought was (ax & lt; b) & amp; Amp; (A + x> B) , but it fails when it has to work from an angle, which wraps from -179 to 180.

In the picture given above, the area (green) that angle negative and Should be between wrapping between positive sides. How can I determine that angle (red line) comes within this area?

Try this formula:

  360- (| now |) % 360 & lt; X || (| A-b |)% 360 & lt; X  

Or,:

   

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -