tables.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Emacs style mode select -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // DESCRIPTION:
  18. // Lookup tables.
  19. // Do not try to look them up :-).
  20. // In the order of appearance:
  21. //
  22. // int finetangent[4096] - Tangens LUT.
  23. // Should work with BAM fairly well (12 of 16bit,
  24. // effectively, by shifting).
  25. //
  26. // int finesine[10240] - Sine lookup.
  27. // Guess what, serves as cosine, too.
  28. // Remarkable thing is, how to use BAMs with this?
  29. //
  30. // int tantoangle[2049] - ArcTan LUT,
  31. // maps tan(angle) to angle fast. Gotta search.
  32. //
  33. //-----------------------------------------------------------------------------
  34. #ifndef __TABLES__
  35. #define __TABLES__
  36. #ifdef LINUX
  37. #include <math.h>
  38. #else
  39. #define PI 3.141592657
  40. #endif
  41. #include "m_fixed.h"
  42. #define FINEANGLES 8192
  43. #define FINEMASK (FINEANGLES-1)
  44. // 0x100000000 to 0x2000
  45. #define ANGLETOFINESHIFT 19
  46. // Effective size is 10240.
  47. extern fixed_t finesine[5*FINEANGLES/4];
  48. // Re-use data, is just PI/2 pahse shift.
  49. extern fixed_t* finecosine;
  50. // Effective size is 4096.
  51. extern fixed_t finetangent[FINEANGLES/2];
  52. // Binary Angle Measument, BAM.
  53. #define ANG45 0x20000000
  54. #define ANG90 0x40000000
  55. #define ANG180 0x80000000
  56. #define ANG270 0xc0000000
  57. #define SLOPERANGE 2048
  58. #define SLOPEBITS 11
  59. #define DBITS (FRACBITS-SLOPEBITS)
  60. typedef unsigned angle_t;
  61. // Effective size is 2049;
  62. // The +1 size is to handle the case when x==y
  63. // without additional checking.
  64. extern angle_t tantoangle[SLOPERANGE+1];
  65. // Utility function,
  66. // called by R_PointToAngle.
  67. int
  68. SlopeDiv
  69. ( unsigned num,
  70. unsigned den);
  71. #endif
  72. //-----------------------------------------------------------------------------
  73. //
  74. // $Log:$
  75. //
  76. //-----------------------------------------------------------------------------