ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts
1.0
ESP8266ILI9341DisplayProject
|
Cordic Routines Handle angle outside of the first quadrant Added standalone test to verify CORDIC against math library Add Documentation and references. More...
#include "user_config.h"
#include <stdint.h>
#include <string.h>
#include "printf/mathio.h"
#include <math.h>
#include "cordic2c_inc.h"
#include "cordic.h"
Go to the source code of this file.
Macros | |
#define | CORDIC_TABLE /* include the generated Cordic table */ |
Functions | |
MEMSPACE double | deg2rad (double deg) |
Convert Degrees to Rads. More... | |
MEMSPACE double | angle_quad (double quads, int *quad) |
Compute quadrant of angle and the quadrant modulus Note: Integer part is quadrant. More... | |
void | Circular (Cordic_T x, Cordic_T y, Cordic_T z) |
MEMSPACE void | cordic_quad (double angle, double *s, double *c) |
Compute Sin and Cos from angle in quads using Cordic. More... | |
MEMSPACE void | cordic_deg (double deg, double *s, double *c) |
Compute Sin and Cos from angle in degrees using Cordic. More... | |
MEMSPACE void | cordic_rad (double rad, double *s, double *c) |
Compute Sin and Cos from angle in Rads using Cordic. More... | |
MEMSPACE void | scale_point (point *P, double scale) |
Scale x,y,z by scale factor. More... | |
MEMSPACE void | shift_point (point *P, point *shift) |
Shift x,y,z by shift. More... | |
MEMSPACE void | rotate (point *P, point *V) |
Rotate point P by View point. More... | |
MEMSPACE void | PerspectiveProjection (point *P, double scale, int x, int y) |
Variables | |
Cordic_T | X |
Main Cordic routine - used for basic trig and vector rotations We use fixed point numbers, where 1.0=Cordic_One cordic.h. More... | |
Cordic_T | Y |
Cordic_T | Z |
Cordic Routines Handle angle outside of the first quadrant Added standalone test to verify CORDIC against math library Add Documentation and references.
Cordic Code Modified by Mike Gore 2015 to generate C Cordic tables The code has been adjusted to quads (Where 90 degrees = 1.0) The angle is just the fractional part of a floating point number The integer part is the quadrant. This makes computations for code using the tables much faster.
This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Original Documentation
CORDIC algorithms. The original code was published in Doctor Dobbs Journal issue ddj9010. The ddj version can be obtained using FTP from SIMTEL and other places.
Converted to ANSI-C (with prototypes) by P. Knoppers, 13-Apr-1992.
The main advantage of the CORDIC algorithms is that all commonly used math Functions ([a]sin[h] [a]cos[h] [a]tan[h] atahh ln exp sqrt) are Implemented using only shifts, add, subtract and compare. All values are treated as integers. Actually they are fixed point values. The position of the fixed point is a compile time constant (Cordic_T_FractionBits). I don't believe that this can be easily fixed...
Some initialization of internal tables and constants is necessary before all functions can be used. The constant "Cordic_HalfPI" must be determined before compile time, all others are computed during run-time - see main() below.
Of course, any serious implementation of these functions should probably have all constants determined sometime before run-time and most functions might be written in assembler.
The layout of the code is adapted to my personal preferences. PK.
Definition in file cordic.c.
#define CORDIC_TABLE /* include the generated Cordic table */ |
MEMSPACE double angle_quad | ( | double | quads, |
int * | quad | ||
) |
Compute quadrant of angle and the quadrant modulus Note: Integer part is quadrant.
[in] | quads | 1.0 = 90 degrees |
[out] | quad | quadrant 0 = 0 .. 89.9999, 1 = 90 ... 179.999 ..., etc |
Definition at line 71 of file cordic.c.
Referenced by cordic_quad().
Definition at line 103 of file cordic.c.
Referenced by cordic_quad().
MEMSPACE void cordic_deg | ( | double | deg, |
double * | s, | ||
double * | c | ||
) |
Compute Sin and Cos from angle in degrees using Cordic.
[in] | deg | angle in degrees |
[in,out] | *s | sin |
[in,out] | *c | cos |
Definition at line 215 of file cordic.c.
Referenced by PerspectiveProjection(), and rotate().
MEMSPACE void cordic_quad | ( | double | angle, |
double * | s, | ||
double * | c | ||
) |
Compute Sin and Cos from angle in quads using Cordic.
[in] | angle | angle in quads ( 1 quad = 90 degrees) |
[out] | *s | sin |
[out] | *c | cos |
Definition at line 144 of file cordic.c.
Referenced by cordic_deg(), and cordic_rad().
MEMSPACE void cordic_rad | ( | double | rad, |
double * | s, | ||
double * | c | ||
) |
Compute Sin and Cos from angle in Rads using Cordic.
[in] | rad | angle in radians |
[out] | *s | sin |
[out] | *c | cos |
MEMSPACE double deg2rad | ( | double | deg | ) |
Definition at line 310 of file cordic.c.
Referenced by wire_draw().
Rotate point P by View point.
[in] | *P | x,y,z point |
[in] | *V | View point |
Definition at line 265 of file cordic.c.
Referenced by wire_draw().
Cordic_T X |
Main Cordic routine - used for basic trig and vector rotations We use fixed point numbers, where 1.0=Cordic_One cordic.h.
[in,out] | x | in: Cordik_K, out: Cos of z |
[in,out] | y | in: 0, out: Sin of z |
[in,out] | z | in: fixed point version of angle in quads, out: not used |
Definition at line 102 of file cordic.c.
Referenced by AdjustFontTable(), Circular(), cordic_quad(), FontAdjustSmall(), tft_Bezier2(), tft_Bezier3(), tft_clip_xy(), and user_loop().
Cordic_T Y |
Definition at line 102 of file cordic.c.
Referenced by AdjustFontTable(), Circular(), cordic_quad(), FontAdjustSmall(), tft_Bezier2(), tft_Bezier3(), tft_clip_xy(), and user_loop().
Cordic_T Z |
Definition at line 102 of file cordic.c.
Referenced by Circular().