/* CORDICSin uses the CORDIC algorithm to compute sin(x) */ #include "CORDIC.h" float CORDICSin(float x){ unsigned int n, MaxNum; int i, bit; float c,s,z; /* Converting the float to a fixed point binary format This value measn that the largest fixed point number is 010000...000000 */ MaxNum=64*256*256*256; n = FloatToFixed(x, MaxNum); /* Initializing CORDIC Cos, Sin, and Z values */ c=1.0;s=0.0;z=0.0; /* Updating the CORDIC Cos, Sin, and Z values according to the algorithm when there is a 1 in the binary bit string n */ for(i=29;i>=0;i--){ bit=(n>>i)&1; if(bit==1) CORDICUpdate(&c,&s,&z,29-i); }; return s; };