I have an application that requires very low precision (within 2 degrees) and very high speed to determine the angle of a line given rise/run. Specifically, the precision is really only needed closer to the x axis (below 45 or above 135 degrees), which I think is easier to accomplish because as the angle nears 90 it approaches an undefined value. Currently, I use atan2 from the math.h library, but I would like something faster.
I have seen this example and think a lookup table for atan would suffice, however its much more tricky to make one for an arctan than tan, as I have to think in terms of the slope and how it can be represented as an integer so it can be used as an indices of the table.
Has anyone done this before? I'm thinking I need to have some sort of scale factor, so when I take rise/run and get my slope as a decimal I may have to multiply it by a constant value, otherwise everything below 45 will be 0 degrees. However, in this case I sacrifice a lot of accuracy above 45 degrees. Really, I do not need to distinguish between anything between 75-105 degrees. But in the 30/160 degree range it would be good to be able to have accuracy at 2-3 degrees.