Open Source Tomb Raider Engine
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Vector3d.h 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*================================================================
  3. *
  4. * Project : Hel
  5. * Author : Terry 'Mongoose' Hendrix II
  6. * Website : http://www.westga.edu/~stu7440/
  7. * Email : stu7440@westga.edu
  8. * Object : Vector3d
  9. * License : No use w/o permission (C) 2002 Mongoose
  10. * Comments: Math vector
  11. *
  12. *
  13. * This file was generated using Mongoose's C++
  14. * template generator script. <stu7440@westga.edu>
  15. *
  16. *-- Test Defines -----------------------------------------------
  17. *
  18. * UNIT_TEST_VECTOR3D - Builds Vector3d class as a console unit test
  19. *
  20. *-- History ------------------------------------------------
  21. *
  22. * 2002.12.24:
  23. * Mongoose - Created
  24. ================================================================*/
  25. #ifndef _VECTOR3D_H_
  26. #define _VECTOR3D_H_
  27. #include <MatMath.h>
  28. class Vector3d
  29. {
  30. public:
  31. ////////////////////////////////////////////////////////////
  32. // Constructors
  33. ////////////////////////////////////////////////////////////
  34. Vector3d();
  35. /*------------------------------------------------------
  36. * Pre :
  37. * Post : Constructs an object of Vector3d
  38. *
  39. *-- History ------------------------------------------
  40. *
  41. * 2002.12.24:
  42. * Mongoose - Created
  43. ------------------------------------------------------*/
  44. Vector3d(vec3_t v);
  45. /*------------------------------------------------------
  46. * Pre :
  47. * Post : Constructs an object of Vector3d
  48. *
  49. *-- History ------------------------------------------
  50. *
  51. * 2002.12.24:
  52. * Mongoose - Created
  53. ------------------------------------------------------*/
  54. Vector3d(vec_t x, vec_t y, vec_t z);
  55. /*------------------------------------------------------
  56. * Pre :
  57. * Post : Constructs an object of Vector3d
  58. *
  59. *-- History ------------------------------------------
  60. *
  61. * 2002.12.24:
  62. * Mongoose - Created
  63. ------------------------------------------------------*/
  64. ~Vector3d();
  65. /*------------------------------------------------------
  66. * Pre : Vector3d object is allocated
  67. * Post : Deconstructs an object of Vector3d
  68. *
  69. *-- History ------------------------------------------
  70. *
  71. * 2002.12.24:
  72. * Mongoose - Created
  73. ------------------------------------------------------*/
  74. ////////////////////////////////////////////////////////////
  75. // Public Accessors
  76. ////////////////////////////////////////////////////////////
  77. static vec_t dot(const Vector3d &u, const Vector3d &v);
  78. /*------------------------------------------------------
  79. * Pre :
  80. * Post : Returns dot product of U and V vectors
  81. *
  82. *-- History ------------------------------------------
  83. *
  84. * 2002.05.08:
  85. * Mongoose - Created
  86. ------------------------------------------------------*/
  87. static Vector3d cross(const Vector3d &u, const Vector3d &v);
  88. /*------------------------------------------------------
  89. * Pre :
  90. * Post : Returns cross product of U and V vectors
  91. *
  92. *-- History ------------------------------------------
  93. *
  94. * 2002.05.08:
  95. * Mongoose - Created
  96. ------------------------------------------------------*/
  97. vec_t magnitude();
  98. /*------------------------------------------------------
  99. * Pre :
  100. * Post : Returns magnitude this vector
  101. *
  102. *-- History ------------------------------------------
  103. *
  104. * 2002.05.08:
  105. * Mongoose - Created
  106. ------------------------------------------------------*/
  107. Vector3d unit();
  108. /*------------------------------------------------------
  109. * Pre :
  110. * Post : Returns normalized copy of this vector
  111. *
  112. *-- History ------------------------------------------
  113. *
  114. * 2002.05.08:
  115. * Mongoose - Created
  116. ------------------------------------------------------*/
  117. static Vector3d zeroVector();
  118. /*------------------------------------------------------
  119. * Pre :
  120. * Post : Returns the Zero vector <0, 0, 0>
  121. *
  122. *-- History ------------------------------------------
  123. *
  124. * 2003.06.08:
  125. * Mongoose - Created
  126. ------------------------------------------------------*/
  127. Vector3d operator +(const Vector3d &v);
  128. /*------------------------------------------------------
  129. * Pre :
  130. * Post : Returns a vector = this vector + v
  131. *
  132. *-- History ------------------------------------------
  133. *
  134. * 2002.05.08:
  135. * Mongoose - Created
  136. ------------------------------------------------------*/
  137. Vector3d operator -(const Vector3d &v);
  138. /*------------------------------------------------------
  139. * Pre :
  140. * Post : Returns a vector = this vector - v
  141. *
  142. *-- History ------------------------------------------
  143. *
  144. * 2002.05.08:
  145. * Mongoose - Created
  146. ------------------------------------------------------*/
  147. Vector3d operator -();
  148. /*------------------------------------------------------
  149. * Pre :
  150. * Post : Returns a copy of this vector, negated
  151. *
  152. *-- History ------------------------------------------
  153. *
  154. * 2002.05.08:
  155. * Mongoose - Created
  156. ------------------------------------------------------*/
  157. Vector3d operator *(vec_t s);
  158. /*------------------------------------------------------
  159. * Pre : S is scalar to scale by
  160. * Post : Returns scale by S of this vector ( mult )
  161. *
  162. *-- History ------------------------------------------
  163. *
  164. * 2002.05.08:
  165. * Mongoose - Created
  166. ------------------------------------------------------*/
  167. Vector3d operator /(vec_t s);
  168. /*------------------------------------------------------
  169. * Pre : S is scalar to scale by
  170. * Post : Returns scale by S of this vector ( div )
  171. *
  172. *-- History ------------------------------------------
  173. *
  174. * 2002.05.08:
  175. * Mongoose - Created
  176. ------------------------------------------------------*/
  177. vec_t operator *(const Vector3d &v);
  178. /*------------------------------------------------------
  179. * Pre : V is vector to dot by
  180. * Post : Returns dot by V with this vector
  181. *
  182. *-- History ------------------------------------------
  183. *
  184. * 2002.05.08:
  185. * Mongoose - Created
  186. ------------------------------------------------------*/
  187. ////////////////////////////////////////////////////////////
  188. // Public Mutators
  189. ////////////////////////////////////////////////////////////
  190. void normalize();
  191. /*------------------------------------------------------
  192. * Pre :
  193. * Post : Normalizes *this vector
  194. *
  195. *-- History ------------------------------------------
  196. *
  197. * 2002.05.08:
  198. * Mongoose - Created
  199. ------------------------------------------------------*/
  200. void zero();
  201. /*------------------------------------------------------
  202. * Pre :
  203. * Post :This is set to the Zero vector <0, 0, 0>
  204. *
  205. *-- History ------------------------------------------
  206. *
  207. * 2003.06.08:
  208. * Mongoose - Created
  209. ------------------------------------------------------*/
  210. void operator =(const Vector3d &v);
  211. /*------------------------------------------------------
  212. * Pre :
  213. * Post : this = v, values are assigned =)
  214. *
  215. *-- History ------------------------------------------
  216. *
  217. * 2002.05.08:
  218. * Mongoose - Created
  219. ------------------------------------------------------*/
  220. void operator +=(const Vector3d &v);
  221. /*------------------------------------------------------
  222. * Pre :
  223. * Post : this += v, values are sumed, assigned =)
  224. *
  225. *-- History ------------------------------------------
  226. *
  227. * 2002.05.08:
  228. * Mongoose - Created
  229. ------------------------------------------------------*/
  230. void operator -=(const Vector3d &v);
  231. /*------------------------------------------------------
  232. * Pre :
  233. * Post : this -= v, values are diffed, assigned =)
  234. *
  235. *-- History ------------------------------------------
  236. *
  237. * 2002.05.08:
  238. * Mongoose - Created
  239. ------------------------------------------------------*/
  240. void operator *=(vec_t s);
  241. /*------------------------------------------------------
  242. * Pre :
  243. * Post : this *= s, values are scaled, assigned =)
  244. *
  245. *-- History ------------------------------------------
  246. *
  247. * 2002.05.08:
  248. * Mongoose - Created
  249. ------------------------------------------------------*/
  250. vec3_t mVec; /* Vector data */
  251. private:
  252. ////////////////////////////////////////////////////////////
  253. // Private Accessors
  254. ////////////////////////////////////////////////////////////
  255. ////////////////////////////////////////////////////////////
  256. // Private Mutators
  257. ////////////////////////////////////////////////////////////
  258. };
  259. #endif