|
搞好的定点的快速 ATAN2,测试有些问题!
flaot temp6=fix2float(arctan3(float2fix(1),float2fix(0)));
int32_t arctan33( int32_t y, int32_t x ) { const int32_t ONEQTR_PI = float2fix(M_PI / 4.0); const int32_t THRQTR_PI = float2fix(3.0 * M_PI / 4.0); const int32_t OP1 =float2fix(0.1963f); const int32_t OP2 =float2fix(0.9817f); const int32_t LEF =float2fix(1e-10f);
int32_t r, angle; int32_t abs_y = abs(y)+LEF; // kludge to prevent 0/0 condition
if ( x < 0 ) { r = fixdiv((x + abs_y) , (abs_y - x)); angle = THRQTR_PI; } else { r = fixdiv((x - abs_y) , (x + abs_y)); angle = ONEQTR_PI; } //angle =angle + (0.1963f * r * r - 0.9817f) * r;
angle += fixmulf( (fixmulf(OP1,fixmulf(r,r))- OP2), r);
if ( y < 0 ) return( -angle ); // negate if in quad III or IV else return( angle ); } |
|