Module fixed_math::trig

source ·
Expand description

Trigonometric functions for fixed numbers.

Implementation

We use the CORDIC algorithm, following this paper: Efficient Fixed-Point Trigonometry Using CORDIC Functions For PIC16F - Jose Benavides Microchip Technology Inc. (2007) https://ww1.microchip.com/downloads/en/AppNotes/01061A.pdf

Constants

180 / π used to convert from radians to degrees
π / 180 used to convert from degrees to radians

Functions

Compute cos of an angle in degrees.
Simply convert a fixed number from degrees to radians by multiplication.
Simply convert a fixed number from radians to degrees by multiplication.
Compute sin of an angle in degrees.
Compute sin and cos simultaneously of an angle in degrees.
Only works with values in -90 to 90 degrees.
Compute sin and cos simultaneously of an angle in degrees.
Compute sin and cos simultaneously of an angle in degrees.
Compute sin and cos simultaneously of an angle in degrees.
Currently it is very imprecise. You probably want to convert to degrees and use sin_cos instead.
Only works for values in -π/2 to π/2 radians
Calculate tangent of an angle in degrees. Returns None when the cos is 0 or on overflow.