Skip to content

atan2 implementation for MIPS, without floating point registers.

Notifications You must be signed in to change notification settings

ultraviolet/mips-atan2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

MIPS atan2 Implementation

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.

Features

  • 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

Usage

See function header for input/output specifications.

Accuracy

  • 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.

Histogram of accuracy data. The mean accuracy is 0.006580deg, with a max accuracy of 0.015942 degrees.

About

atan2 implementation for MIPS, without floating point registers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published