1.4.3.6 _LIBQ_Q16_tan_Q2_29 Function

Calculates the value of tan(x).

Description

_Q16 _LIBQ_Q16_tan_Q2_29 (_Q2_29 x);

Calculates the tan(x), where x is of type _Q2_29 radians and the resulting value is of type _Q16.

Preconditions

None

Parameters

x The _Q2_29 input value from which to calculate tan(x).

Returns

_LIBQ_Q16_tan_Q2_29 returns the _Q16 fixed point result from the calculation tan(x). The resulting value is saturated.

Remarks

The functions _LIBQ_Q31_sin_Q2_29, _LIBQ_Q31_cos_Q2_29, and _LIBQ_Q16Div are called by this routine and thus must be linked into the executable image.

Execution Time (cycles): 703 typical (22 to 796)

Program Memory 88 bytes

Error <= 0.000015259 (accurate to least significant _Q16 bit for the input range -1.568 .. 1.568)

Error rises from 0.0 to 0.065 for the input range (-1.568 .. -1.570765808 and 1.568 .. 1.570765808)

Example

_Q16 resultTan;

resultTan = _LIBQ_Q16_tan_Q2_29 ((_Q2_29)0x16720c36); 

_// _LIBQ_Q16_tan_Q2_29( 0.701421838) =_ _0.844726562 (0x0000d840)_

C

_Q16 _LIBQ_Q16_tan_Q2_29 (_Q2_29 x );