Guest User

Untitled

a guest
Jul 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. y_abs = fabsf(y);
  2. x_abs = fabsf(x);
  3.  
  4. if(!((y_abs > 0.0f) || (x_abs > 0.0f)))
  5. return 0.0;
  6.  
  7. if(y_abs < x_abs)
  8. z = y_abs / x_abs;
  9. else
  10. z = x_abs / y_abs;
  11.  
  12. /* when ratio approaches the table resolution, the angle is */
  13. /* best approximated with the argument itself... */
  14. if(z < TAN_MAP_RES)
  15. base_angle = z;
  16. else {
  17. /* find index and interpolation value */
  18. alpha = z * (float)TAN_MAP_SIZE;
  19. index = ((int)alpha) & 0xff;
  20. alpha -= (float)index;
  21. /* determine base angle based on quadrant and */
  22. /* add or subtract table value from base angle based on quadrant */
  23. base_angle = fast_atan_table[index];
  24. base_angle += (fast_atan_table[index + 1] - fast_atan_table[index]) * alpha;
  25. }
Add Comment
Please, Sign In to add comment