fastMath cleanup
This commit is contained in:
parent
2e6d8615cf
commit
af3c8f87b7
2 changed files with 15 additions and 19 deletions
|
@ -116,30 +116,26 @@ float sintable[91] = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float getSin(unsigned int degree)
|
float getSin(unsigned int degree) {
|
||||||
{
|
|
||||||
degree = degree % 360;
|
degree = degree % 360;
|
||||||
if(degree <= 90)
|
|
||||||
{
|
if(degree <= 90) {
|
||||||
return sintable[degree];
|
return sintable[degree];
|
||||||
}
|
}
|
||||||
else if(degree <= 180)
|
else if(degree <= 180) {
|
||||||
{
|
|
||||||
return sintable[180-degree];
|
return sintable[180-degree];
|
||||||
}
|
}
|
||||||
else if(degree <= 270)
|
else if(degree <= 270) {
|
||||||
{
|
|
||||||
return sintable[degree-180]*(-1.0);
|
return sintable[degree-180]*(-1.0);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
return sintable[360-degree]*(-1.0);
|
return sintable[360-degree]*(-1.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double getCos(unsigned int degree)
|
double getCos(unsigned int degree) {
|
||||||
{
|
|
||||||
degree = degree % 360;
|
degree = degree % 360;
|
||||||
|
|
||||||
return getSin(degree+90);
|
return getSin(degree+90);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,12 +144,11 @@ char sgn(char x){
|
||||||
return (x > 0) ? 1 : (x < 0) ? -1 : 0;
|
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;
|
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;
|
return (a<b) ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,13 @@
|
||||||
* Copyright: 2011 Roland Domke
|
* Copyright: 2011 Roland Domke
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FASTMATH_H_
|
#ifndef FASTMATH_H
|
||||||
#define FASTMATH_H_
|
#define FASTMATH_H
|
||||||
|
|
||||||
char sgn(char x);
|
char sgn(char x);
|
||||||
double getCos(unsigned int degree);
|
double getCos(unsigned int degree);
|
||||||
double getSin(unsigned int degree);
|
double getSin(unsigned int degree);
|
||||||
unsigned char max(unsigned char a, unsigned char b);
|
unsigned char max(unsigned char a, unsigned char b);
|
||||||
unsigned char min(unsigned char a, unsigned char b);
|
unsigned char min(unsigned char a, unsigned char b);
|
||||||
|
|
||||||
#endif /* FASTMATH_H_ */
|
#endif /* FASTMATH_H_ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue