trig.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* trig.h - Trigonometric function support. */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2008 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef GRUB_TRIG_HEADER
  20. #define GRUB_TRIG_HEADER 1
  21. #define GRUB_TRIG_ANGLE_MAX 256
  22. #define GRUB_TRIG_ANGLE_MASK 255
  23. #define GRUB_TRIG_FRACTION_SCALE 16384
  24. extern const short grub_trig_sintab[];
  25. extern const short grub_trig_costab[];
  26. static __inline int
  27. grub_sin (int x)
  28. {
  29. x &= GRUB_TRIG_ANGLE_MASK;
  30. return grub_trig_sintab[x];
  31. }
  32. static __inline int
  33. grub_cos (int x)
  34. {
  35. x &= GRUB_TRIG_ANGLE_MASK;
  36. return grub_trig_costab[x];
  37. }
  38. #endif /* ! GRUB_TRIG_HEADER */