home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / radiance / simplerd.lha / simplerad / FinalFTP / WalkT / misc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-20  |  2.6 KB  |  82 lines

  1. /**********************************************************************/
  2. /* misc.h : miscellaneous variables and constants                     */
  3. /*                                                                    */
  4. /* Copyright (C) 1992, Bernard Kwok                                   */
  5. /* All rights reserved.                                               */
  6. /* Revision 1.0                                                       */
  7. /* May, 1992                                                          */
  8. /**********************************************************************/
  9. #ifndef MISC_H
  10. #define MISC_H
  11.  
  12. /* Miscellaneous constants */
  13. #ifndef ERROR
  14. #define ERROR -1
  15. #endif /* ERROR */
  16.  
  17. #ifndef OK
  18. #define OK 1
  19. #endif /* OK */
  20.  
  21. #ifndef TRUE
  22. #define TRUE 1
  23. #endif /* TRUE */
  24.  
  25. #ifndef FALSE
  26. #define FALSE 1
  27. #endif /* FALSE */
  28.  
  29. #ifndef NULL
  30. #define NULL 0
  31. #endif /* NULL */
  32.  
  33. /**********************************************************************/
  34.  
  35. #define X 0
  36. #define Y 1
  37. #define Z 2
  38. #define ANGLE_SHOCK_ABSORBER (0.4)
  39. #define COORD_SHOCK_ABSORBER (0.04)
  40. #define MIN_VECTOR_LENGTH    (1.0e-7)      /* min length of a vector */
  41. #define UP    1                          /* define up / down direction */
  42. #define DOWN    2
  43. #define UNIVERSE         (1e10)            /* maximum environment size */
  44. #define MAX_RESOLUTION   (4096)            /* maximum screen resolution */
  45.  
  46. #define VERY_SMALL       (1e-5)
  47. #define DAMN_SMALL       (1e-10)
  48. #define VERY_LARGE       (1e+5)
  49. #define DAMN_LARGE       (1e+10)
  50. #define PI               (3.14159265358979323846)
  51. #define HALFLIFE         (-.69314718)
  52.  
  53. #define ABS(x)           (((x) > 0) ? (x) : (0 - (x)))
  54. #define FABS(a)         (((a) >= 0.0) ? (a): (-a))
  55. #define SCAN_INT(a,b)     (a == NULL ? 0 : sscanf(a,"%ld",b))
  56. #define FLOOR(a)     ((a)>0 ? (int)(a) : -(int)(-a))
  57. #define CEILING(a)  ((a)==(int)(a) ? (a) : (a)>0 ? 1+(int)(a) : -(1+(int)(-a)))
  58. #define ROUND(a)    ((a)>0 ? (int)(a+0.5) : -(int)(0.5-a))        
  59. #define ZSGN(a)        (((a)<0) ? -1 : (a)>0 ? 1 : 0)    /* sign of -1,0,1 */
  60. /* take binary sign of a, either -1, or 1 if >= 0 */
  61. #define SGN(a)        (((a)<0) ? -1 : 0)
  62. /* shout if something that should be true isn't */
  63. #define ASSERT(x) \
  64. if (!(x)) fprintf(stderr," Assert failed: x\n");
  65. /* square a */
  66. #define SQR(a)        ((a)*(a))    
  67.  
  68. #define MIN(a,b)    (((a)<(b))?(a):(b))    
  69. #define MAX(a,b)    (((a)>(b))?(a):(b))    
  70. #define SWAP(a,b)    { a^=b; b^=a; a^=b; }
  71. /* linear interpolation from l (when a=0) to h (when a=1)*/
  72. /* (equal to (a*h)+((1-a)*l) */
  73. #define LERP(a,l,h)    ((l)+(((h)-(l))*(a)))
  74. /* clamp the input to the specified range */
  75. #define CLAMP(v,l,h)    ((v)<(l) ? (l) : (v) > (h) ? (h) : v)
  76.  
  77. #define MAX_ARG        25
  78. #define CONTINUE 0
  79. #define DIE 1
  80.  
  81. #endif /* MISC_H */
  82.