1.4.4.1 CosInDegs Function

fract_q0d15_t CosInDegs( fract_q9d6_t theta );

Summary

Calculates fixed point Cos(theta) (Q0.15 fixed point), where theta is in degrees (Q8.6 fixed point)

Description

Calculates fixed point Cos(theta) (Q0.15 fixed point), where theta is in degrees (Q8.6 fixed point)

Preconditions

None

Parameters

theta Q9.6 fixed point angle

Returns

cos(theta) in Q0.15 fixed point

Remarks

CosInDegs uses SinInDegs.

Example

int32_t nTests = 400;

float theta;

float delta_theta = 360.0/(nTests-1);

float theta0 = 0;

int32_t i;

int32_t x;

for ( i = 0; i < nTests; i++ )

{

theta = theta0 + i*delta_theta;

x = theta*(32768/512); _//Q9.6_

printf("%d, %d rn",( int )x,CosInDegs(x));

}

C

fract_q0d15_t CosInDegs (fract_q9d6_t theta );