home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 015.lha / tracer_source / macros.h < prev    next >
C/C++ Source or Header  |  1986-11-10  |  1KB  |  72 lines

  1. /*
  2.     macros.h
  3.  
  4.     some of the most important stuff in the program
  5. */
  6.  
  7. #ifndef    MYMATH_H
  8. # include "MyMath.h"
  9. #endif
  10.  
  11. /* returns dot product of two vectors */
  12. #define DOT(v1,v2)    (\
  13.     SPAdd(\
  14.         SPAdd(\
  15.             SPMul(v1.x, v2.x),\
  16.             SPMul(v1.y, v2.y)\
  17.         ),\
  18.         SPMul(v1.z, v2.z)\
  19.     )\
  20. )
  21.  
  22.  
  23. /* returns the square of the length of a vector */
  24. #define LN2(v)    (DOT(v,v))
  25.  
  26.  
  27. /* guess */
  28. #define LEN(v)    SPSqrt(LN2(v))
  29.  
  30.  
  31. /* returns the component in the xz plane of a vector */
  32. #define XZL(v)    SPSqrt(\
  33.             SPAdd(\
  34.                 SPMul(v.x, v.x),\
  35.                 SPMul(v.z, v.z)\
  36.             )\
  37.         )
  38.  
  39.  
  40. /* multiplies a vetor by a scalar */
  41. #define SCMLT(sc,vct)    vct.x = SPMul(vct.x, sc);\
  42.             vct.y = SPMul(vct.y, sc);\
  43.             vct.z = SPMul(vct.z, sc);\
  44.             vct.l = SPMul(vct.l, sc);
  45.  
  46.  
  47. /* makes a vector. wouldn't need this with c++ */
  48. #define MV(a,b,c,v)    v.x= a;v.y= b;v.z= c;
  49.  
  50.  
  51. /*subtract vector t=u-v */
  52. #define SV(t,u,v)    t.x=SPSub(v.x, u.x);\
  53.             t.y=SPSub(v.y, u.y);\
  54.             t.z=SPSub(v.z, u.z);
  55.  
  56.  
  57. /* add vector t=u+v */
  58. #define AV(t,u,v)    t.x=SPAdd(u.x, v.x);\
  59.             t.y=SPAdd(u.y, v.y);\
  60.             t.z=SPAdd(u.z, v.z);
  61.  
  62.  
  63. /* multiply transpose matrix by vector. v1=m*v2 */
  64. #define MTV(v1,m,v2)    MV( DOT(m.x,v2), DOT(m.y,v2), DOT(m.z,v2), v1)
  65.  
  66.  
  67. /* levels of recursion */
  68. #define LEVEL 5
  69.  
  70. /* don't want as many inside the ball, takes forever as it is */
  71. #define RLEV  3
  72.