Dealing with Q15 for arc Tan function

Status
Not open for further replies.

garimella

Full Member level 5
Joined
Aug 25, 2011
Messages
260
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
3,276
Hi

I am using dspic libq library to experiment with Q15 functions. The difficulty I am facing is that _Q15sinPI() and _Q15cosPI return in range -32768 to +32767 corresponding to -pi to +pi. But _Q15atanYByXByPI() deals only on -45 to +45 degrees and returns-8192 to +8192. This gives me only solutions to first and 4th quadrant. How do derive the arc tan for 2nd and 3rd quadrant?
 

The restriction is necessary due to Q15 number range. You get +/- 45..90 degree range by flipping x and y. Other two quadrants by manipulating x and y sign.
 

Hi

_Q15 y = Q15(0.866);
_Q15 x = Q15(0.5);

_Q15 check = _Q15atanYByXByPI(x,y);

returns 8192 ( 45 degrees) and not 60 degrees. Even if I flip , results are same
 
Last edited:

Can you share the link or lib file that works
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…