Updated fix16_atan, now removes some un-necessary code.

Added FIXMATH_NO_ROUNDING macro to disable rounding, currently only applies to fix16_atan but will change to apply this to other operations (namely mul/div) too.
Changed optimization options for rel build in code::blocks project.
This commit is contained in:
flatmush 2011-02-24 17:18:08 +00:00
parent 3fc97475e1
commit d829f83d31
2 changed files with 17 additions and 11 deletions

View File

@ -87,9 +87,14 @@ fix16_t fix16_atan2(fix16_t inY , fix16_t inX) {
int64_t angle;
angle = (4216574283LL * -i) / j;
is = (i * i);
is = (is + (1LL << 15)) >> 16;
js = (j * j);
#ifdef FIXMATH_NO_ROUNDING
is >>= 16;
js >>= 16;
#else
is = (is + (1LL << 15)) >> 16;
js = (js + (1LL << 15)) >> 16;
#endif
if((is | js) >> 32) {
if((is | js) >> 40) {
is >>= 16;
@ -100,22 +105,22 @@ fix16_t fix16_atan2(fix16_t inY , fix16_t inX) {
}
}
is = (is * i);
is = (is + (1LL << 15)) >> 16;
js = (js * j);
#ifdef FIXMATH_NO_ROUNDING
is >>= 16;
js >>= 16;
#else
is = (is + (1LL << 15)) >> 16;
js = (js + (1LL << 15)) >> 16;
if((is | js) >> 50) {
if((is | js) >> 57) {
is >>= 14;
js >>= 14;
} else {
is >>= 7;
js >>= 7;
}
}
#endif
is = is * 51472LL;
angle += (is / js) << 14;
angle += (inX >= 0 ? 3373259426LL : 10119778278LL);
#ifdef FIXMATH_NO_ROUNDING
angle >>= 16;
#else
angle = (angle + (1LL << 15)) >> 16;
#endif
angle = (inY < 0 ? -angle : angle);
#ifndef FIXMATH_NO_CACHE

View File

@ -16,6 +16,7 @@
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="-DFIXMATH_NO_CACHE" />
</Compiler>
</Target>
<Target title="rel">