-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace sine table with 5th order approximation
The previous implementation used the pre-calculated fixed-point arithmetic table for sine values, which added over 2 KiB to the code size. To solve this issue, I implemented the 5th order polynomial approximation for sine[1], which reduced the code size from 2556 bytes to 918 bytes (by about 65%) while maintaining acceptable error (RMS error is 8.866 observed with 0-90 degrees, 0-1024 in fixed-point representation) Besides, as several applications need the sine and cosine of the same angle, I replace all occurrences of twin_sin and twin_cos with the shortcut twin_sincos, including the code in the files src/path.c and src/matrix.c. [1]: https://www.nullhardware.com/blog/fixed-point-sine-and-cosine-for-embedded-systems/ Close #13
- Loading branch information
1 parent
db1162e
commit ef31d46
Showing
4 changed files
with
83 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters