1.4.3.14 _LIBQ_Q2_13_atan2_Q7_8 Function
Calculates the value of atan2(y, x).
Description
_Q2_13 _LIBQ_Q2_13_atan2_Q7_8 (_Q7_8 y, _Q7_8 x);
Calculates the atan2(y, x), where y and x are of type _Q7_8 and the resulting value is of type _Q2_13. The output value will be radians in the range pi >= result >= -pi.
Preconditions
None.
Parameters
y The _Q7_8 input value from which to calculate atan2(y, x).
x The _Q7_8 input value from which to calculate atan2(y, x).
Returns
_LIBQ_Q2_13_atan2_Q7_8 returns the _Q2_13 fixed point result from the calculation atan2(y, x).
Remarks
The function _LIBQ_Q16Div is called by this routine and thus must be linked into the executable image.
Execution Time (cycles): 220 typical (22 to 250)
Program Memory 288 bytes
Error <= 0.00012207 (accurate to least significant _Q2_13 bit)
Example
_Q2_13 resultAtan2; resultAtan2 = _LIBQ_Q2_13_atan2_Q7_8 ((_Q7_8)0x589d, (_Q7_8)0xf878); _//_ __LIBQ_Q2_13_atan2_Q7_8(88.613281, -7.531250) = 1.655518 (0x34fa)_
C
_Q2_13 _LIBQ_Q2_13_atan2_Q7_8 (_Q7_8 y , _Q7_8 x );