@fimbul-works/vec 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (558) hide show
  1. package/README.md +208 -95
  2. package/dist/cjs/2d/add-2d.d.ts +8 -0
  3. package/dist/cjs/2d/add-2d.js +11 -0
  4. package/dist/cjs/2d/angle-between-2d.d.ts +8 -0
  5. package/dist/cjs/2d/angle-between-2d.js +11 -0
  6. package/dist/cjs/2d/angle-x-2d.d.ts +7 -0
  7. package/dist/cjs/2d/angle-x-2d.js +10 -0
  8. package/dist/cjs/2d/angle-y-2d.d.ts +7 -0
  9. package/dist/cjs/2d/angle-y-2d.js +10 -0
  10. package/dist/cjs/2d/clamp-2d.d.ts +10 -0
  11. package/dist/cjs/2d/clamp-2d.js +14 -0
  12. package/dist/cjs/2d/clone-2d.d.ts +7 -0
  13. package/dist/cjs/2d/clone-2d.js +10 -0
  14. package/dist/cjs/2d/cross-2d.d.ts +8 -0
  15. package/dist/cjs/2d/cross-2d.js +11 -0
  16. package/dist/cjs/2d/distance-2d.d.ts +8 -0
  17. package/dist/cjs/2d/distance-2d.js +11 -0
  18. package/dist/cjs/2d/distance-chebyshev-2d.d.ts +8 -0
  19. package/dist/cjs/2d/distance-chebyshev-2d.js +15 -0
  20. package/dist/cjs/2d/distance-manhattan-2d.d.ts +8 -0
  21. package/dist/cjs/2d/distance-manhattan-2d.js +11 -0
  22. package/dist/cjs/2d/distance-minkowski-2d.d.ts +9 -0
  23. package/dist/cjs/2d/distance-minkowski-2d.js +12 -0
  24. package/dist/cjs/2d/distance-sq-2d.d.ts +8 -0
  25. package/dist/cjs/2d/distance-sq-2d.js +11 -0
  26. package/dist/cjs/2d/divide-2d.d.ts +8 -0
  27. package/dist/cjs/2d/divide-2d.js +14 -0
  28. package/dist/cjs/2d/dot-2d.d.ts +8 -0
  29. package/dist/cjs/2d/dot-2d.js +11 -0
  30. package/dist/cjs/2d/from-angle-x-2d.d.ts +8 -0
  31. package/dist/cjs/2d/from-angle-x-2d.js +14 -0
  32. package/dist/cjs/2d/from-angle-y-2d.d.ts +8 -0
  33. package/dist/cjs/2d/from-angle-y-2d.js +14 -0
  34. package/dist/cjs/2d/from-object-2d.d.ts +10 -0
  35. package/dist/cjs/2d/from-object-2d.js +10 -0
  36. package/dist/cjs/2d/from-polar-coords-2d.d.ts +8 -0
  37. package/dist/cjs/2d/from-polar-coords-2d.js +11 -0
  38. package/dist/cjs/2d/immutable-2d.d.ts +7 -0
  39. package/dist/cjs/2d/immutable-2d.js +10 -0
  40. package/dist/cjs/2d/index.d.ts +47 -0
  41. package/dist/cjs/2d/index.js +63 -0
  42. package/dist/cjs/2d/is-equal-2d.d.ts +8 -0
  43. package/dist/cjs/2d/is-equal-2d.js +11 -0
  44. package/dist/cjs/2d/is-equal-approx-2d.d.ts +9 -0
  45. package/dist/cjs/2d/is-equal-approx-2d.js +12 -0
  46. package/dist/cjs/2d/is-infinite-2d.d.ts +7 -0
  47. package/dist/cjs/2d/is-infinite-2d.js +13 -0
  48. package/dist/cjs/2d/is-nan-2d.d.ts +7 -0
  49. package/dist/cjs/2d/is-nan-2d.js +10 -0
  50. package/dist/cjs/2d/is-opposite-2d.d.ts +8 -0
  51. package/dist/cjs/2d/is-opposite-2d.js +11 -0
  52. package/dist/cjs/2d/is-zero-2d.d.ts +7 -0
  53. package/dist/cjs/2d/is-zero-2d.js +10 -0
  54. package/dist/cjs/2d/lerp-2d.d.ts +9 -0
  55. package/dist/cjs/2d/lerp-2d.js +15 -0
  56. package/dist/cjs/2d/limit-max-2d.d.ts +9 -0
  57. package/dist/cjs/2d/limit-max-2d.js +13 -0
  58. package/dist/cjs/2d/limit-min-2d.d.ts +9 -0
  59. package/dist/cjs/2d/limit-min-2d.js +13 -0
  60. package/dist/cjs/2d/look-at-2d.d.ts +10 -0
  61. package/dist/cjs/2d/look-at-2d.js +14 -0
  62. package/dist/cjs/2d/magnitude-2d.d.ts +7 -0
  63. package/dist/cjs/2d/magnitude-2d.js +10 -0
  64. package/dist/cjs/2d/magnitude-sq-2d.d.ts +7 -0
  65. package/dist/cjs/2d/magnitude-sq-2d.js +10 -0
  66. package/dist/cjs/2d/multiply-2d.d.ts +8 -0
  67. package/dist/cjs/2d/multiply-2d.js +11 -0
  68. package/dist/cjs/2d/negate-2d.d.ts +7 -0
  69. package/dist/cjs/2d/negate-2d.js +10 -0
  70. package/dist/cjs/2d/normalize-2d.d.ts +8 -0
  71. package/dist/cjs/2d/normalize-2d.js +12 -0
  72. package/dist/cjs/2d/one-2d.d.ts +6 -0
  73. package/dist/cjs/2d/one-2d.js +9 -0
  74. package/dist/cjs/2d/project-2d.d.ts +10 -0
  75. package/dist/cjs/2d/project-2d.js +17 -0
  76. package/dist/cjs/2d/random-2d.d.ts +7 -0
  77. package/dist/cjs/2d/random-2d.js +13 -0
  78. package/dist/cjs/2d/reflect-2d.d.ts +9 -0
  79. package/dist/cjs/2d/reflect-2d.js +16 -0
  80. package/dist/cjs/2d/rotate-2d.d.ts +9 -0
  81. package/dist/cjs/2d/rotate-2d.js +27 -0
  82. package/dist/cjs/2d/set-magnitude-2d.d.ts +9 -0
  83. package/dist/cjs/2d/set-magnitude-2d.js +16 -0
  84. package/dist/cjs/2d/subtract-2d.d.ts +8 -0
  85. package/dist/cjs/2d/subtract-2d.js +11 -0
  86. package/dist/cjs/2d/types.d.ts +4 -0
  87. package/dist/cjs/2d/types.js +2 -0
  88. package/dist/cjs/2d/zero-2d.d.ts +6 -0
  89. package/dist/cjs/2d/zero-2d.js +9 -0
  90. package/dist/cjs/3d/add-3d.d.ts +8 -0
  91. package/dist/cjs/3d/add-3d.js +15 -0
  92. package/dist/cjs/3d/angle-between-3d.d.ts +10 -0
  93. package/dist/cjs/3d/angle-between-3d.js +14 -0
  94. package/dist/cjs/3d/angle-x-3d.d.ts +7 -0
  95. package/dist/cjs/3d/angle-x-3d.js +10 -0
  96. package/dist/cjs/3d/angle-y-3d.d.ts +7 -0
  97. package/dist/cjs/3d/angle-y-3d.js +10 -0
  98. package/dist/cjs/3d/angle-z-3d.d.ts +7 -0
  99. package/dist/cjs/3d/angle-z-3d.js +10 -0
  100. package/dist/cjs/3d/clamp-3d.d.ts +10 -0
  101. package/dist/cjs/3d/clamp-3d.js +18 -0
  102. package/dist/cjs/3d/clone-3d.d.ts +7 -0
  103. package/dist/cjs/3d/clone-3d.js +10 -0
  104. package/dist/cjs/3d/cross-3d.d.ts +8 -0
  105. package/dist/cjs/3d/cross-3d.js +15 -0
  106. package/dist/cjs/3d/distance-3d.d.ts +8 -0
  107. package/dist/cjs/3d/distance-3d.js +11 -0
  108. package/dist/cjs/3d/distance-chebyshev-3d.d.ts +8 -0
  109. package/dist/cjs/3d/distance-chebyshev-3d.js +16 -0
  110. package/dist/cjs/3d/distance-manhattan-3d.d.ts +8 -0
  111. package/dist/cjs/3d/distance-manhattan-3d.js +11 -0
  112. package/dist/cjs/3d/distance-minkowski-3d.d.ts +9 -0
  113. package/dist/cjs/3d/distance-minkowski-3d.js +12 -0
  114. package/dist/cjs/3d/distance-sq-3d.d.ts +8 -0
  115. package/dist/cjs/3d/distance-sq-3d.js +11 -0
  116. package/dist/cjs/3d/divide-3d.d.ts +8 -0
  117. package/dist/cjs/3d/divide-3d.js +15 -0
  118. package/dist/cjs/3d/dot-3d.d.ts +8 -0
  119. package/dist/cjs/3d/dot-3d.js +11 -0
  120. package/dist/cjs/3d/from-cylindrical-coords-3d.d.ts +9 -0
  121. package/dist/cjs/3d/from-cylindrical-coords-3d.js +16 -0
  122. package/dist/cjs/3d/from-object-3d.d.ts +11 -0
  123. package/dist/cjs/3d/from-object-3d.js +10 -0
  124. package/dist/cjs/3d/from-spherical-coords-3d.d.ts +9 -0
  125. package/dist/cjs/3d/from-spherical-coords-3d.js +16 -0
  126. package/dist/cjs/3d/immutable-3d.d.ts +7 -0
  127. package/dist/cjs/3d/immutable-3d.js +10 -0
  128. package/dist/cjs/3d/index.d.ts +49 -0
  129. package/dist/cjs/3d/index.js +65 -0
  130. package/dist/cjs/3d/is-equal-3d.d.ts +8 -0
  131. package/dist/cjs/3d/is-equal-3d.js +11 -0
  132. package/dist/cjs/3d/is-equal-approx-3d.d.ts +9 -0
  133. package/dist/cjs/3d/is-equal-approx-3d.js +14 -0
  134. package/dist/cjs/3d/is-infinite-3d.d.ts +7 -0
  135. package/dist/cjs/3d/is-infinite-3d.js +15 -0
  136. package/dist/cjs/3d/is-nan-3d.d.ts +7 -0
  137. package/dist/cjs/3d/is-nan-3d.js +10 -0
  138. package/dist/cjs/3d/is-opposite-3d.d.ts +8 -0
  139. package/dist/cjs/3d/is-opposite-3d.js +11 -0
  140. package/dist/cjs/3d/is-zero-3d.d.ts +7 -0
  141. package/dist/cjs/3d/is-zero-3d.js +10 -0
  142. package/dist/cjs/3d/lerp-3d.d.ts +9 -0
  143. package/dist/cjs/3d/lerp-3d.js +16 -0
  144. package/dist/cjs/3d/limit-max-3d.d.ts +9 -0
  145. package/dist/cjs/3d/limit-max-3d.js +13 -0
  146. package/dist/cjs/3d/limit-min-3d.d.ts +9 -0
  147. package/dist/cjs/3d/limit-min-3d.js +13 -0
  148. package/dist/cjs/3d/look-at-3d.d.ts +10 -0
  149. package/dist/cjs/3d/look-at-3d.js +14 -0
  150. package/dist/cjs/3d/magnitude-3d.d.ts +7 -0
  151. package/dist/cjs/3d/magnitude-3d.js +10 -0
  152. package/dist/cjs/3d/magnitude-sq-3d.d.ts +7 -0
  153. package/dist/cjs/3d/magnitude-sq-3d.js +10 -0
  154. package/dist/cjs/3d/multiply-3d.d.ts +8 -0
  155. package/dist/cjs/3d/multiply-3d.js +15 -0
  156. package/dist/cjs/3d/negate-3d.d.ts +7 -0
  157. package/dist/cjs/3d/negate-3d.js +10 -0
  158. package/dist/cjs/3d/normalize-3d.d.ts +8 -0
  159. package/dist/cjs/3d/normalize-3d.js +12 -0
  160. package/dist/cjs/3d/one-3d.d.ts +6 -0
  161. package/dist/cjs/3d/one-3d.js +9 -0
  162. package/dist/cjs/3d/project-3d.d.ts +10 -0
  163. package/dist/cjs/3d/project-3d.js +17 -0
  164. package/dist/cjs/3d/random-3d.d.ts +7 -0
  165. package/dist/cjs/3d/random-3d.js +11 -0
  166. package/dist/cjs/3d/reflect-3d.d.ts +9 -0
  167. package/dist/cjs/3d/reflect-3d.js +16 -0
  168. package/dist/cjs/3d/rotate-x-3d.d.ts +9 -0
  169. package/dist/cjs/3d/rotate-x-3d.js +26 -0
  170. package/dist/cjs/3d/rotate-y-3d.d.ts +9 -0
  171. package/dist/cjs/3d/rotate-y-3d.js +26 -0
  172. package/dist/cjs/3d/rotate-z-3d.d.ts +9 -0
  173. package/dist/cjs/3d/rotate-z-3d.js +26 -0
  174. package/dist/cjs/3d/set-magnitude-3d.d.ts +9 -0
  175. package/dist/cjs/3d/set-magnitude-3d.js +13 -0
  176. package/dist/cjs/3d/subtract-3d.d.ts +8 -0
  177. package/dist/cjs/3d/subtract-3d.js +15 -0
  178. package/dist/cjs/3d/types.d.ts +4 -0
  179. package/dist/cjs/3d/types.js +2 -0
  180. package/dist/cjs/3d/zero-3d.d.ts +6 -0
  181. package/dist/cjs/3d/zero-3d.js +9 -0
  182. package/dist/cjs/4d/add-4d.d.ts +8 -0
  183. package/dist/cjs/4d/add-4d.js +16 -0
  184. package/dist/cjs/4d/angle-between-4d.d.ts +10 -0
  185. package/dist/cjs/4d/angle-between-4d.js +15 -0
  186. package/dist/cjs/4d/angle-w-4d.d.ts +7 -0
  187. package/dist/cjs/4d/angle-w-4d.js +10 -0
  188. package/dist/cjs/4d/angle-x-4d.d.ts +7 -0
  189. package/dist/cjs/4d/angle-x-4d.js +10 -0
  190. package/dist/cjs/4d/angle-y-4d.d.ts +7 -0
  191. package/dist/cjs/4d/angle-y-4d.js +10 -0
  192. package/dist/cjs/4d/angle-z-4d.d.ts +7 -0
  193. package/dist/cjs/4d/angle-z-4d.js +10 -0
  194. package/dist/cjs/4d/clamp-4d.d.ts +10 -0
  195. package/dist/cjs/4d/clamp-4d.js +18 -0
  196. package/dist/cjs/4d/clone-4d.d.ts +7 -0
  197. package/dist/cjs/4d/clone-4d.js +10 -0
  198. package/dist/cjs/4d/distance-4d.d.ts +8 -0
  199. package/dist/cjs/4d/distance-4d.js +11 -0
  200. package/dist/cjs/4d/distance-chebyshev-4d.d.ts +8 -0
  201. package/dist/cjs/4d/distance-chebyshev-4d.js +23 -0
  202. package/dist/cjs/4d/distance-manhattan-4d.d.ts +8 -0
  203. package/dist/cjs/4d/distance-manhattan-4d.js +14 -0
  204. package/dist/cjs/4d/distance-minkowski-4d.d.ts +9 -0
  205. package/dist/cjs/4d/distance-minkowski-4d.js +16 -0
  206. package/dist/cjs/4d/distance-sq-4d.d.ts +9 -0
  207. package/dist/cjs/4d/distance-sq-4d.js +12 -0
  208. package/dist/cjs/4d/divide-4d.d.ts +8 -0
  209. package/dist/cjs/4d/divide-4d.js +16 -0
  210. package/dist/cjs/4d/dot-4d.d.ts +8 -0
  211. package/dist/cjs/4d/dot-4d.js +11 -0
  212. package/dist/cjs/4d/from-object-4d.d.ts +12 -0
  213. package/dist/cjs/4d/from-object-4d.js +15 -0
  214. package/dist/cjs/4d/immutable-4d.d.ts +7 -0
  215. package/dist/cjs/4d/immutable-4d.js +10 -0
  216. package/dist/cjs/4d/index.d.ts +44 -0
  217. package/dist/cjs/4d/index.js +60 -0
  218. package/dist/cjs/4d/is-equal-4d.d.ts +8 -0
  219. package/dist/cjs/4d/is-equal-4d.js +11 -0
  220. package/dist/cjs/4d/is-equal-approx-4d.d.ts +9 -0
  221. package/dist/cjs/4d/is-equal-approx-4d.js +15 -0
  222. package/dist/cjs/4d/is-infinite-4d.d.ts +7 -0
  223. package/dist/cjs/4d/is-infinite-4d.js +17 -0
  224. package/dist/cjs/4d/is-nan-4d.d.ts +7 -0
  225. package/dist/cjs/4d/is-nan-4d.js +10 -0
  226. package/dist/cjs/4d/is-opposite-4d.d.ts +8 -0
  227. package/dist/cjs/4d/is-opposite-4d.js +11 -0
  228. package/dist/cjs/4d/is-zero-4d.d.ts +7 -0
  229. package/dist/cjs/4d/is-zero-4d.js +10 -0
  230. package/dist/cjs/4d/lerp-4d.d.ts +9 -0
  231. package/dist/cjs/4d/lerp-4d.js +17 -0
  232. package/dist/cjs/4d/limit-max-4d.d.ts +9 -0
  233. package/dist/cjs/4d/limit-max-4d.js +13 -0
  234. package/dist/cjs/4d/limit-min-4d.d.ts +9 -0
  235. package/dist/cjs/4d/limit-min-4d.js +13 -0
  236. package/dist/cjs/4d/look-at-4d.d.ts +10 -0
  237. package/dist/cjs/4d/look-at-4d.js +14 -0
  238. package/dist/cjs/4d/magnitude-4d.d.ts +7 -0
  239. package/dist/cjs/4d/magnitude-4d.js +10 -0
  240. package/dist/cjs/4d/magnitude-sq-4d.d.ts +8 -0
  241. package/dist/cjs/4d/magnitude-sq-4d.js +11 -0
  242. package/dist/cjs/4d/multiply-4d.d.ts +8 -0
  243. package/dist/cjs/4d/multiply-4d.js +16 -0
  244. package/dist/cjs/4d/negate-4d.d.ts +7 -0
  245. package/dist/cjs/4d/negate-4d.js +10 -0
  246. package/dist/cjs/4d/normalize-4d.d.ts +8 -0
  247. package/dist/cjs/4d/normalize-4d.js +17 -0
  248. package/dist/cjs/4d/one-4d.d.ts +6 -0
  249. package/dist/cjs/4d/one-4d.js +9 -0
  250. package/dist/cjs/4d/project-4d.d.ts +10 -0
  251. package/dist/cjs/4d/project-4d.js +18 -0
  252. package/dist/cjs/4d/random-4d.d.ts +7 -0
  253. package/dist/cjs/4d/random-4d.js +21 -0
  254. package/dist/cjs/4d/reflect-4d.d.ts +9 -0
  255. package/dist/cjs/4d/reflect-4d.js +21 -0
  256. package/dist/cjs/4d/set-magnitude-4d.d.ts +9 -0
  257. package/dist/cjs/4d/set-magnitude-4d.js +18 -0
  258. package/dist/cjs/4d/subtract-4d.d.ts +8 -0
  259. package/dist/cjs/4d/subtract-4d.js +16 -0
  260. package/dist/cjs/4d/types.d.ts +4 -0
  261. package/dist/cjs/4d/types.js +2 -0
  262. package/dist/cjs/4d/zero-4d.d.ts +6 -0
  263. package/dist/cjs/4d/zero-4d.js +9 -0
  264. package/dist/cjs/index.d.ts +4 -0
  265. package/dist/cjs/index.js +4 -0
  266. package/dist/cjs/package.json +1 -1
  267. package/dist/cjs/slerp.d.ts +21 -0
  268. package/dist/cjs/slerp.js +28 -0
  269. package/dist/cjs/vec2.d.ts +10 -4
  270. package/dist/cjs/vec2.js +13 -6
  271. package/dist/cjs/vec3.d.ts +121 -106
  272. package/dist/cjs/vec3.js +127 -129
  273. package/dist/cjs/vec4.d.ts +118 -100
  274. package/dist/cjs/vec4.js +134 -134
  275. package/dist/esm/2d/add-2d.d.ts +8 -0
  276. package/dist/esm/2d/add-2d.js +7 -0
  277. package/dist/esm/2d/angle-between-2d.d.ts +8 -0
  278. package/dist/esm/2d/angle-between-2d.js +7 -0
  279. package/dist/esm/2d/angle-x-2d.d.ts +7 -0
  280. package/dist/esm/2d/angle-x-2d.js +6 -0
  281. package/dist/esm/2d/angle-y-2d.d.ts +7 -0
  282. package/dist/esm/2d/angle-y-2d.js +6 -0
  283. package/dist/esm/2d/clamp-2d.d.ts +10 -0
  284. package/dist/esm/2d/clamp-2d.js +10 -0
  285. package/dist/esm/2d/clone-2d.d.ts +7 -0
  286. package/dist/esm/2d/clone-2d.js +6 -0
  287. package/dist/esm/2d/cross-2d.d.ts +8 -0
  288. package/dist/esm/2d/cross-2d.js +7 -0
  289. package/dist/esm/2d/distance-2d.d.ts +8 -0
  290. package/dist/esm/2d/distance-2d.js +7 -0
  291. package/dist/esm/2d/distance-chebyshev-2d.d.ts +8 -0
  292. package/dist/esm/2d/distance-chebyshev-2d.js +11 -0
  293. package/dist/esm/2d/distance-manhattan-2d.d.ts +8 -0
  294. package/dist/esm/2d/distance-manhattan-2d.js +7 -0
  295. package/dist/esm/2d/distance-minkowski-2d.d.ts +9 -0
  296. package/dist/esm/2d/distance-minkowski-2d.js +8 -0
  297. package/dist/esm/2d/distance-sq-2d.d.ts +8 -0
  298. package/dist/esm/2d/distance-sq-2d.js +7 -0
  299. package/dist/esm/2d/divide-2d.d.ts +8 -0
  300. package/dist/esm/2d/divide-2d.js +10 -0
  301. package/dist/esm/2d/dot-2d.d.ts +8 -0
  302. package/dist/esm/2d/dot-2d.js +7 -0
  303. package/dist/esm/2d/from-angle-x-2d.d.ts +8 -0
  304. package/dist/esm/2d/from-angle-x-2d.js +10 -0
  305. package/dist/esm/2d/from-angle-y-2d.d.ts +8 -0
  306. package/dist/esm/2d/from-angle-y-2d.js +10 -0
  307. package/dist/esm/2d/from-object-2d.d.ts +10 -0
  308. package/dist/esm/2d/from-object-2d.js +6 -0
  309. package/dist/esm/2d/from-polar-coords-2d.d.ts +8 -0
  310. package/dist/esm/2d/from-polar-coords-2d.js +7 -0
  311. package/dist/esm/2d/immutable-2d.d.ts +7 -0
  312. package/dist/esm/2d/immutable-2d.js +6 -0
  313. package/dist/esm/2d/index.d.ts +47 -0
  314. package/dist/esm/2d/index.js +47 -0
  315. package/dist/esm/2d/is-equal-2d.d.ts +8 -0
  316. package/dist/esm/2d/is-equal-2d.js +7 -0
  317. package/dist/esm/2d/is-equal-approx-2d.d.ts +9 -0
  318. package/dist/esm/2d/is-equal-approx-2d.js +8 -0
  319. package/dist/esm/2d/is-infinite-2d.d.ts +7 -0
  320. package/dist/esm/2d/is-infinite-2d.js +9 -0
  321. package/dist/esm/2d/is-nan-2d.d.ts +7 -0
  322. package/dist/esm/2d/is-nan-2d.js +6 -0
  323. package/dist/esm/2d/is-opposite-2d.d.ts +8 -0
  324. package/dist/esm/2d/is-opposite-2d.js +7 -0
  325. package/dist/esm/2d/is-zero-2d.d.ts +7 -0
  326. package/dist/esm/2d/is-zero-2d.js +6 -0
  327. package/dist/esm/2d/lerp-2d.d.ts +9 -0
  328. package/dist/esm/2d/lerp-2d.js +11 -0
  329. package/dist/esm/2d/limit-max-2d.d.ts +9 -0
  330. package/dist/esm/2d/limit-max-2d.js +9 -0
  331. package/dist/esm/2d/limit-min-2d.d.ts +9 -0
  332. package/dist/esm/2d/limit-min-2d.js +9 -0
  333. package/dist/esm/2d/look-at-2d.d.ts +10 -0
  334. package/dist/esm/2d/look-at-2d.js +10 -0
  335. package/dist/esm/2d/magnitude-2d.d.ts +7 -0
  336. package/dist/esm/2d/magnitude-2d.js +6 -0
  337. package/dist/esm/2d/magnitude-sq-2d.d.ts +7 -0
  338. package/dist/esm/2d/magnitude-sq-2d.js +6 -0
  339. package/dist/esm/2d/multiply-2d.d.ts +8 -0
  340. package/dist/esm/2d/multiply-2d.js +7 -0
  341. package/dist/esm/2d/negate-2d.d.ts +7 -0
  342. package/dist/esm/2d/negate-2d.js +6 -0
  343. package/dist/esm/2d/normalize-2d.d.ts +8 -0
  344. package/dist/esm/2d/normalize-2d.js +8 -0
  345. package/dist/esm/2d/one-2d.d.ts +6 -0
  346. package/dist/esm/2d/one-2d.js +5 -0
  347. package/dist/esm/2d/project-2d.d.ts +10 -0
  348. package/dist/esm/2d/project-2d.js +13 -0
  349. package/dist/esm/2d/random-2d.d.ts +7 -0
  350. package/dist/esm/2d/random-2d.js +9 -0
  351. package/dist/esm/2d/reflect-2d.d.ts +9 -0
  352. package/dist/esm/2d/reflect-2d.js +12 -0
  353. package/dist/esm/2d/rotate-2d.d.ts +9 -0
  354. package/dist/esm/2d/rotate-2d.js +23 -0
  355. package/dist/esm/2d/set-magnitude-2d.d.ts +9 -0
  356. package/dist/esm/2d/set-magnitude-2d.js +12 -0
  357. package/dist/esm/2d/subtract-2d.d.ts +8 -0
  358. package/dist/esm/2d/subtract-2d.js +7 -0
  359. package/dist/esm/2d/types.d.ts +4 -0
  360. package/dist/esm/2d/types.js +1 -0
  361. package/dist/esm/2d/zero-2d.d.ts +6 -0
  362. package/dist/esm/2d/zero-2d.js +5 -0
  363. package/dist/esm/3d/add-3d.d.ts +8 -0
  364. package/dist/esm/3d/add-3d.js +11 -0
  365. package/dist/esm/3d/angle-between-3d.d.ts +10 -0
  366. package/dist/esm/3d/angle-between-3d.js +10 -0
  367. package/dist/esm/3d/angle-x-3d.d.ts +7 -0
  368. package/dist/esm/3d/angle-x-3d.js +6 -0
  369. package/dist/esm/3d/angle-y-3d.d.ts +7 -0
  370. package/dist/esm/3d/angle-y-3d.js +6 -0
  371. package/dist/esm/3d/angle-z-3d.d.ts +7 -0
  372. package/dist/esm/3d/angle-z-3d.js +6 -0
  373. package/dist/esm/3d/clamp-3d.d.ts +10 -0
  374. package/dist/esm/3d/clamp-3d.js +14 -0
  375. package/dist/esm/3d/clone-3d.d.ts +7 -0
  376. package/dist/esm/3d/clone-3d.js +6 -0
  377. package/dist/esm/3d/cross-3d.d.ts +8 -0
  378. package/dist/esm/3d/cross-3d.js +11 -0
  379. package/dist/esm/3d/distance-3d.d.ts +8 -0
  380. package/dist/esm/3d/distance-3d.js +7 -0
  381. package/dist/esm/3d/distance-chebyshev-3d.d.ts +8 -0
  382. package/dist/esm/3d/distance-chebyshev-3d.js +12 -0
  383. package/dist/esm/3d/distance-manhattan-3d.d.ts +8 -0
  384. package/dist/esm/3d/distance-manhattan-3d.js +7 -0
  385. package/dist/esm/3d/distance-minkowski-3d.d.ts +9 -0
  386. package/dist/esm/3d/distance-minkowski-3d.js +8 -0
  387. package/dist/esm/3d/distance-sq-3d.d.ts +8 -0
  388. package/dist/esm/3d/distance-sq-3d.js +7 -0
  389. package/dist/esm/3d/divide-3d.d.ts +8 -0
  390. package/dist/esm/3d/divide-3d.js +11 -0
  391. package/dist/esm/3d/dot-3d.d.ts +8 -0
  392. package/dist/esm/3d/dot-3d.js +7 -0
  393. package/dist/esm/3d/from-cylindrical-coords-3d.d.ts +9 -0
  394. package/dist/esm/3d/from-cylindrical-coords-3d.js +12 -0
  395. package/dist/esm/3d/from-object-3d.d.ts +11 -0
  396. package/dist/esm/3d/from-object-3d.js +6 -0
  397. package/dist/esm/3d/from-spherical-coords-3d.d.ts +9 -0
  398. package/dist/esm/3d/from-spherical-coords-3d.js +12 -0
  399. package/dist/esm/3d/immutable-3d.d.ts +7 -0
  400. package/dist/esm/3d/immutable-3d.js +6 -0
  401. package/dist/esm/3d/index.d.ts +49 -0
  402. package/dist/esm/3d/index.js +49 -0
  403. package/dist/esm/3d/is-equal-3d.d.ts +8 -0
  404. package/dist/esm/3d/is-equal-3d.js +7 -0
  405. package/dist/esm/3d/is-equal-approx-3d.d.ts +9 -0
  406. package/dist/esm/3d/is-equal-approx-3d.js +10 -0
  407. package/dist/esm/3d/is-infinite-3d.d.ts +7 -0
  408. package/dist/esm/3d/is-infinite-3d.js +11 -0
  409. package/dist/esm/3d/is-nan-3d.d.ts +7 -0
  410. package/dist/esm/3d/is-nan-3d.js +6 -0
  411. package/dist/esm/3d/is-opposite-3d.d.ts +8 -0
  412. package/dist/esm/3d/is-opposite-3d.js +7 -0
  413. package/dist/esm/3d/is-zero-3d.d.ts +7 -0
  414. package/dist/esm/3d/is-zero-3d.js +6 -0
  415. package/dist/esm/3d/lerp-3d.d.ts +9 -0
  416. package/dist/esm/3d/lerp-3d.js +12 -0
  417. package/dist/esm/3d/limit-max-3d.d.ts +9 -0
  418. package/dist/esm/3d/limit-max-3d.js +9 -0
  419. package/dist/esm/3d/limit-min-3d.d.ts +9 -0
  420. package/dist/esm/3d/limit-min-3d.js +9 -0
  421. package/dist/esm/3d/look-at-3d.d.ts +10 -0
  422. package/dist/esm/3d/look-at-3d.js +10 -0
  423. package/dist/esm/3d/magnitude-3d.d.ts +7 -0
  424. package/dist/esm/3d/magnitude-3d.js +6 -0
  425. package/dist/esm/3d/magnitude-sq-3d.d.ts +7 -0
  426. package/dist/esm/3d/magnitude-sq-3d.js +6 -0
  427. package/dist/esm/3d/multiply-3d.d.ts +8 -0
  428. package/dist/esm/3d/multiply-3d.js +11 -0
  429. package/dist/esm/3d/negate-3d.d.ts +7 -0
  430. package/dist/esm/3d/negate-3d.js +6 -0
  431. package/dist/esm/3d/normalize-3d.d.ts +8 -0
  432. package/dist/esm/3d/normalize-3d.js +8 -0
  433. package/dist/esm/3d/one-3d.d.ts +6 -0
  434. package/dist/esm/3d/one-3d.js +5 -0
  435. package/dist/esm/3d/project-3d.d.ts +10 -0
  436. package/dist/esm/3d/project-3d.js +13 -0
  437. package/dist/esm/3d/random-3d.d.ts +7 -0
  438. package/dist/esm/3d/random-3d.js +7 -0
  439. package/dist/esm/3d/reflect-3d.d.ts +9 -0
  440. package/dist/esm/3d/reflect-3d.js +12 -0
  441. package/dist/esm/3d/rotate-x-3d.d.ts +9 -0
  442. package/dist/esm/3d/rotate-x-3d.js +22 -0
  443. package/dist/esm/3d/rotate-y-3d.d.ts +9 -0
  444. package/dist/esm/3d/rotate-y-3d.js +22 -0
  445. package/dist/esm/3d/rotate-z-3d.d.ts +9 -0
  446. package/dist/esm/3d/rotate-z-3d.js +22 -0
  447. package/dist/esm/3d/set-magnitude-3d.d.ts +9 -0
  448. package/dist/esm/3d/set-magnitude-3d.js +9 -0
  449. package/dist/esm/3d/subtract-3d.d.ts +8 -0
  450. package/dist/esm/3d/subtract-3d.js +11 -0
  451. package/dist/esm/3d/types.d.ts +4 -0
  452. package/dist/esm/3d/types.js +1 -0
  453. package/dist/esm/3d/zero-3d.d.ts +6 -0
  454. package/dist/esm/3d/zero-3d.js +5 -0
  455. package/dist/esm/4d/add-4d.d.ts +8 -0
  456. package/dist/esm/4d/add-4d.js +12 -0
  457. package/dist/esm/4d/angle-between-4d.d.ts +10 -0
  458. package/dist/esm/4d/angle-between-4d.js +11 -0
  459. package/dist/esm/4d/angle-w-4d.d.ts +7 -0
  460. package/dist/esm/4d/angle-w-4d.js +6 -0
  461. package/dist/esm/4d/angle-x-4d.d.ts +7 -0
  462. package/dist/esm/4d/angle-x-4d.js +6 -0
  463. package/dist/esm/4d/angle-y-4d.d.ts +7 -0
  464. package/dist/esm/4d/angle-y-4d.js +6 -0
  465. package/dist/esm/4d/angle-z-4d.d.ts +7 -0
  466. package/dist/esm/4d/angle-z-4d.js +6 -0
  467. package/dist/esm/4d/clamp-4d.d.ts +10 -0
  468. package/dist/esm/4d/clamp-4d.js +14 -0
  469. package/dist/esm/4d/clone-4d.d.ts +7 -0
  470. package/dist/esm/4d/clone-4d.js +6 -0
  471. package/dist/esm/4d/distance-4d.d.ts +8 -0
  472. package/dist/esm/4d/distance-4d.js +7 -0
  473. package/dist/esm/4d/distance-chebyshev-4d.d.ts +8 -0
  474. package/dist/esm/4d/distance-chebyshev-4d.js +19 -0
  475. package/dist/esm/4d/distance-manhattan-4d.d.ts +8 -0
  476. package/dist/esm/4d/distance-manhattan-4d.js +10 -0
  477. package/dist/esm/4d/distance-minkowski-4d.d.ts +9 -0
  478. package/dist/esm/4d/distance-minkowski-4d.js +12 -0
  479. package/dist/esm/4d/distance-sq-4d.d.ts +9 -0
  480. package/dist/esm/4d/distance-sq-4d.js +8 -0
  481. package/dist/esm/4d/divide-4d.d.ts +8 -0
  482. package/dist/esm/4d/divide-4d.js +12 -0
  483. package/dist/esm/4d/dot-4d.d.ts +8 -0
  484. package/dist/esm/4d/dot-4d.js +7 -0
  485. package/dist/esm/4d/from-object-4d.d.ts +12 -0
  486. package/dist/esm/4d/from-object-4d.js +11 -0
  487. package/dist/esm/4d/immutable-4d.d.ts +7 -0
  488. package/dist/esm/4d/immutable-4d.js +6 -0
  489. package/dist/esm/4d/index.d.ts +44 -0
  490. package/dist/esm/4d/index.js +44 -0
  491. package/dist/esm/4d/is-equal-4d.d.ts +8 -0
  492. package/dist/esm/4d/is-equal-4d.js +7 -0
  493. package/dist/esm/4d/is-equal-approx-4d.d.ts +9 -0
  494. package/dist/esm/4d/is-equal-approx-4d.js +11 -0
  495. package/dist/esm/4d/is-infinite-4d.d.ts +7 -0
  496. package/dist/esm/4d/is-infinite-4d.js +13 -0
  497. package/dist/esm/4d/is-nan-4d.d.ts +7 -0
  498. package/dist/esm/4d/is-nan-4d.js +6 -0
  499. package/dist/esm/4d/is-opposite-4d.d.ts +8 -0
  500. package/dist/esm/4d/is-opposite-4d.js +7 -0
  501. package/dist/esm/4d/is-zero-4d.d.ts +7 -0
  502. package/dist/esm/4d/is-zero-4d.js +6 -0
  503. package/dist/esm/4d/lerp-4d.d.ts +9 -0
  504. package/dist/esm/4d/lerp-4d.js +13 -0
  505. package/dist/esm/4d/limit-max-4d.d.ts +9 -0
  506. package/dist/esm/4d/limit-max-4d.js +9 -0
  507. package/dist/esm/4d/limit-min-4d.d.ts +9 -0
  508. package/dist/esm/4d/limit-min-4d.js +9 -0
  509. package/dist/esm/4d/look-at-4d.d.ts +10 -0
  510. package/dist/esm/4d/look-at-4d.js +10 -0
  511. package/dist/esm/4d/magnitude-4d.d.ts +7 -0
  512. package/dist/esm/4d/magnitude-4d.js +6 -0
  513. package/dist/esm/4d/magnitude-sq-4d.d.ts +8 -0
  514. package/dist/esm/4d/magnitude-sq-4d.js +7 -0
  515. package/dist/esm/4d/multiply-4d.d.ts +8 -0
  516. package/dist/esm/4d/multiply-4d.js +12 -0
  517. package/dist/esm/4d/negate-4d.d.ts +7 -0
  518. package/dist/esm/4d/negate-4d.js +6 -0
  519. package/dist/esm/4d/normalize-4d.d.ts +8 -0
  520. package/dist/esm/4d/normalize-4d.js +13 -0
  521. package/dist/esm/4d/one-4d.d.ts +6 -0
  522. package/dist/esm/4d/one-4d.js +5 -0
  523. package/dist/esm/4d/project-4d.d.ts +10 -0
  524. package/dist/esm/4d/project-4d.js +14 -0
  525. package/dist/esm/4d/random-4d.d.ts +7 -0
  526. package/dist/esm/4d/random-4d.js +17 -0
  527. package/dist/esm/4d/reflect-4d.d.ts +9 -0
  528. package/dist/esm/4d/reflect-4d.js +17 -0
  529. package/dist/esm/4d/set-magnitude-4d.d.ts +9 -0
  530. package/dist/esm/4d/set-magnitude-4d.js +14 -0
  531. package/dist/esm/4d/subtract-4d.d.ts +8 -0
  532. package/dist/esm/4d/subtract-4d.js +12 -0
  533. package/dist/esm/4d/types.d.ts +4 -0
  534. package/dist/esm/4d/types.js +1 -0
  535. package/dist/esm/4d/zero-4d.d.ts +6 -0
  536. package/dist/esm/4d/zero-4d.js +5 -0
  537. package/dist/esm/index.d.ts +4 -0
  538. package/dist/esm/index.js +4 -0
  539. package/dist/esm/slerp.d.ts +21 -0
  540. package/dist/esm/slerp.js +23 -0
  541. package/dist/esm/vec2.d.ts +10 -4
  542. package/dist/esm/vec2.js +13 -6
  543. package/dist/esm/vec3.d.ts +121 -106
  544. package/dist/esm/vec3.js +127 -129
  545. package/dist/esm/vec4.d.ts +118 -100
  546. package/dist/esm/vec4.js +134 -134
  547. package/docs/ArrayVector2D.md +1090 -0
  548. package/docs/ArrayVector3D.md +1162 -0
  549. package/docs/ArrayVector4D.md +1019 -0
  550. package/docs/README.md +13 -0
  551. package/docs/Slerp.md +64 -0
  552. package/docs/Vec2.md +1827 -0
  553. package/docs/Vec3.md +2084 -0
  554. package/docs/Vec4.md +2031 -0
  555. package/package.json +30 -9
  556. package/VEC2.md +0 -147
  557. package/VEC3.md +0 -172
  558. package/VEC4.md +0 -161
package/dist/esm/vec4.js CHANGED
@@ -1,4 +1,8 @@
1
- const { cos, acos, atan2, sqrt, abs } = Math;
1
+ /**
2
+ * Documentation for 4D Vector class.
3
+ * @module Vec4
4
+ */
5
+ const { sin, cos, acos, atan2, sqrt, abs, log, PI } = Math;
2
6
  /**
3
7
  * Represents a 4D vector with various operations.
4
8
  */
@@ -9,10 +13,11 @@ export class Vec4 {
9
13
  /**
10
14
  * Computes and updates the magnitude of the vector.
11
15
  * @private
12
- * @param x - The x-component of the vector.
13
- * @param y - The y-component of the vector.
14
- * @param z - The z-component of the vector.
15
- * @param w - The w-component of the vector.
16
+ * @param {number} x - The x-component of the vector.
17
+ * @param {number} y - The y-component of the vector.
18
+ * @param {number} z - The z-component of the vector.
19
+ * @param {number} w - The w-component of the vector.
20
+ * @returns {void}
16
21
  */
17
22
  #computeMagnitude(x = this.#xyzw[0], y = this.#xyzw[1], z = this.#xyzw[2], w = this.#xyzw[3]) {
18
23
  if (x !== this.#prevXYZW[0] || y !== this.#prevXYZW[1] || z !== this.#prevXYZW[2] || w !== this.#prevXYZW[3]) {
@@ -25,10 +30,10 @@ export class Vec4 {
25
30
  }
26
31
  /**
27
32
  * Creates a new Vec4 instance.
28
- * @param x - The x-coordinate of the vector.
29
- * @param y - The y-coordinate of the vector.
30
- * @param z - The z-coordinate of the vector.
31
- * @param w - The w-coordinate of the vector.
33
+ * @param {number} x - The x-coordinate of the vector.
34
+ * @param {number} y - The y-coordinate of the vector.
35
+ * @param {number} z - The z-coordinate of the vector.
36
+ * @param {number} w - The w-coordinate of the vector.
32
37
  */
33
38
  constructor(x = 0, y = 0, z = 0, w = 0) {
34
39
  this.#xyzw[0] = x;
@@ -39,18 +44,18 @@ export class Vec4 {
39
44
  }
40
45
  /**
41
46
  * Adds two vectors.
42
- * @param v - The first vector.
43
- * @param w - The second vector.
44
- * @returns A new Vec3 instance representing the sum.
47
+ * @param {Vec4} v - The first vector.
48
+ * @param {Vec4} w - The second vector.
49
+ * @returns {Vec4} A new Vec4 instance representing the sum.
45
50
  */
46
51
  static add(v, w) {
47
52
  return new Vec4(v.#xyzw[0] + w.#xyzw[0], v.#xyzw[1] + w.#xyzw[1], v.#xyzw[2] + w.#xyzw[2], v.#xyzw[3] + w.#xyzw[3]);
48
53
  }
49
54
  /**
50
55
  * Subtracts one vector from another.
51
- * @param v - The vector to subtract from.
52
- * @param w - The vector to subtract.
53
- * @returns A new Vec2 instance representing the difference.
56
+ * @param {Vec4} v - The vector to subtract from.
57
+ * @param {Vec4} w - The vector to subtract.
58
+ * @returns {Vec4} A new Vec4 instance representing the difference.
54
59
  */
55
60
  static subtract(v, w) {
56
61
  return new Vec4(v.#xyzw[0] - w.#xyzw[0], v.#xyzw[1] - w.#xyzw[1], v.#xyzw[2] - w.#xyzw[2], v.#xyzw[3] - w.#xyzw[3]);
@@ -75,9 +80,9 @@ export class Vec4 {
75
80
  }
76
81
  /**
77
82
  * Calculates the angle between two vectors.
78
- * @param v - The first vector.
79
- * @param w - The second vector.
80
- * @returns The angle between the vectors in radians.
83
+ * @param {Vec4} v - The first vector.
84
+ * @param {Vec4} w - The second vector.
85
+ * @returns {number} The angle between the vectors in radians.
81
86
  */
82
87
  static angleBetween(v, w) {
83
88
  return acos((v.#xyzw[0] * w.#xyzw[0] + v.#xyzw[1] * w.#xyzw[1] + v.#xyzw[2] * w.#xyzw[2] + v.#xyzw[3] * w.#xyzw[3]) /
@@ -85,9 +90,9 @@ export class Vec4 {
85
90
  }
86
91
  /**
87
92
  * Calculates the Euclidean distance between two vectors.
88
- * @param v - The first vector.
89
- * @param w - The second vector.
90
- * @returns The distance between the vectors.
93
+ * @param {Vec4} v - The first vector.
94
+ * @param {Vec4} w - The second vector.
95
+ * @returns {number} The distance between the vectors.
91
96
  */
92
97
  static distance(v, w) {
93
98
  return sqrt((v.#xyzw[0] - w.#xyzw[0]) ** 2 +
@@ -97,9 +102,9 @@ export class Vec4 {
97
102
  }
98
103
  /**
99
104
  * Calculates the Chebyshev distance between two vectors.
100
- * @param v - The first vector.
101
- * @param w - The second vector.
102
- * @returns The Chebyshev distance between the vectors.
105
+ * @param {Vec4} v - The first vector.
106
+ * @param {Vec4} w - The second vector.
107
+ * @returns {number} The Chebyshev distance between the vectors.
103
108
  */
104
109
  static distanceChebyshev(v, w) {
105
110
  const absX = abs(v.#xyzw[0] - w.#xyzw[0]);
@@ -116,9 +121,9 @@ export class Vec4 {
116
121
  }
117
122
  /**
118
123
  * Calculates the Manhattan distance between two vectors.
119
- * @param v - The first vector.
120
- * @param w - The second vector.
121
- * @returns The Manhattan distance between the vectors.
124
+ * @param {Vec4} v - The first vector.
125
+ * @param {Vec4} w - The second vector.
126
+ * @returns {number} The Manhattan distance between the vectors.
122
127
  */
123
128
  static distanceManhattan(v, w) {
124
129
  return (abs(v.#xyzw[0] - w.#xyzw[0]) +
@@ -128,10 +133,10 @@ export class Vec4 {
128
133
  }
129
134
  /**
130
135
  * Calculates the Minkowski distance between two vectors.
131
- * @param v - The first vector.
132
- * @param w - The second vector.
133
- * @param p - The order of the Minkowski distance.
134
- * @returns The Minkowski distance between the vectors.
136
+ * @param {Vec4} v - The first vector.
137
+ * @param {Vec4} w - The second vector.
138
+ * @param {number} p - The order of the Minkowski distance.
139
+ * @returns {number} The Minkowski distance between the vectors.
135
140
  */
136
141
  static distanceMinkowski(v, w, p) {
137
142
  return ((abs(v.#xyzw[0] - w.#xyzw[0]) ** p +
@@ -142,9 +147,9 @@ export class Vec4 {
142
147
  }
143
148
  /**
144
149
  * Calculates the squared Euclidean distance between two vectors.
145
- * @param v - The first vector.
146
- * @param w - The second vector.
147
- * @returns The squared distance between the vectors.
150
+ * @param {Vec4} v - The first vector.
151
+ * @param {Vec4} w - The second vector.
152
+ * @returns {number} The squared distance between the vectors.
148
153
  */
149
154
  static distanceSq(v, w) {
150
155
  return ((v.#xyzw[0] - w.#xyzw[0]) ** 2 +
@@ -154,9 +159,9 @@ export class Vec4 {
154
159
  }
155
160
  /**
156
161
  * Calculates the dot product of two vectors.
157
- * @param v - The first vector.
158
- * @param w - The second vector.
159
- * @returns The dot product of the two vectors.
162
+ * @param {Vec4} v - The first vector.
163
+ * @param {Vec4} w - The second vector.
164
+ * @returns {number} The dot product of the two vectors.
160
165
  */
161
166
  static dot(v, w) {
162
167
  return v.#xyzw[0] * w.#xyzw[0] + v.#xyzw[1] * w.#xyzw[1] + v.#xyzw[2] * w.#xyzw[2] + v.#xyzw[3] * w.#xyzw[3];
@@ -178,9 +183,11 @@ export class Vec4 {
178
183
  }
179
184
  /**
180
185
  * Creates an immutable Vec4-like object.
181
- * @param x - The x-coordinate of the vector.
182
- * @param y - The y-coordinate of the vector.
183
- * @returns An immutable object with Vec4-like properties.
186
+ * @param {number} x - The x-coordinate of the vector.
187
+ * @param {number} y - The y-coordinate of the vector.
188
+ * @param {number} z - The z-coordinate of the vector.
189
+ * @param {number} w - The w-coordinate of the vector.
190
+ * @returns {Readonly<{ x: number; y: number; z: number; w: number; xyzw: readonly number[]; r: number; g: number; b: number; a: number; rgba: readonly number[]; magnitude: number; magnitudeSq: number; angleW: number; angleX: number; angleY: number; angleZ: number; isInfinite: boolean; isNaN: boolean; isZero: boolean }>} An immutable object with Vec4-like properties.
184
191
  */
185
192
  static immutable(x = 0, y = 0, z = 0, w = 0) {
186
193
  const data = new Float64Array(10);
@@ -269,8 +276,8 @@ export class Vec4 {
269
276
  }
270
277
  /**
271
278
  * Checks if a vector has infinite components.
272
- * @param v - The vector to check.
273
- * @returns True if the vector has infinite components, false otherwise.
279
+ * @param {Vec4} v - The vector to check.
280
+ * @returns {boolean} True if the vector has infinite components, false otherwise.
274
281
  */
275
282
  static isInfinite(v) {
276
283
  const x = v.#xyzw[0];
@@ -288,26 +295,26 @@ export class Vec4 {
288
295
  }
289
296
  /**
290
297
  * Checks if a vector has NaN components.
291
- * @param v - The vector to check.
292
- * @returns True if the vector has NaN components, false otherwise.
298
+ * @param {Vec4} v - The vector to check.
299
+ * @returns {boolean} True if the vector has NaN components, false otherwise.
293
300
  */
294
301
  static isNaN(v) {
295
302
  return Number.isNaN(v.#xyzw[0]) || Number.isNaN(v.#xyzw[1]) || Number.isNaN(v.#xyzw[2]) || Number.isNaN(v.#xyzw[3]);
296
303
  }
297
304
  /**
298
305
  * Checks if a vector is zero.
299
- * @param v - The vector to check.
300
- * @returns True if the vector is zero, false otherwise.
306
+ * @param {Vec4} v - The vector to check.
307
+ * @returns {boolean} True if the vector is zero, false otherwise.
301
308
  */
302
309
  static isZero(v) {
303
310
  return v.#xyzw[0] === 0 && v.#xyzw[1] === 0 && v.#xyzw[2] === 0 && v.#xyzw[3] === 0;
304
311
  }
305
312
  /**
306
313
  * Performs linear interpolation between two vectors.
307
- * @param v - The first vector.
308
- * @param w - The second vector.
309
- * @param t - The interpolation parameter (0 to 1).
310
- * @returns A new Vec2 instance representing the interpolated vector.
314
+ * @param {Vec4} v - The first vector.
315
+ * @param {Vec4} w - The second vector.
316
+ * @param {number} t - The interpolation parameter (0 to 1).
317
+ * @returns {Vec4} A new Vec4 instance representing the interpolated vector.
311
318
  */
312
319
  static lerp(v, w, t) {
313
320
  if (t > 1)
@@ -322,16 +329,16 @@ export class Vec4 {
322
329
  }
323
330
  /**
324
331
  * Negates a vector.
325
- * @param v - The vector to negate.
326
- * @returns A new Vec2 instance representing the negated vector.
332
+ * @param {Vec4} v - The vector to negate.
333
+ * @returns {Vec4} A new Vec4 instance representing the negated vector.
327
334
  */
328
335
  static negate(v) {
329
336
  return new Vec4(-v.#xyzw[0], -v.#xyzw[1], -v.#xyzw[2], -v.#xyzw[3]);
330
337
  }
331
338
  /**
332
339
  * Normalizes a vector.
333
- * @param v - The vector to normalize.
334
- * @returns A new Vec2 instance representing the normalized vector.
340
+ * @param {Vec4} v - The vector to normalize.
341
+ * @returns {Vec4} A new Vec4 instance representing the normalized vector.
335
342
  */
336
343
  static normalize(v) {
337
344
  const m = v.#magnitude;
@@ -339,9 +346,9 @@ export class Vec4 {
339
346
  }
340
347
  /**
341
348
  * Projects one vector onto another.
342
- * @param v - The vector to project.
343
- * @param w - The vector to project onto.
344
- * @returns A new Vec2 instance representing the projected vector.
349
+ * @param {Vec4} v - The vector to project.
350
+ * @param {Vec4} w - The vector to project onto.
351
+ * @returns {Vec4} A new Vec4 instance representing the projected vector.
345
352
  */
346
353
  static project(v, w) {
347
354
  const vM = v.#magnitude;
@@ -355,37 +362,34 @@ export class Vec4 {
355
362
  }
356
363
  /**
357
364
  * Creates a random unit vector.
358
- * @param random - A function that returns a random number between 0 and 1.
359
- * @returns A new Vec4 instance representing a random unit vector.
365
+ * @param {() => number} random - A function that returns a random number between 0 and 1.
366
+ * @returns {Vec4} A new Vec4 instance representing a random unit vector.
360
367
  */
361
368
  static random(random = Math.random) {
362
- let x1;
363
- let x2;
364
- let x3;
365
- let x4;
366
- do {
367
- x1 = random() * 2 - 1;
368
- x2 = random() * 2 - 1;
369
- x3 = random() * 2 - 1;
370
- x4 = random() * 2 - 1;
371
- } while (x1 ** 2 + x2 ** 2 >= 1 || x3 ** 2 + x4 ** 2 >= 1);
372
- const f = sqrt((1 - x1 ** 2 - x2 ** 2) / (x3 ** 2 + x4 ** 2));
373
- return new Vec4(x1, x2, x3 * f, x4 * f);
369
+ // 1. Generate four numbers from a Normal Distribution (Box-Muller transform)
370
+ const x = sqrt(-2 * log(random())) * cos(2 * PI * random());
371
+ const y = sqrt(-2 * log(random())) * sin(2 * PI * random());
372
+ const z = sqrt(-2 * log(random())) * cos(2 * PI * random());
373
+ const w = sqrt(-2 * log(random())) * sin(2 * PI * random());
374
+ // 2. Calculate the current length
375
+ const length = sqrt(x * x + y * y + z * z + w * w);
376
+ // 3. Divide by length to make it a unit vector
377
+ return new Vec4(x / length, y / length, z / length, w / length);
374
378
  }
375
379
  /**
376
380
  * Checks if two vectors are equal.
377
- * @param v - The first vector.
378
- * @param w - The second vector.
379
- * @returns True if the vectors are equal, false otherwise.
381
+ * @param {Vec4} v - The first vector.
382
+ * @param {Vec4} w - The second vector.
383
+ * @returns {boolean} True if the vectors are equal, false otherwise.
380
384
  */
381
385
  static satisfyEquality(v, w) {
382
386
  return (v.#xyzw[0] === w.#xyzw[0] && v.#xyzw[1] === w.#xyzw[1] && v.#xyzw[2] === w.#xyzw[2] && v.#xyzw[3] === w.#xyzw[3]);
383
387
  }
384
388
  /**
385
389
  * Checks if two vectors are opposite.
386
- * @param v - The first vector.
387
- * @param w - The second vector.
388
- * @returns True if the vectors are opposite, false otherwise.
390
+ * @param {Vec4} v - The first vector.
391
+ * @param {Vec4} w - The second vector.
392
+ * @returns {boolean} True if the vectors are opposite, false otherwise.
389
393
  */
390
394
  static satisfyOpposition(v, w) {
391
395
  return (v.#xyzw[0] === -w.#xyzw[0] &&
@@ -408,16 +412,16 @@ export class Vec4 {
408
412
  }
409
413
  /**
410
414
  * Scales a vector by a scalar value.
411
- * @param v - The vector to scale.
412
- * @param c - The scalar value.
413
- * @returns A new Vec2 instance representing the scaled vector.
415
+ * @param {Vec4} v - The vector to scale.
416
+ * @param {number} c - The scalar value.
417
+ * @returns {Vec4} A new Vec4 instance representing the scaled vector.
414
418
  */
415
419
  static scale(v, c) {
416
420
  return new Vec4(v.#xyzw[0] * c, v.#xyzw[1] * c, v.#xyzw[2] * c, v.#xyzw[3] * c);
417
421
  }
418
422
  /**
419
423
  * Creates a zero vector.
420
- * @returns A new Vec4 instance representing a zero vector.
424
+ * @returns {Vec4} A new Vec4 instance representing a zero vector.
421
425
  */
422
426
  static zero() {
423
427
  return new Vec4();
@@ -431,14 +435,16 @@ export class Vec4 {
431
435
  }
432
436
  /**
433
437
  * Creates a Vec4 from an array.
434
- * @returns A new Vec4 instance.
438
+ * @param {[number, number, number, number] | number[]} arr - An array containing the x, y, z, and w coordinates.
439
+ * @returns {Vec4} A new Vec4 instance.
435
440
  */
436
441
  static fromArray(arr) {
437
442
  return new Vec4(arr[0] ?? 0, arr[1] ?? 0, arr[2] ?? 0, arr[3] ?? 0);
438
443
  }
439
444
  /**
440
445
  * Creates a Vec4 from an object with x, y, z and w properties.
441
- * @returns A new Vec4 instance.
446
+ * @param {{ x: number; y: number; z: number; w: number }} obj - An object with x, y, z, and w properties.
447
+ * @returns {Vec4} A new Vec4 instance.
442
448
  */
443
449
  static fromObject(obj) {
444
450
  return new Vec4(obj.x, obj.y, obj.z, obj.w);
@@ -453,14 +459,15 @@ export class Vec4 {
453
459
  }
454
460
  /**
455
461
  * Gets the x-component of the vector.
456
- * @returns The x-component.
462
+ * @returns {number} The x-component.
457
463
  */
458
464
  get x() {
459
465
  return this.#xyzw[0];
460
466
  }
461
467
  /**
462
468
  * Sets the x-component of the vector.
463
- * @param x - The new x-component.
469
+ * @param {number} x - The new x-component.
470
+ * @returns {void}
464
471
  */
465
472
  set x(x) {
466
473
  this.#xyzw[0] = x;
@@ -468,14 +475,15 @@ export class Vec4 {
468
475
  }
469
476
  /**
470
477
  * Gets the y-component of the vector.
471
- * @returns The y-component.
478
+ * @returns {number} The y-component.
472
479
  */
473
480
  get y() {
474
481
  return this.#xyzw[1];
475
482
  }
476
483
  /**
477
484
  * Sets the z-component of the vector.
478
- * @param y - The new z-component.
485
+ * @param {number} y - The new z-component.
486
+ * @returns {void}
479
487
  */
480
488
  set y(y) {
481
489
  this.#xyzw[1] = y;
@@ -483,14 +491,15 @@ export class Vec4 {
483
491
  }
484
492
  /**
485
493
  * Gets the z-component of the vector.
486
- * @returns The z-component.
494
+ * @returns {number} The z-component.
487
495
  */
488
496
  get z() {
489
497
  return this.#xyzw[2];
490
498
  }
491
499
  /**
492
500
  * Sets the z-component of the vector.
493
- * @param z - The new z-component.
501
+ * @param {number} z - The new z-component.
502
+ * @returns {void}
494
503
  */
495
504
  set z(z) {
496
505
  this.#xyzw[2] = z;
@@ -498,14 +507,15 @@ export class Vec4 {
498
507
  }
499
508
  /**
500
509
  * Gets the w-component of the vector.
501
- * @returns The w-component.
510
+ * @returns {number} The w-component.
502
511
  */
503
512
  get w() {
504
513
  return this.#xyzw[3];
505
514
  }
506
515
  /**
507
516
  * Sets the w-component of the vector.
508
- * @param w - The new w-component.
517
+ * @param {number} w - The new w-component.
518
+ * @returns {void}
509
519
  */
510
520
  set w(w) {
511
521
  this.#xyzw[3] = w;
@@ -513,14 +523,15 @@ export class Vec4 {
513
523
  }
514
524
  /**
515
525
  * Gets a copy of the vector's components as an array.
516
- * @returns An array containing the x, y, z and w components of the vector.
526
+ * @returns {[number, number, number, number]} An array containing the x, y, z and w components of the vector.
517
527
  */
518
528
  get xyzw() {
519
529
  return Array.from(this.#xyzw.slice());
520
530
  }
521
531
  /**
522
532
  * Sets both components of the vector at once.
523
- * @param xyzw - An array containing the new x, y and z components.
533
+ * @param {[number, number, number, number]} xyzw - An array containing the new x, y, z and w components.
534
+ * @returns {void}
524
535
  */
525
536
  set xyzw(xyzw) {
526
537
  this.#xyzw[0] = xyzw[0];
@@ -531,70 +542,75 @@ export class Vec4 {
531
542
  }
532
543
  /**
533
544
  * Gets the Red-component of a Color.
534
- * @returns The Red-component.
545
+ * @returns {number} The Red-component.
535
546
  */
536
547
  get r() {
537
548
  return this.x;
538
549
  }
539
550
  /**
540
551
  * Sets the Red-component of a Color.
541
- * @param r - The new Red-component.
552
+ * @param {number} r - The new Red-component.
553
+ * @returns {void}
542
554
  */
543
555
  set r(r) {
544
556
  this.x = r;
545
557
  }
546
558
  /**
547
559
  * Gets the Green-component of a Color.
548
- * @returns The Green-component.
560
+ * @returns {number} The Green-component.
549
561
  */
550
562
  get g() {
551
563
  return this.y;
552
564
  }
553
565
  /**
554
566
  * Sets the Green-component of the Color.
555
- * @param g - The new Green-component.
567
+ * @param {number} g - The new Green-component.
568
+ * @returns {void}
556
569
  */
557
570
  set g(g) {
558
571
  this.y = g;
559
572
  }
560
573
  /**
561
574
  * Gets the Blue-component of the color.
562
- * @returns The Blue-component.
575
+ * @returns {number} The Blue-component.
563
576
  */
564
577
  get b() {
565
578
  return this.z;
566
579
  }
567
580
  /**
568
581
  * Sets the Blue-component of the Color.
569
- * @param b - The new Blue-component.
582
+ * @param {number} b - The new Blue-component.
583
+ * @returns {void}
570
584
  */
571
585
  set b(b) {
572
586
  this.z = b;
573
587
  }
574
588
  /**
575
589
  * Gets the Alpha-component of the color.
576
- * @returns The Alpha-component.
590
+ * @returns {number} The Alpha-component.
577
591
  */
578
592
  get a() {
579
593
  return this.w;
580
594
  }
581
595
  /**
582
596
  * Sets the Alpha-component of the Color.
583
- * @param b - The new Alpha-component.
597
+ * @param {number} a - The new Alpha-component.
598
+ * @returns {void}
584
599
  */
585
600
  set a(a) {
586
601
  this.w = a;
587
602
  }
588
603
  /**
589
604
  * Gets a copy of the vector's components as an array.
590
- * @returns An array containing the Red, Green, Blue and Alpha components of the Color.
605
+ * @returns {[number, number, number, number]} An array containing the Red, Green, Blue and Alpha components of the Color.
591
606
  */
592
607
  get rgba() {
593
608
  return this.xyzw;
594
609
  }
595
610
  /**
596
611
  * Sets all components of the Color at once.
597
- * @param rgba - An array containing the new Red, Green and Blue components.
612
+ * @param {[number, number, number, number]} rgba - An array containing the new Red, Green, Blue and Alpha components.
613
+ * @returns {void}
598
614
  */
599
615
  set rgba(rgba) {
600
616
  this.xyzw = rgba;
@@ -656,8 +672,8 @@ export class Vec4 {
656
672
  }
657
673
  /**
658
674
  * Adds another vector to this vector.
659
- * @param v - The vector to add.
660
- * @returns This Vec4 instance for method chaining.
675
+ * @param {Vec4} v - The vector to add.
676
+ * @returns {this} This Vec4 instance for method chaining.
661
677
  */
662
678
  add(v) {
663
679
  this.#xyzw[0] += v.#xyzw[0];
@@ -719,9 +735,9 @@ export class Vec4 {
719
735
  }
720
736
  /**
721
737
  * Clamps the magnitude of this vector between a minimum and maximum value.
722
- * @param min - The minimum magnitude.
723
- * @param max - The maximum magnitude.
724
- * @returns This Vec4 instance for method chaining.
738
+ * @param {number} min - The minimum magnitude.
739
+ * @param {number} max - The maximum magnitude.
740
+ * @returns {this} This Vec4 instance for method chaining.
725
741
  */
726
742
  clamp(min, max) {
727
743
  const m = this.#magnitude;
@@ -743,7 +759,7 @@ export class Vec4 {
743
759
  }
744
760
  /**
745
761
  * Creates a copy of this vector.
746
- * @returns A new Vec4 instance with the same components.
762
+ * @returns {Vec4} A new Vec4 instance with the same components.
747
763
  */
748
764
  clone() {
749
765
  return new Vec4(this.#xyzw[0], this.#xyzw[1], this.#xyzw[2], this.#xyzw[3]);
@@ -774,8 +790,8 @@ export class Vec4 {
774
790
  }
775
791
  /**
776
792
  * Calculates the Chebyshev distance between this vector and another vector.
777
- * @param v - The first vector.
778
- * @returns The Chebyshev distance between the vectors.
793
+ * @param {Vec4} v - The other vector.
794
+ * @returns {number} The Chebyshev distance between the vectors.
779
795
  */
780
796
  distanceChebyshev(v) {
781
797
  const absX = abs(this.#xyzw[0] - v.#xyzw[0]);
@@ -792,8 +808,8 @@ export class Vec4 {
792
808
  }
793
809
  /**
794
810
  * Calculates the Manhattan distance between this vector and another vector.
795
- * @param v - The other vector.
796
- * @returns The Manhattan distance between the vectors.
811
+ * @param {Vec4} v - The other vector.
812
+ * @returns {number} The Manhattan distance between the vectors.
797
813
  */
798
814
  distanceManhattan(v) {
799
815
  return (abs(this.#xyzw[0] - v.#xyzw[0]) +
@@ -802,10 +818,10 @@ export class Vec4 {
802
818
  abs(this.#xyzw[3] - v.#xyzw[3]));
803
819
  }
804
820
  /**
805
- * Calculates the Minkowski distance between thisvector and another vector.
806
- * @param v - The other vector.
807
- * @param p - The order of the Minkowski distance.
808
- * @returns The Minkowski distance between the vectors.
821
+ * Calculates the Minkowski distance between this vector and another vector.
822
+ * @param {Vec4} v - The other vector.
823
+ * @param {number} p - The order of the Minkowski distance.
824
+ * @returns {number} The Minkowski distance between the vectors.
809
825
  */
810
826
  distanceMinkowski(v, p) {
811
827
  return ((abs(this.#xyzw[0] - v.#xyzw[0]) ** p +
@@ -984,23 +1000,7 @@ export class Vec4 {
984
1000
  * @returns This Vec4 instance for method chaining.
985
1001
  */
986
1002
  random(random = Math.random) {
987
- let x1;
988
- let x2;
989
- let x3;
990
- let x4;
991
- do {
992
- x1 = random() * 2 - 1;
993
- x2 = random() * 2 - 1;
994
- x3 = random() * 2 - 1;
995
- x4 = random() * 2 - 1;
996
- } while (x1 ** 2 + x2 ** 2 >= 1 || x3 ** 2 + x4 ** 2 >= 1);
997
- const f = sqrt((1 - x1 ** 2 - x2 ** 2) / (x3 ** 2 + x4 ** 2));
998
- const m = this.#magnitude;
999
- this.#xyzw[0] = m * x1;
1000
- this.#xyzw[1] = m * x2;
1001
- this.#xyzw[2] = m * x3 * f;
1002
- this.#xyzw[3] = m * x4 * f;
1003
- this.#computeMagnitude();
1003
+ this.copy(Vec4.random(random));
1004
1004
  return this;
1005
1005
  }
1006
1006
  /**