1.4.3.20 _LIBQ_Q2_29_atan2_Q16 Function

Calculates the value of atan2(y, x).

Description

_Q2_29 _LIBQ_Q2_29_atan2_Q16 (_Q16 y, _Q16 x);

Calculates the atan(y, x), where y and x are of type _Q16 and the resulting value is of type _Q2_29. The output value will be radians in the range pi >= result >= -pi.

Preconditions

None.

Parameters

y The _Q16 input value from which to calculate atan2(y, x).

x The _Q16 input value from which to calculate atan2(y, x).

Returns

_LIBQ_Q2_29_atan2_Q16 returns the _Q2_29 fixed point result from the calculation atan2(y, x).

Remarks

The C function __divdi3 is called by this routine and thus must be linked into the executable image.

Execution Time (cycles): 348 typical (20 to 376)

Program Memory 464 bytes

Error <= 0.000000003 (accurate within one least significant _Q2_29 bit)

Example

_Q2_29 resultAtan2;

resultAtan2 = _LIBQ_Q2_29_atan2_Q16 ((_Q16)0xf6276270, x(_Q16)0x34b4b4c0); 
_//_ __LIBQ_Q2_29_atan2_Q16(-2520.615479, 13492.706055) = -0.184684 (0xfa1710c7)_

C

_Q2_29 _LIBQ_Q2_29_atan2_Q16 (_Q16 y , _Q16 x );