trig.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2023 Daniele Lacamera <root@danielinux.net>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <math.h>
  18. #include <stdint.h>
  19. #ifndef TRIG_H
  20. #define TRIG_H
  21. extern const float PreCalcCos[], PreCalcSin[];
  22. extern const short PreCalcAtan[81][81];
  23. static inline float psin(int x)
  24. {
  25. int a = x + 180;
  26. if (a >= 360)
  27. a-=360;
  28. return (PreCalcSin[a]);
  29. }
  30. static inline float pcos(int x)
  31. {
  32. int a = x + 180;
  33. if (a >= 360)
  34. a-=360;
  35. return (PreCalcCos[a]);
  36. }
  37. static inline int16_t p_atan2(int x, int y)
  38. {
  39. return PreCalcAtan[x,y];
  40. }
  41. #endif