I can't help with the inverse stuff but I did just cobble together a SIN/COS/TAN function lookup table in Java to show one of the students how it could be done. Remember, it's java, so you'll have to adjust the parameters and the data types as appropriate (signed, unsigned, etc).
Code:
/*
* Main.java
*
* Created on February 16, 2007, 12:54 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package triglookup;
/**
* Table Values provided from: http://www.industrialpress.com/en/tabid/63/default.aspx
* @author purduePhotog
*/
public class Main {
//TRIGTAB is x1000 values for added precision.
private static int[] TRIGTAB = {0,17,35,52,70,87,105,122,139,156,174,191,208,225,242,259,276,292,309,326,342,358,375,391,407,423,438,454,469,485,500,515,530,545,559,574,588,602,616,629,643,656,669,682,695,707,719,731,743,755,766,777,788,799,809,819,829,839,848,857,866,875,883,891,899,906,914,921,927,934,940,946,951,956,961,966,970,974,978,982,985,988,990,993,995,996,997,998,999,1000,1000};
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//Test the values of each function:
//int n = -360;
int n = 0;
while (n <= 365) {
System.err.println("Angle Test: " + n + "\tTAN: " + (double) TAN(n*100) / 1000);
n = n + 5;
}
}
//Expects ANG to be x100
//public signed int SIN( signed long ANG, int SCALE) {
public static int SIN(long ANG) {
//Get us in the proper range for Sin to work.
while (ANG > 36000) {
ANG=ANG - 36000;
}
while (ANG < 0) {
ANG= ANG + 36000;
}
//if we're from 0-90 (0-9000) then we simply return the lookup value
if (ANG <= 9000 ) {
return (TRIGTAB[(int)ANG/100]);
} else if ((ANG > 9000) && (ANG <= 18000) ) {
return (TRIGTAB[180 - (int)ANG/100]);
} else if (( ANG > 18000) && (ANG <= 27000) ) {
return (-1 * TRIGTAB[(int)ANG/100 - 180]);
} else {
return (-1 * TRIGTAB[360 - (int)ANG/100]);
}
}
//Expects ANG to be x100
public static int COS(long ANG) {
//Simply offset the SIN by 90 degrees phase
return (SIN(9000 + ANG));
}
//Expects ANG to be x100
public static int TAN(long ANG) {
//Simply offset the SIN by 90 degrees phase for COS
int cosResult = COS(ANG);
int sinResult = SIN(ANG);
if (cosResult == 0) {
cosResult = 1;
}
return ( sinResult * 1000 / cosResult );
}
}