#include #include #include #include #define PI 3.14159265358979 #define LENGTH 32 #define MILLISECOND 1000000.0 //computes sin(x) using the CORDIC algorithm float cordicSin(float x); //computes sin(x) using a truncated Maclaurin polynomial of order 6 // sin(x) = x - (x^3)/6 + x^5/120 double maclaurinPoly(double x); //converts a float to binary unsigned int floatToBin(float x); //prints bin as binary 0's and 1's int binPrint(unsigned int bin); //recursive method for solving sin // argument "bin" is binary representing floating point number // example if float is 0.5 then bin = 1 // if float is 0.25 then bin = 2 // // sin(a+b) = sin(a) cos(b) + cos(a) sin (b) // where sin(a), and cos(a) are retrieved from a table of pre-calculated sines and cosines // cos(b), and sin(b) are called recursivly float sinRec(unsigned int bin); //recursive method for solving cos // argument "bin" is binary representing floating point number // example if float is 0.75 then bin = 3 // if float is 0.125 then bin = 4 // // cos(a+b) = cos(a) cos(b) - sin(a) sin(b) // where sin(a), and cos(a) are retrieved from a table of pre-calculated sines and cosines // cos(b), and sin(b) are called recursivly float cosRec(unsigned int bin);