diff options
author | Tectu <joel@unormal.org> | 2012-07-22 22:28:28 +0200 |
---|---|---|
committer | Tectu <joel@unormal.org> | 2012-07-22 22:28:28 +0200 |
commit | af3c8f87b702a99f0b82f3d1d3b656a8c9fa4cf0 (patch) | |
tree | b1723603d50d5cdca05d6f2d847646f0b34ef1e9 /glcd/fastMath.c | |
parent | 2e6d8615cf55e37ecf68c0c108d2a303c3800ef9 (diff) | |
download | uGFX-af3c8f87b702a99f0b82f3d1d3b656a8c9fa4cf0.tar.gz uGFX-af3c8f87b702a99f0b82f3d1d3b656a8c9fa4cf0.tar.bz2 uGFX-af3c8f87b702a99f0b82f3d1d3b656a8c9fa4cf0.zip |
fastMath cleanup
Diffstat (limited to 'glcd/fastMath.c')
-rw-r--r-- | glcd/fastMath.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/glcd/fastMath.c b/glcd/fastMath.c index 26ae0d3f..1957b304 100644 --- a/glcd/fastMath.c +++ b/glcd/fastMath.c @@ -116,44 +116,39 @@ float sintable[91] = { }; -float getSin(unsigned int degree) -{ +float getSin(unsigned int degree) { degree = degree % 360; - if(degree <= 90) - { + + if(degree <= 90) { return sintable[degree]; } - else if(degree <= 180) - { + else if(degree <= 180) { return sintable[180-degree]; } - else if(degree <= 270) - { + else if(degree <= 270) { return sintable[degree-180]*(-1.0); } - else - { + else { return sintable[360-degree]*(-1.0); } } -double getCos(unsigned int degree) -{ +double getCos(unsigned int degree) { degree = degree % 360; + return getSin(degree+90); } /* signum function */ -char sgn(char x){ +char sgn(char x) { return (x > 0) ? 1 : (x < 0) ? -1 : 0; } -unsigned char max(unsigned char a, unsigned char b) -{ +unsigned char max(unsigned char a, unsigned char b) { return (a<b) ? b : a; } -unsigned char min (unsigned char a, unsigned char b) -{ +unsigned char min (unsigned char a, unsigned char b) { return (a<b) ? a : b; } + |