Bayley Wang
/
priustroller
Prius IPM controller
Fork of analoghalls5_5 by
Diff: util/fastmath.cpp
- Revision:
- 11:dccbaa9274c5
- Parent:
- 9:d3b70c15baa9
diff -r b4abecccec7a -r dccbaa9274c5 util/fastmath.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util/fastmath.cpp Sun Mar 08 08:37:38 2015 +0000 @@ -0,0 +1,21 @@ +#include "includes.h" +#include "fastmath.h" +#include "lut.h" + +float FastMath::FastSin(float theta) { + if (theta < 0.0f) theta += 360.0f; + if (theta >= 360.0f) theta -= 360.0f; + return 2.0f * sinetab[(int) theta] - 1.0f; +} + +float FastMath::FastCos(float theta) { + return FastSin(90.0f - theta); +} + +float FastMath::FastSin01(float theta) { + return FastSin(theta) * 0.5f + 0.5f; +} + +float FastMath::FastCos01(float theta) { + return FastCos(theta) * 0.5f + 0.5f; +} \ No newline at end of file