In the case you need float result and accept resolution of whole degrees, sin can be looked up with this code. If you need int (not float) numbers or smaller table, the code can be easily modified:
/**
* Sinus lookup table
* The table only covers whole degrees lookup, and only in I. quarter of the circle. The remaining three quarters
* of the circle are figured out with logic.
*/
const float sinus_I_quarter[91] =
{
0.0000, 0.0175, 0.0349, 0.0523, 0.0698, 0.0872, 0.1045, 0.1219, 0.1392, 0.1564, // 00 .. 09
0.1736, 0.1908, 0.2079, 0.2250, 0.2419, 0.2588, 0.2756, 0.2924, 0.3090, 0.3256, // 10 .. 19
0.3420, 0.3584, 0.3746, 0.3907, 0.4067, 0.4226, 0.4384, 0.4540, 0.4695, 0.4848, // 20 .. 29
0.5000, 0.5150, 0.5299, 0.5446, 0.5592, 0.5736, 0.5878, 0.6018, 0.6157, 0.6293, // 30 .. 39
0.6428, 0.6561, 0.6691, 0.6820, 0.6947, 0.7071, 0.7193, 0.7314, 0.7431, 0.7547, // 40 .. 49
0.7660, 0.7771, 0.7880, 0.7986, 0.8090, 0.8192, 0.8290, 0.8387, 0.8480, 0.8572, // 50 .. 59
0.8660, 0.8746, 0.8829, 0.8910, 0.8988, 0.9063, 0.9135, 0.9205, 0.9272, 0.9336, // 60 .. 69
0.9397, 0.9455, 0.9511, 0.9563, 0.9613, 0.9659, 0.9703, 0.9744, 0.9781, 0.9816, // 70 .. 79
0.9848, 0.9877, 0.9903, 0.9925, 0.9945, 0.9962, 0.9976, 0.9986, 0.9994, 0.9998, // 80 .. 89
1.0000 // 90
};
#define CIRCLE_QUARTER_1 1
#define CIRCLE_QUARTER_2 2
#define CIRCLE_QUARTER_3 3
#define CIRCLE_QUARTER_4 4
/**
* The function converts passed angle into 0..89 degrees and looks up a corresponding sin() value.
* After lookup the return value is adjusted depending what was the original passed angle by figuring
* out belonging to circle quarter I., II, II. or IV.
* Any angle outside the accepted angle range of 0 .. 359 will be automatically corrected.
*
* @param angle Whole angle in degrees as used in mathematics: 0 degrees is EAST (in meteorology, 0 degrees wind is NORTH)
* @return The looked-up 4-decimal points accurate sinus
*/
float sinus_lookup (unsigned int angle)
{
float sin_value;
unsigned int circle_quarter;
// correct angles outside the accepted angle range into 0 .. 359
if (angle > 359u)
angle = angle % 360u;
circle_quarter = 1 + (angle / 90u);
switch (circle_quarter)
{
case CIRCLE_QUARTER_1: // 00 .. 89
sin_value = sinus_I_quarter[angle];
break;
case CIRCLE_QUARTER_2: // 90 .. 179
sin_value = sinus_I_quarter[180 - angle];
break;
case CIRCLE_QUARTER_3: // 180 .. 269
sin_value = -sinus_I_quarter[angle - 180];
break;
case CIRCLE_QUARTER_4: // 270 .. 359
sin_value = -sinus_I_quarter[360 - angle];
break;
}
return sin_value;
}