MIPS implementation of atan2 using a reduced lookup table (LUT) with linear interpolation (LERP). Credits to https://www.coranac.com/documents/arctangent/ for describing the algorithm.
- Computed entirely with integer arithmetic (no floating-point operations)
- As a result, it is highly performant for embedded systems and MIPS-based platforms
- Uses Q12/Q15 fixed-point arithmetic for intermediate calculations
- 129-entry reduced lookup table with linear interpolation
See function header for input/output specifications.
- Computational accuracy: ~0.016 degrees maximum error (mean ~0.007°)
- Output resolution: Integer degrees [0, 359] (±0.5° rounding error)
Note: To retain higher precision, modify the output conversion. For example:
- For thousandths of degrees [0-359999]:
result = (Q15_value * 45000) >> 15 - For BRAD format (0-65535): Keep the Q15 value and scale appropriately
The default implementation outputs integer degrees, but the internal Q15 precision supports sub-degree accuracy when using the thousandths conversion shown above. Accuracy data for thousandths precision is shown below.
