Atan2 is the mathematical operation that lets you find an angle from two points. For example, point A is "where I am", expressed in coordinates, and point B is "where I want to be", expressed in coordinates. In a flat world, atan2(a,b) will give you the compass direction to go from A to B.

In a round world, you first have to do a bit of geodesy. For short distances, you don't care that much.

These formulas are there to let you do atan2 very quickly on a processor that either doesn't have trigonometric functions, or has them but they are very slow.

32 bit floating point (reference math)

16 bit integer

Note that this is an approximation: the 32 bit version will be off by about 0.2 degrees, and the 16 bit by about 1 degree. The good news is that even 1 degree is often good enough for autonomous navigation.

Page last modified on April 15, 2014, at 12:44 AM
Powered by PmWiki