home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Graphics / graphics-16000.iso / msdos / raytrace / rayshade / src / common.h < prev    next >
C/C++ Source or Header  |  1992-04-30  |  3KB  |  133 lines

  1. /*
  2.  * common.h
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * $Id: common.h,v 4.0.1.1 91/11/26 21:34:27 cek Exp Locker: cek $
  17.  *
  18.  * $Log:    common.h,v $
  19.  * Revision 4.0.1.1  91/11/26  21:34:27  cek
  20.  * patch3: Added EPSILON definition, redefine equal() macro.
  21.  * 
  22.  * Revision 4.0  91/07/17  14:30:18  kolb
  23.  * Initial version.
  24.  * 
  25.  */
  26. #ifndef COMMON_H 
  27. #define COMMON_H
  28.  
  29. #include <stdio.h>
  30. #include <math.h>
  31. #ifdef I_STDLIB
  32. #include <stdlib.h>
  33. #endif
  34.  
  35. #if defined(__WATCOMC__) || defined(__BORLANDC__)
  36. #ifndef HUGE
  37. #define HUGE    HUGE_VAL
  38. #endif
  39. #include <stdlib.h>
  40. #endif
  41.  
  42. #include "config.h"
  43.  
  44. typedef double Float;
  45.  
  46. #if (VOIDFLAGS & 8) == 8
  47. typedef void * voidstar;
  48. #else
  49. typedef char * voidstar;
  50. #endif
  51.  
  52. #include "expr.h"
  53. #include "vector.h"
  54. #include "ray.h"
  55. #include "color.h"
  56. #include "transform.h"
  57. #include "error.h"
  58.  
  59. #ifndef TRUE
  60. #define TRUE        1
  61. #endif
  62.  
  63. #ifndef FALSE
  64. #define FALSE        0
  65. #endif
  66.  
  67. /*
  68.  * Various useful constants and macros.
  69.  */
  70.  
  71. /*
  72.  * Minimum vector length & fp value.
  73.  * Modify depending upon Float typedef.
  74.  */
  75. #define EPSILON        (Float)0.00001
  76.  
  77. #ifndef PI
  78. #define    PI        3.14159265358979323846
  79. #endif
  80. #define TWOPI        (2. * PI)
  81. #define INV_TWOPI    (1. / TWOPI)
  82. #define deg2rad(x)    (Float)(x * PI/180.)
  83. #define LNHALF        (-.69314718)
  84.  
  85. #ifndef NULL
  86. #    define NULL 0
  87. #endif
  88.  
  89. #define UNSET        -1
  90.  
  91. /*
  92.  * Some systems, such as the RS6000, have fast fabs already defined.
  93.  */
  94. #ifndef fabs
  95. extern Float RSabstmp;
  96. #define fabs(x)         ((RSabstmp=x) < 0 ? -RSabstmp : RSabstmp)
  97. #endif
  98.  
  99. #ifdef MULTIMAX
  100. /*
  101.  * On the multimax, allocate large pieces of memory as shared memory.
  102.  */
  103. extern char *share_malloc(), *share_calloc();
  104. #else
  105. /*
  106.  * Otherwise, malloc is malloc, etc.
  107.  */
  108. #define share_malloc(x)        RayMalloc(x)
  109. #define share_calloc(x,y)    Calloc(x,y)
  110. #endif
  111.  
  112. /*
  113.  * Close enough for us.
  114.  */
  115. #define equal(a, b)        (fabs((a) - (b)) < EPSILON)
  116. /*
  117.  * Maximum/Minimum functions
  118.  */
  119.  
  120. #if !defined(__WATCOMC__) && !defined(__BORLANDC__)
  121. #define max(a, b)        ((a) > (b) ? (a) : (b))
  122. #define min(a, b)        ((a) < (b) ? (a) : (b))
  123. #endif
  124.  
  125. extern voidstar RayMalloc(), Calloc();
  126. extern char    *strsave();
  127.  
  128. #ifndef __WATCOMC__
  129. extern double    drand48();    /* just in case */
  130. #endif
  131.  
  132. #endif /* COMMON_H */
  133.