You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/FastTrig/README.md
+58-39Lines changed: 58 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@
8
8
9
9
Arduino library with interpolated lookup for sin() and cos(). Trades speed for accuracy.
10
10
11
+
11
12
## Description
12
13
13
14
**Warning: The library trades speed for accuracy so use at own risk**
@@ -22,6 +23,7 @@ due to the folding.
22
23
23
24
The **i** in the names stands for **int** and **interpolated** as the core is using integer math and lookuptable of 91 uint16_t = 182 bytes. By folding and mirroring the whole 360 degrees and beyond can be handled. When **isin(x)** is called and ```x == int(x)``` then the library will not interpolate and this will improve performance. When x is not a whole number the library will linear interpolate between **isin(int(x))** and **isin(int(x+1))**. Of course this introduces an error but it is quite fast (which was the goal).
24
25
26
+
25
27
#### Lookup tables
26
28
27
29
The lookup tables are optimized (sketch provided) to minimize the error when using the interpolation, this implies that the points in the table might not be optimal when you use only wholde degrees. A sketch that generates lookup tables is in the examples folder. This generator sketch can also generate tables with different resolution e.g. 24, 14, 12 or even 6, 5 or 4 bit lookup tables. So depending on the application these tables can be ideal, but verify they meet your requirements.
@@ -37,18 +39,20 @@ Although the tables can be written to, it is advised not to do so.
37
39
38
40
*OK, the optimize example does a write to improve the table to minimize errors*
39
41
42
+
40
43
## Performance isin icos itan
41
44
42
45
time in us - calls 0 - 360 step 1 degree and calls 720 - 1080 (lib version 0.1.5)
46
+
(clock speeds in MHz)
43
47
44
-
| function | UNO 16MHz| ESP32 240 MHz | UNO (720-1080) | ESP (720-1080) |
45
-
|:----:|:----:|:----:|:----:|:----:|
46
-
| sin |120.43 | 10.90 |124.19 |10.91 |
47
-
| isin |44.24 | 1.09 | 85.00 | 1.11 |
48
-
| cos |120.27 | 10.81 |123.98 |10.83 |
49
-
| icos |51.40 | 1.16 | 91.42 | 1.18 |
50
-
| tan |147.59 | 18.07 |151.39 |18.07 |
51
-
| itan |126.73 | 1.31 |129.93 | 1.29 |
48
+
| function | UNO 16| ESP32 240 | UNO (720-1080) | ESP (720-1080) |
0 commit comments