Last active
October 9, 2019 15:50
-
-
Save kevinmoran/c15263a8517ff43d783b25a49b4d7770 to your computer and use it in GitHub Desktop.
Sin Approximation
This file contains hidden or 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
// From: https://web.archive.org/web/20080228213915/http://www.devmaster.net/forums/showthread.php?t=5784 | |
float sinApprox(float x) | |
{ | |
const float kPI32 = 3.14159265359f; | |
const float B = 4/kPI32; | |
const float C = -4/(kPI32*kPI32); | |
float y = B * x + C * x * abs(x); | |
#ifdef EXTRA_PRECISION | |
//const float Q = 0.775; | |
const float P = 0.225; | |
y = P * (y * abs(y) - y) + y; // Q * y + P * y * abs(y) | |
#endif | |
return y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment