|
brazos-trapezoidal
|
#include "MathLib.h"
Go to the source code of this file.
Macros | |
| #define | SIZE_SQRT_TABLE_2N 7 |
| #define | SIN_TABLE_SIZE 512 |
| #define | COS_TABLE_OFFSET 128 |
| #define | SIN_POL_A0 _IQ(0.70710781187) |
| #define | SIN_POL_A2 _IQ(-0.872348075361) |
| #define | SIN_POL_A4 _IQ(0.179251759526) |
| #define | SIN_POL_A6 _IQ(-0.0142718282624) |
| #define | SIN_POL_B1 _IQ(-1.11067032264) |
| #define | SIN_POL_B3 _IQ(0.4561589075945) |
| #define | SIN_POL_B5 _IQ(-0.0539104694791) |
| #define | ATAN_POL_A7 _IQ(-1.57588) |
| #define | ATAN_POL_A5 _IQ(1.48697) |
| #define | ATAN_POL_A3 _IQ(-0.817719) |
| #define | ATAN_POL_A1 _IQ(0.63611725) |
| #define | ATAN_POL_A0 _IQ(0.25) |
Functions | |
| u_mc_t | MathLib_SqrtLUT (uint16_t value) |
| Calculates the square root of IQ1.15 number using a Look-up table that needs to have a size of a power of 2. More... | |
| void | MathLib_SinCosPoly (mc_t theta, trig_t *sinCos) |
| Calculates the sine and cosine using a sixth order polynomial approximation, the approximation is just valid for the range -0.5 to 0.5 which represents the range from 0 to pi/2. More... | |
| void | MathLib_SinCosIQ (mc_t theta, trig_t *sinCos) |
| Sin and Cosine calculation of a Q1.15 angle. More... | |
| mc_t | MathLib_ModIq (mc_t x, mc_t y) |
| Modulus function, it calculates hypotenusa in Q1.15. More... | |
| void | MathLib_SinCosModAbIq (AlphaBeta_t *ab, mc_t mod, trig_t *sinCos) |
| Modulus function, it calculates hypotenusa in Q1.15. More... | |
| mc_t | MathLib_AtanPoly (mc_t a) |
| Calculates the atangent from a IQ number. More... | |
| mc_t | MathLib_Atan2Poly (mc_t y, mc_t x) |
| Atan2 function, it calculates the atan based on the x and y values. More... | |
Variables | |
| const uint16_t | SquareRootLUT [] |
Definition in file MathLib_Iq.c.
| #define ATAN_POL_A0 _IQ(0.25) |
Definition at line 44 of file MathLib_Iq.c.
| #define ATAN_POL_A1 _IQ(0.63611725) |
Definition at line 43 of file MathLib_Iq.c.
| #define ATAN_POL_A3 _IQ(-0.817719) |
Definition at line 42 of file MathLib_Iq.c.
| #define ATAN_POL_A5 _IQ(1.48697) |
Definition at line 41 of file MathLib_Iq.c.
| #define ATAN_POL_A7 _IQ(-1.57588) |
Polynomial solution for the atan
Definition at line 40 of file MathLib_Iq.c.
| #define COS_TABLE_OFFSET 128 |
defines the size of the Sin Look-up table in 2^n logic, since 2^8 = 256, the table has 256 entries
Definition at line 28 of file MathLib_Iq.c.
| #define SIN_POL_A0 _IQ(0.70710781187) |
Polynomial solution for the sine and cosine
Definition at line 32 of file MathLib_Iq.c.
| #define SIN_POL_A2 _IQ(-0.872348075361) |
Definition at line 33 of file MathLib_Iq.c.
| #define SIN_POL_A4 _IQ(0.179251759526) |
Definition at line 34 of file MathLib_Iq.c.
| #define SIN_POL_A6 _IQ(-0.0142718282624) |
Definition at line 35 of file MathLib_Iq.c.
| #define SIN_POL_B1 _IQ(-1.11067032264) |
Definition at line 36 of file MathLib_Iq.c.
| #define SIN_POL_B3 _IQ(0.4561589075945) |
Definition at line 37 of file MathLib_Iq.c.
| #define SIN_POL_B5 _IQ(-0.0539104694791) |
Definition at line 38 of file MathLib_Iq.c.
| #define SIN_TABLE_SIZE 512 |
Definition at line 25 of file MathLib_Iq.c.
| #define SIZE_SQRT_TABLE_2N 7 |
defines the size of the square root Look-up table in 2^n logic, since 2^7 = 128, the table has 128 entries
Definition at line 24 of file MathLib_Iq.c.
| mc_t MathLib_Atan2Poly | ( | mc_t | y, |
| mc_t | x | ||
| ) |
Atan2 function, it calculates the atan based on the x and y values.
| y | y-axis value to be calculated |
| x | x-axis value to be calculated |
Definition at line 453 of file MathLib_Iq.c.
| mc_t MathLib_AtanPoly | ( | mc_t | a | ) |
Calculates the atangent from a IQ number.
| a | the IQ value to be calculated, it needs to be between -0.5 and 0.5 |
Definition at line 430 of file MathLib_Iq.c.
| mc_t MathLib_ModIq | ( | mc_t | x, |
| mc_t | y | ||
| ) |
Modulus function, it calculates hypotenusa in Q1.15.
| y | y-axis value to be calculated |
| x | x-axis value to be calculated |
Definition at line 363 of file MathLib_Iq.c.

| void MathLib_SinCosIQ | ( | mc_t | theta, |
| trig_t * | sinCos | ||
| ) |
Sin and Cosine calculation of a Q1.15 angle.
Sin table in the range of [0:2*pi]
| mc_t | theta: the angle |
Definition at line 301 of file MathLib_Iq.c.
| void MathLib_SinCosModAbIq | ( | AlphaBeta_t * | ab, |
| mc_t | mod, | ||
| trig_t * | sinCos | ||
| ) |
Modulus function, it calculates hypotenusa in Q1.15.
| y | y-axis value to be calculated |
| x | x-axis value to be calculated |
Definition at line 377 of file MathLib_Iq.c.
| void MathLib_SinCosPoly | ( | mc_t | theta, |
| trig_t * | sinCos | ||
| ) |
Calculates the sine and cosine using a sixth order polynomial approximation, the approximation is just valid for the range -0.5 to 0.5 which represents the range from 0 to pi/2.
| theta | the angle |
| sinCos | pointer to the struct that will hold the results |
get the quadrant of the angle
wrap the angle between 0 and pi/2, the range of the polynomial approximation
Rearrange 0 -> -1/2 and pi/2 -> 1/2, that's how the approximation use the angles
Definition at line 253 of file MathLib_Iq.c.
| u_mc_t MathLib_SqrtLUT | ( | uint16_t | value | ) |
Calculates the square root of IQ1.15 number using a Look-up table that needs to have a size of a power of 2.
| value | the number in 1.15 format |
The modulus operation is getting how much the input value is far from the table value, this is being used to interpolate, since everything is in the power of two, tmp will be in the IQ 1.(15-SIZE_SQRT_TABLE_2N) format.
Definition at line 216 of file MathLib_Iq.c.

| const uint16_t SquareRootLUT[] |
Definition at line 65 of file MathLib_Iq.c.