Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- y_abs = fabsf(y);
- x_abs = fabsf(x);
- if(!((y_abs > 0.0f) || (x_abs > 0.0f)))
- return 0.0;
- if(y_abs < x_abs)
- z = y_abs / x_abs;
- else
- z = x_abs / y_abs;
- /* when ratio approaches the table resolution, the angle is */
- /* best approximated with the argument itself... */
- if(z < TAN_MAP_RES)
- base_angle = z;
- else {
- /* find index and interpolation value */
- alpha = z * (float)TAN_MAP_SIZE;
- index = ((int)alpha) & 0xff;
- alpha -= (float)index;
- /* determine base angle based on quadrant and */
- /* add or subtract table value from base angle based on quadrant */
- base_angle = fast_atan_table[index];
- base_angle += (fast_atan_table[index + 1] - fast_atan_table[index]) * alpha;
- }
Add Comment
Please, Sign In to add comment