VECMAT.INC 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. ;
  2. ; $Source: f:/miner/source/vecmat/rcs/vecmat.inc $
  3. ; $Revision: 1.21 $
  4. ; $Author: matt $
  5. ; $Date: 1994/12/13 14:44:21 $
  6. ;
  7. ; Header file for vector/matrix library
  8. ;
  9. ; $Log: vecmat.inc $
  10. ; Revision 1.21 1994/12/13 14:44:21 matt
  11. ; Added vm_vector_2_matrix_norm()
  12. ;
  13. ; Revision 1.20 1994/09/11 19:23:04 matt
  14. ; Added vm_vec_normalized_dir_quick()
  15. ;
  16. ; Revision 1.19 1994/07/19 18:52:55 matt
  17. ; Added vm_vec_normalize_quick() and vm_vec_copy_normalize_quick()
  18. ;
  19. ; Revision 1.18 1994/06/16 18:24:31 matt
  20. ; Added vm_vec_mag_quick()
  21. ;
  22. ; Revision 1.17 1994/05/19 12:07:20 matt
  23. ; Fixed globals and macros and added a constant
  24. ;
  25. ; Revision 1.16 1994/05/18 22:28:55 matt
  26. ; Added function vm_vec_normalized_dir()
  27. ; Added C macros IS_ZERO_VEC(), vm_vec_zero(), and vm_set_identity()
  28. ; Added C global static vars vmd_zero_vector & vmd_identity_matrix
  29. ;
  30. ; Revision 1.15 1994/05/18 21:45:05 matt
  31. ; Added functions:
  32. ; vm_extract_angles_vector()
  33. ; vm_extract_angles_vector_normalized()
  34. ; vm_vec_copy_normalize()
  35. ;
  36. ; Revision 1.14 1994/05/13 12:42:09 matt
  37. ; Added new function, vm_vec_dist_quick(), which does an approximation.
  38. ;
  39. ; Revision 1.13 1994/03/30 15:43:54 matt
  40. ; Added two functions, vm_vec_scale_add() & vm_vec_scale_add2()
  41. ;
  42. ; Revision 1.12 1994/01/31 19:45:24 matt
  43. ; Added function vm_extract_angles_matrix()
  44. ;
  45. ; Revision 1.11 1993/12/21 19:46:29 matt
  46. ; Added function vm_dist_to_plane()
  47. ;
  48. ; Revision 1.10 1993/12/13 17:26:40 matt
  49. ; Added vm_vec_dist()
  50. ;
  51. ; Revision 1.9 1993/12/02 12:44:04 matt
  52. ; New functions: vm_vec_copy_scale(), vm_vec_scale2()
  53. ;
  54. ; Revision 1.8 1993/10/29 22:39:08 matt
  55. ; Changed matrix order, making direction vectors the rows
  56. ;
  57. ; Revision 1.7 1993/10/25 11:49:58 matt
  58. ; Made vm_vec_delta_ang() take optional forward vector to return signed delta
  59. ;
  60. ; Revision 1.6 1993/10/20 01:10:04 matt
  61. ; Added vm_vec_delta_ang(), vm_vec_delta_ang_norm(), and vm_vec_ang_2_matrix()
  62. ;
  63. ; Revision 1.5 1993/09/28 12:16:04 matt
  64. ; Added func vm_vector_2_matrix()
  65. ;
  66. ; Revision 1.4 1993/09/24 21:19:14 matt
  67. ; Added vm_vec_avg() and vm_vec_avg4()
  68. ;
  69. ; Revision 1.3 1993/09/20 14:56:35 matt
  70. ; Added new function, vm_vec_perp()
  71. ;
  72. ; Revision 1.2 1993/09/17 11:09:57 matt
  73. ; Added vm_vec_add2() and vm_vec_sub2(), which take 2 args (dest==src0)
  74. ;
  75. ; Revision 1.1 1993/09/16 20:19:29 matt
  76. ; Initial revision
  77. ;
  78. ;
  79. ;
  80. ifndef _VECMAT_INC
  81. _VECMAT_INC equ 1
  82. include fix.inc
  83. ;Structures
  84. vms_vector struct
  85. union
  86. struct
  87. x fix ?
  88. y fix ?
  89. z fix ?
  90. ends
  91. xyz fix 3 dup (?)
  92. ends
  93. vms_vector ends
  94. vms_svec struct
  95. union
  96. struct
  97. sv_x dw ?
  98. sv_y dw ?
  99. sv_z dw ?
  100. ends
  101. sv_xyz dw 3 dup (?)
  102. ends
  103. vms_svec ends
  104. vms_angvec struct
  105. union
  106. struct
  107. pitch fixang ?
  108. bank fixang ?
  109. head fixang ?
  110. ends
  111. struct
  112. ;p fixang ?
  113. ;b fixang ?
  114. ;h fixang ?
  115. ends
  116. ends
  117. vms_angvec ends
  118. vms_matrix struct
  119. union
  120. struct
  121. m1 fix ?
  122. m4 fix ?
  123. m7 fix ?
  124. m2 fix ?
  125. m5 fix ?
  126. m8 fix ?
  127. m3 fix ?
  128. m6 fix ?
  129. m9 fix ?
  130. ends
  131. struct
  132. rvec fix ?,?,?
  133. uvec fix ?,?,?
  134. fvec fix ?,?,?
  135. ends
  136. ;;mm fix 9 dup (?)
  137. ends
  138. vms_matrix ends
  139. ;Macros
  140. ;copies one vector to another, using the register specified. If none
  141. ;specified, uses eax
  142. vm_copy macro dest,src,reg:=<eax>
  143. for ofs,<x,y,z>
  144. mov reg,[src].ofs
  145. mov [dest].ofs,reg
  146. endm
  147. endm
  148. ;copies one angvec to another, using the register specified. If none
  149. ;specified, uses eax (and ax). Note the trick to get the word part of
  150. ;the register without knowing what the register is.
  151. vm_acopy macro dest,src,reg:=<eax>
  152. mov reg,fix ptr [src].p ;copy two at once
  153. mov fix ptr [dest].p,reg
  154. db 66h ;size override, use short
  155. mov reg,fix ptr [src].h ;copy last angle
  156. db 66h ;size override, use short
  157. mov fix ptr [dest].h,reg
  158. endm
  159. ;Global contants
  160. extdef vms_vector,_vmd_zero_vector
  161. extdef vms_matrix,_vmd_identity_matrix
  162. ;Routines
  163. ;register usage appears here, but see VECMAT.H for other info
  164. extn vm_vec_add ;eax=dest, esi,edi=srcs
  165. extn vm_vec_sub ;eax=dest, esi,edi=srcs
  166. extn vm_vec_add2 ;edi=dest, esi=source
  167. extn vm_vec_sub2 ;edi=dest, esi=source
  168. extn vm_vec_avg ;eax=dest, esi,edi=srcs
  169. extn vm_vec_avg4 ;eax=dest, esi,edi,ecx,edx=srcs
  170. extn vm_vec_scale ;ebx=vec, ecx=scale
  171. extn vm_vec_copy_scale ;edi=dest, ebx=src, ecx=scale
  172. extn vm_vec_scale2 ;edi=vec, ebx=n,edx=d
  173. extn vm_vec_mag ;esi=vec, returns eax=mag
  174. extn vm_vec_dist ;esi,edi=vecs, returns eax=dist
  175. extn vm_vec_mag_quick ;esi=vec, returns eax=approx dist
  176. extn vm_vec_dist_quick ;esi,edi=vecs, returns eax=approx dist
  177. extn vm_vec_normalize ;esi=vec, returns ecx=mag
  178. extn vm_vec_normalize_quick ;esi=vec, returns ecx=mag
  179. extn vm_vec_copy_normalize ;edi=dest, esi=src
  180. extn vm_vec_copy_normalize_quick ;edi=dest, esi=src
  181. extn vm_vec_normalized_dir ;edi=dest, esi=endpoint, ebx=startpoint
  182. extn vm_vec_normalized_dir_quick ;edi=dest, esi=endpoint, ebx=startpoint
  183. extn vm_vec_dotprod ;esi,edi=vecs, ret eax=dotprod
  184. extn vm_vec_crossprod ;eax=dest, esi,edi=srcs
  185. extn vm_vec_normal ;ebx=dest, eax,esi,edi=srcs
  186. extn vm_vec_perp ;ebx=dest, eax,esi,edi=srcs
  187. extn vm_vec_delta_ang ;esi,edi=vecs, eax=(optional) fvec, ret ax=angle
  188. extn vm_vec_delta_ang_norm ;esi,edi=vec, ret ax=angle
  189. extn vm_angles_2_matrix ;edi=dest, esi=angvec
  190. extn vm_vector_2_matrix ;edi=dest, esi=fwdvec, eax=upvec, ebx=rightvec
  191. extn vm_vector_2_matrix_norm ;edi=dest, esi=fwdvec, eax=upvec, ebx=rightvec
  192. extn vm_vec_rotate ;eax=dest, esi=src, edi=matrix
  193. extn vm_transpose_matrix ;edi=matrix (transpose in place)
  194. extn vm_copy_transpose_matrix ;edi=dest, esi=src
  195. extn vm_matrix_x_matrix ;eax=dest, esi,edi=srcs
  196. extn vm_vec_ang_2_matrix ;esi=vector, eax=angle, edi=matrix
  197. extn vm_dist_to_plane ;ebx=norm, edi=plane pnt, esi=check pnt, ret eax=dist
  198. extn vm_extract_angles_matrix ;edi=angles, esi=matrix
  199. extn vm_vec_scale_add ;edi=dest, ebx=src1, esi=src2, ecx=scale
  200. extn vm_vec_scale_add2 ;edi=dest, esi=src, ecx=scale
  201. extn vm_extract_angles_vector ;edi=angvec, esi=vec TRASHES ESI
  202. extn vm_extract_angles_vector_normalized ;edi=angvec, esi=vec
  203. endif