home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Zone / VRZONE.ISO / mac / PC / REND386 / JIREND / INTMATH.H < prev    next >
C/C++ Source or Header  |  1993-04-11  |  4KB  |  112 lines

  1. /* Matrix math, assembly by Dave Stampe */
  2. /* Protoypes for matrix and integer math routines */
  3.   
  4. /* Copyright 1992 by Dave Stampe and Bernie Roehl.
  5.    May be freely used to write software for release into the public domain;
  6.    all commercial endeavours MUST contact Bernie Roehl and Dave Stampe
  7.    for permission to incorporate any part of this software into their
  8.    products!
  9.  */
  10.   
  11. /* Contact: broehl@sunee.waterloo.edu or dstampe@sunee.waterloo.edu */
  12.  
  13. extern void fill_sine(void);
  14. extern void fill_sclip(void);
  15. extern void fill_sqrt(void);
  16.   
  17. extern long isine(long angle);
  18. extern long icosine(long angle);
  19. extern long arcsine(long x);
  20. extern long arccosine(long x);
  21. extern long arctan2(long y, long x);
  22.   
  23.    /* Create rotation/translation "matrix" from angle data.  */
  24.    /* Can only be used after setup_render() has been called */
  25. extern void std_matrix(MATRIX m,
  26.    long rx, long ry, long rz,
  27.    long tx, long ty, long tz);
  28.   
  29. #define RXYZ 1    /* matrix rotation types */
  30. #define RYXZ 0          /* ONLY RYXZ guaranteed to be tested */
  31. #define RXZY 2
  32. #define RZYX 5
  33. #define RZXY 4
  34. #define RYZX 6
  35.   
  36. extern void multi_matrix(MATRIX m, long rx, long ry, long rz,
  37. long tx, long ty, long tz, int type );
  38.   
  39.    /* multiplies upper left 3x3 submatrices A and B giving C */
  40. extern void matrix_mult(MATRIX a, MATRIX b, MATRIX c);
  41.   
  42.    /* multiplies matrices: A*B->C */
  43. extern void matrix_product(MATRIX a, MATRIX b, MATRIX c);
  44.   
  45.    /* rotate & translate XYZ by matrix */
  46. extern void matrix_point(MATRIX m, long *xp, long *yp, long *zp);
  47.   
  48.    /* rotate XYZ by matrix */
  49. extern void matrix_rotate(MATRIX m, long *xp, long *yp, long *zp);
  50.   
  51.    /* generate inverse of rotate matrix (transpose) */
  52.    /* ONLY WORKS FOR ORTHOGONAL MATRICES */
  53. extern void matrix_transpose(MATRIX a, MATRIX b);
  54.   
  55.    /* generate inverse of rotate/translate matrix */
  56. extern void inverse_matrix(MATRIX a, MATRIX b);
  57.   
  58.       /* use "matrix" to compute world coords from object coords for obj */
  59. extern void apply_matrix(OBJECT *obj, MATRIX m);
  60.   
  61.       /* move bounds sphere only */
  62. extern void matmove_osphere(OBJECT *obj, MATRIX m);
  63.   
  64.       /* move all of rep's polys, vertices */
  65. extern void matmove_rep(REP *rep, MATRIX m);
  66.   
  67.       /* create identity matrix */
  68. extern void identity_matrix(MATRIX m);
  69.   
  70.       /* copy matrix */
  71. extern void matrix_copy(MATRIX s, MATRIX d);
  72.   
  73.    /* copies upper left 3x3 submatrix, zeros translation part (bottom row) */
  74. extern void matrix_rot_copy(MATRIX s, MATRIX d);
  75.   
  76.    /* perform multiplication of <3.29> matrix elements */
  77. extern long m_mult(long a, long b);
  78.   
  79.    /* returns (ax+by+cz)>>29) */
  80. extern long dot_prod_29(long a, long b, long c, long x, long y, long z);
  81.   
  82.    /* returns (ax+cz+d)/-b) */
  83. extern long plane_y(long a, long b, long c, long d, long x, long z);
  84.   
  85.    /* returns >65536 if not in sphere     */
  86.    /* else ((D/R)^2)<<16 ratio to find    */
  87.    /* closest to center (choose smallest) */
  88. extern long sphere_pretest(OBJECT *obj, long x, long y, long z);
  89.   
  90.    /* makes matrix that will xform Z axis to given vector */
  91. extern void vector_to_matrix(MATRIX m, long x, long y, long z);
  92.   
  93. extern void matrix_to_angle(MATRIX m, long *rx, long *ry, long *rz);
  94.   
  95. extern void cross_column(MATRIX m, int col);
  96.   
  97. extern long big_dist(long x1, long y1, long z1,
  98.    long x2, long y2, long z2);
  99.   
  100. extern int find_normal(long x1, long y1, long z1,
  101.    long x2, long y2, long z2,
  102.    long x3, long y3, long z3,
  103.    long *xn, long *yn, long *zn);
  104.   
  105. /* rescale matrix: do every 1000 mults or so */
  106. extern void fix_matrix_scale(MATRIX m);
  107.   
  108. extern long scale_16(long s, long a, long x);  /* s*(x+a) */
  109. extern long calc_scale_16(long a, long b, long s);  /* 2s/(a-b) */
  110.   
  111. /* End of intmath.h */
  112.