@ac-kit/math-geometry 0.2.2 → 0.3.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 (371) hide show
  1. package/CHANGELOG.md +228 -0
  2. package/README.md +323 -52
  3. package/dist/_brand.d.ts +14 -0
  4. package/dist/_brand.d.ts.map +1 -0
  5. package/dist/_brand.js +2 -0
  6. package/dist/_brand.js.map +1 -0
  7. package/dist/_ear-clipping.d.ts +20 -0
  8. package/dist/_ear-clipping.d.ts.map +1 -0
  9. package/dist/_ear-clipping.js +360 -0
  10. package/dist/_ear-clipping.js.map +1 -0
  11. package/dist/_ray3-intersect.d.ts +19 -0
  12. package/dist/_ray3-intersect.d.ts.map +1 -0
  13. package/dist/_ray3-intersect.js +122 -0
  14. package/dist/_ray3-intersect.js.map +1 -0
  15. package/dist/box2-array-boundary.d.ts +50 -0
  16. package/dist/box2-array-boundary.d.ts.map +1 -0
  17. package/dist/box2-array-boundary.js +97 -0
  18. package/dist/box2-array-boundary.js.map +1 -0
  19. package/dist/box2-array.d.ts +42 -0
  20. package/dist/box2-array.d.ts.map +1 -0
  21. package/dist/box2-array.js +134 -0
  22. package/dist/box2-array.js.map +1 -0
  23. package/dist/box2-componentwise.d.ts +110 -0
  24. package/dist/box2-componentwise.d.ts.map +1 -0
  25. package/dist/box2-componentwise.js +325 -0
  26. package/dist/box2-componentwise.js.map +1 -0
  27. package/dist/box2-grid-index.d.ts +67 -0
  28. package/dist/box2-grid-index.d.ts.map +1 -0
  29. package/dist/box2-grid-index.js +198 -0
  30. package/dist/box2-grid-index.js.map +1 -0
  31. package/dist/box2-record.d.ts +83 -0
  32. package/dist/box2-record.d.ts.map +1 -0
  33. package/dist/box2-record.js +124 -0
  34. package/dist/box2-record.js.map +1 -0
  35. package/dist/box2.d.ts +38 -0
  36. package/dist/box2.d.ts.map +1 -0
  37. package/dist/box2.js +97 -0
  38. package/dist/box2.js.map +1 -0
  39. package/dist/box3-array-boundary.d.ts +50 -0
  40. package/dist/box3-array-boundary.d.ts.map +1 -0
  41. package/dist/box3-array-boundary.js +107 -0
  42. package/dist/box3-array-boundary.js.map +1 -0
  43. package/dist/box3-componentwise.d.ts +110 -0
  44. package/dist/box3-componentwise.d.ts.map +1 -0
  45. package/dist/box3-componentwise.js +392 -0
  46. package/dist/box3-componentwise.js.map +1 -0
  47. package/dist/box3-record.d.ts +92 -0
  48. package/dist/box3-record.d.ts.map +1 -0
  49. package/dist/box3-record.js +147 -0
  50. package/dist/box3-record.js.map +1 -0
  51. package/dist/box3.d.ts +19 -16
  52. package/dist/box3.d.ts.map +1 -1
  53. package/dist/box3.js +73 -76
  54. package/dist/box3.js.map +1 -1
  55. package/dist/box4-array-boundary.d.ts +50 -0
  56. package/dist/box4-array-boundary.d.ts.map +1 -0
  57. package/dist/box4-array-boundary.js +117 -0
  58. package/dist/box4-array-boundary.js.map +1 -0
  59. package/dist/box4-componentwise.d.ts +110 -0
  60. package/dist/box4-componentwise.d.ts.map +1 -0
  61. package/dist/box4-componentwise.js +459 -0
  62. package/dist/box4-componentwise.js.map +1 -0
  63. package/dist/box4-record.d.ts +96 -0
  64. package/dist/box4-record.d.ts.map +1 -0
  65. package/dist/box4-record.js +167 -0
  66. package/dist/box4-record.js.map +1 -0
  67. package/dist/box4.d.ts +13 -8
  68. package/dist/box4.d.ts.map +1 -1
  69. package/dist/box4.js +27 -5
  70. package/dist/box4.js.map +1 -1
  71. package/dist/circle2-array-boundary.d.ts +51 -0
  72. package/dist/circle2-array-boundary.d.ts.map +1 -0
  73. package/dist/circle2-array-boundary.js +93 -0
  74. package/dist/circle2-array-boundary.js.map +1 -0
  75. package/dist/circle2-array.d.ts +17 -0
  76. package/dist/circle2-array.d.ts.map +1 -0
  77. package/dist/circle2-array.js +44 -0
  78. package/dist/circle2-array.js.map +1 -0
  79. package/dist/circle2-record.d.ts +81 -0
  80. package/dist/circle2-record.d.ts.map +1 -0
  81. package/dist/circle2-record.js +114 -0
  82. package/dist/circle2-record.js.map +1 -0
  83. package/dist/circle2.d.ts +27 -82
  84. package/dist/circle2.d.ts.map +1 -1
  85. package/dist/circle2.js +59 -104
  86. package/dist/circle2.js.map +1 -1
  87. package/dist/coordinates/cylindrical-record.d.ts +86 -0
  88. package/dist/coordinates/cylindrical-record.d.ts.map +1 -0
  89. package/dist/coordinates/cylindrical-record.js +114 -0
  90. package/dist/coordinates/cylindrical-record.js.map +1 -0
  91. package/dist/coordinates/horizontal-record.d.ts +86 -0
  92. package/dist/coordinates/horizontal-record.d.ts.map +1 -0
  93. package/dist/coordinates/horizontal-record.js +114 -0
  94. package/dist/coordinates/horizontal-record.js.map +1 -0
  95. package/dist/coordinates/horizontal.d.ts +48 -0
  96. package/dist/coordinates/horizontal.d.ts.map +1 -0
  97. package/dist/coordinates/horizontal.js +100 -0
  98. package/dist/coordinates/horizontal.js.map +1 -0
  99. package/dist/coordinates/index.d.ts +10 -0
  100. package/dist/coordinates/index.d.ts.map +1 -0
  101. package/dist/coordinates/index.js +10 -0
  102. package/dist/coordinates/index.js.map +1 -0
  103. package/dist/coordinates/longitude-latitude-record.d.ts +81 -0
  104. package/dist/coordinates/longitude-latitude-record.d.ts.map +1 -0
  105. package/dist/coordinates/longitude-latitude-record.js +104 -0
  106. package/dist/coordinates/longitude-latitude-record.js.map +1 -0
  107. package/dist/coordinates/longitude-latitude.d.ts +33 -0
  108. package/dist/coordinates/longitude-latitude.d.ts.map +1 -0
  109. package/dist/coordinates/longitude-latitude.js +78 -0
  110. package/dist/coordinates/longitude-latitude.js.map +1 -0
  111. package/dist/coordinates/polar-record.d.ts +77 -0
  112. package/dist/coordinates/polar-record.d.ts.map +1 -0
  113. package/dist/coordinates/polar-record.js +104 -0
  114. package/dist/coordinates/polar-record.js.map +1 -0
  115. package/dist/coordinates/polar.d.ts +28 -0
  116. package/dist/coordinates/polar.d.ts.map +1 -0
  117. package/dist/coordinates/polar.js +68 -0
  118. package/dist/coordinates/polar.js.map +1 -0
  119. package/dist/coordinates/spherical-cylindrical.d.ts +49 -0
  120. package/dist/coordinates/spherical-cylindrical.d.ts.map +1 -0
  121. package/dist/coordinates/spherical-cylindrical.js +110 -0
  122. package/dist/coordinates/spherical-cylindrical.js.map +1 -0
  123. package/dist/coordinates/spherical-record.d.ts +86 -0
  124. package/dist/coordinates/spherical-record.d.ts.map +1 -0
  125. package/dist/coordinates/spherical-record.js +114 -0
  126. package/dist/coordinates/spherical-record.js.map +1 -0
  127. package/dist/frustum3-record.d.ts +132 -0
  128. package/dist/frustum3-record.d.ts.map +1 -0
  129. package/dist/frustum3-record.js +333 -0
  130. package/dist/frustum3-record.js.map +1 -0
  131. package/dist/frustum3.d.ts +60 -0
  132. package/dist/frustum3.d.ts.map +1 -0
  133. package/dist/frustum3.js +186 -0
  134. package/dist/frustum3.js.map +1 -0
  135. package/dist/index.d.ts +36 -16
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +36 -16
  138. package/dist/index.js.map +1 -1
  139. package/dist/line2-record.d.ts +87 -0
  140. package/dist/line2-record.d.ts.map +1 -0
  141. package/dist/line2-record.js +123 -0
  142. package/dist/line2-record.js.map +1 -0
  143. package/dist/line2.d.ts +20 -33
  144. package/dist/line2.d.ts.map +1 -1
  145. package/dist/line2.js +56 -51
  146. package/dist/line2.js.map +1 -1
  147. package/dist/line3-record.d.ts +91 -0
  148. package/dist/line3-record.d.ts.map +1 -0
  149. package/dist/line3-record.js +146 -0
  150. package/dist/line3-record.js.map +1 -0
  151. package/dist/line3.d.ts +11 -24
  152. package/dist/line3.d.ts.map +1 -1
  153. package/dist/line3.js +32 -36
  154. package/dist/line3.js.map +1 -1
  155. package/dist/mesh/_generator-kit.d.ts +14 -0
  156. package/dist/mesh/_generator-kit.d.ts.map +1 -0
  157. package/dist/mesh/_generator-kit.js +39 -0
  158. package/dist/mesh/_generator-kit.js.map +1 -0
  159. package/dist/mesh/_index-kernels-u16.d.ts +43 -0
  160. package/dist/mesh/_index-kernels-u16.d.ts.map +1 -0
  161. package/dist/mesh/_index-kernels-u16.js +264 -0
  162. package/dist/mesh/_index-kernels-u16.js.map +1 -0
  163. package/dist/mesh/_index-kernels-u32.d.ts +43 -0
  164. package/dist/mesh/_index-kernels-u32.d.ts.map +1 -0
  165. package/dist/mesh/_index-kernels-u32.js +264 -0
  166. package/dist/mesh/_index-kernels-u32.js.map +1 -0
  167. package/dist/mesh/generate-box.d.ts +16 -0
  168. package/dist/mesh/generate-box.d.ts.map +1 -0
  169. package/dist/mesh/generate-box.js +79 -0
  170. package/dist/mesh/generate-box.js.map +1 -0
  171. package/dist/mesh/generate-cylinder.d.ts +25 -0
  172. package/dist/mesh/generate-cylinder.d.ts.map +1 -0
  173. package/dist/mesh/generate-cylinder.js +117 -0
  174. package/dist/mesh/generate-cylinder.js.map +1 -0
  175. package/dist/mesh/generate-heightfield.d.ts +24 -0
  176. package/dist/mesh/generate-heightfield.d.ts.map +1 -0
  177. package/dist/mesh/generate-heightfield.js +48 -0
  178. package/dist/mesh/generate-heightfield.js.map +1 -0
  179. package/dist/mesh/generate-plane.d.ts +18 -0
  180. package/dist/mesh/generate-plane.d.ts.map +1 -0
  181. package/dist/mesh/generate-plane.js +39 -0
  182. package/dist/mesh/generate-plane.js.map +1 -0
  183. package/dist/mesh/generate-sphere.d.ts +50 -0
  184. package/dist/mesh/generate-sphere.d.ts.map +1 -0
  185. package/dist/mesh/generate-sphere.js +244 -0
  186. package/dist/mesh/generate-sphere.js.map +1 -0
  187. package/dist/mesh/index.d.ts +8 -0
  188. package/dist/mesh/index.d.ts.map +1 -0
  189. package/dist/mesh/index.js +8 -0
  190. package/dist/mesh/index.js.map +1 -0
  191. package/dist/mesh/mesh3-kernels.d.ts +82 -0
  192. package/dist/mesh/mesh3-kernels.d.ts.map +1 -0
  193. package/dist/mesh/mesh3-kernels.js +180 -0
  194. package/dist/mesh/mesh3-kernels.js.map +1 -0
  195. package/dist/mesh/mesh3.d.ts +66 -0
  196. package/dist/mesh/mesh3.d.ts.map +1 -0
  197. package/dist/mesh/mesh3.js +128 -0
  198. package/dist/mesh/mesh3.js.map +1 -0
  199. package/dist/plane3-record.d.ts +88 -0
  200. package/dist/plane3-record.d.ts.map +1 -0
  201. package/dist/plane3-record.js +123 -0
  202. package/dist/plane3-record.js.map +1 -0
  203. package/dist/plane3.d.ts +42 -28
  204. package/dist/plane3.d.ts.map +1 -1
  205. package/dist/plane3.js +166 -48
  206. package/dist/plane3.js.map +1 -1
  207. package/dist/polygon2.d.ts +82 -29
  208. package/dist/polygon2.d.ts.map +1 -1
  209. package/dist/polygon2.js +236 -93
  210. package/dist/polygon2.js.map +1 -1
  211. package/dist/polygon3.d.ts +40 -21
  212. package/dist/polygon3.d.ts.map +1 -1
  213. package/dist/polygon3.js +215 -91
  214. package/dist/polygon3.js.map +1 -1
  215. package/dist/polyline2.d.ts +37 -0
  216. package/dist/polyline2.d.ts.map +1 -0
  217. package/dist/polyline2.js +146 -0
  218. package/dist/polyline2.js.map +1 -0
  219. package/dist/polyline3.d.ts +35 -0
  220. package/dist/polyline3.d.ts.map +1 -0
  221. package/dist/polyline3.js +159 -0
  222. package/dist/polyline3.js.map +1 -0
  223. package/dist/quadtree.d.ts +238 -0
  224. package/dist/quadtree.d.ts.map +1 -0
  225. package/dist/quadtree.js +1019 -0
  226. package/dist/quadtree.js.map +1 -0
  227. package/dist/ray2-record.d.ts +86 -0
  228. package/dist/ray2-record.d.ts.map +1 -0
  229. package/dist/ray2-record.js +123 -0
  230. package/dist/ray2-record.js.map +1 -0
  231. package/dist/ray2.d.ts +38 -13
  232. package/dist/ray2.d.ts.map +1 -1
  233. package/dist/ray2.js +85 -22
  234. package/dist/ray2.js.map +1 -1
  235. package/dist/ray3-array.d.ts +27 -0
  236. package/dist/ray3-array.d.ts.map +1 -0
  237. package/dist/ray3-array.js +89 -0
  238. package/dist/ray3-array.js.map +1 -0
  239. package/dist/ray3-record.d.ts +90 -0
  240. package/dist/ray3-record.d.ts.map +1 -0
  241. package/dist/ray3-record.js +146 -0
  242. package/dist/ray3-record.js.map +1 -0
  243. package/dist/ray3.d.ts +72 -25
  244. package/dist/ray3.d.ts.map +1 -1
  245. package/dist/ray3.js +233 -64
  246. package/dist/ray3.js.map +1 -1
  247. package/dist/segment2-record.d.ts +80 -0
  248. package/dist/segment2-record.d.ts.map +1 -0
  249. package/dist/segment2-record.js +122 -0
  250. package/dist/segment2-record.js.map +1 -0
  251. package/dist/segment2.d.ts +34 -19
  252. package/dist/segment2.d.ts.map +1 -1
  253. package/dist/segment2.js +88 -42
  254. package/dist/segment2.js.map +1 -1
  255. package/dist/segment3-record.d.ts +90 -0
  256. package/dist/segment3-record.d.ts.map +1 -0
  257. package/dist/segment3-record.js +146 -0
  258. package/dist/segment3-record.js.map +1 -0
  259. package/dist/segment3.d.ts +24 -12
  260. package/dist/segment3.d.ts.map +1 -1
  261. package/dist/segment3.js +67 -30
  262. package/dist/segment3.js.map +1 -1
  263. package/dist/size.d.ts +40 -0
  264. package/dist/size.d.ts.map +1 -0
  265. package/dist/size.js +72 -0
  266. package/dist/size.js.map +1 -0
  267. package/dist/sphere3-array-boundary.d.ts +51 -0
  268. package/dist/sphere3-array-boundary.d.ts.map +1 -0
  269. package/dist/sphere3-array-boundary.js +98 -0
  270. package/dist/sphere3-array-boundary.js.map +1 -0
  271. package/dist/sphere3-record.d.ts +88 -0
  272. package/dist/sphere3-record.d.ts.map +1 -0
  273. package/dist/sphere3-record.js +123 -0
  274. package/dist/sphere3-record.js.map +1 -0
  275. package/dist/sphere3.d.ts +55 -12
  276. package/dist/sphere3.d.ts.map +1 -1
  277. package/dist/sphere3.js +233 -24
  278. package/dist/sphere3.js.map +1 -1
  279. package/dist/spherical/cap.d.ts +56 -0
  280. package/dist/spherical/cap.d.ts.map +1 -0
  281. package/dist/spherical/cap.js +363 -0
  282. package/dist/spherical/cap.js.map +1 -0
  283. package/dist/spherical/great-circle.d.ts +39 -0
  284. package/dist/spherical/great-circle.d.ts.map +1 -0
  285. package/dist/spherical/great-circle.js +158 -0
  286. package/dist/spherical/great-circle.js.map +1 -0
  287. package/dist/spherical/index.d.ts +3 -0
  288. package/dist/spherical/index.d.ts.map +1 -0
  289. package/dist/spherical/index.js +3 -0
  290. package/dist/spherical/index.js.map +1 -0
  291. package/dist/triangle2-record.d.ts +91 -0
  292. package/dist/triangle2-record.d.ts.map +1 -0
  293. package/dist/triangle2-record.js +146 -0
  294. package/dist/triangle2-record.js.map +1 -0
  295. package/dist/triangle2.d.ts +29 -14
  296. package/dist/triangle2.d.ts.map +1 -1
  297. package/dist/triangle2.js +86 -22
  298. package/dist/triangle2.js.map +1 -1
  299. package/dist/triangle3-record.d.ts +97 -0
  300. package/dist/triangle3-record.d.ts.map +1 -0
  301. package/dist/triangle3-record.js +178 -0
  302. package/dist/triangle3-record.js.map +1 -0
  303. package/dist/triangle3.d.ts +41 -17
  304. package/dist/triangle3.d.ts.map +1 -1
  305. package/dist/triangle3.js +267 -38
  306. package/dist/triangle3.js.map +1 -1
  307. package/package.json +15 -8
  308. package/dist/angles.d.ts +0 -31
  309. package/dist/angles.d.ts.map +0 -1
  310. package/dist/angles.js +0 -53
  311. package/dist/angles.js.map +0 -1
  312. package/dist/coordinate-spaces.d.ts +0 -39
  313. package/dist/coordinate-spaces.d.ts.map +0 -1
  314. package/dist/coordinate-spaces.js +0 -52
  315. package/dist/coordinate-spaces.js.map +0 -1
  316. package/dist/coordinates-vec2.d.ts +0 -7
  317. package/dist/coordinates-vec2.d.ts.map +0 -1
  318. package/dist/coordinates-vec2.js +0 -35
  319. package/dist/coordinates-vec2.js.map +0 -1
  320. package/dist/coordinates-vec3.d.ts +0 -11
  321. package/dist/coordinates-vec3.d.ts.map +0 -1
  322. package/dist/coordinates-vec3.js +0 -61
  323. package/dist/coordinates-vec3.js.map +0 -1
  324. package/dist/coordinates.d.ts +0 -54
  325. package/dist/coordinates.d.ts.map +0 -1
  326. package/dist/coordinates.js +0 -2
  327. package/dist/coordinates.js.map +0 -1
  328. package/dist/euler-angles-quaternion.d.ts +0 -7
  329. package/dist/euler-angles-quaternion.d.ts.map +0 -1
  330. package/dist/euler-angles-quaternion.js +0 -100
  331. package/dist/euler-angles-quaternion.js.map +0 -1
  332. package/dist/euler-angles.d.ts +0 -33
  333. package/dist/euler-angles.d.ts.map +0 -1
  334. package/dist/euler-angles.js +0 -35
  335. package/dist/euler-angles.js.map +0 -1
  336. package/dist/geometry-vectors.d.ts +0 -11
  337. package/dist/geometry-vectors.d.ts.map +0 -1
  338. package/dist/geometry-vectors.js +0 -19
  339. package/dist/geometry-vectors.js.map +0 -1
  340. package/dist/mesh3.d.ts +0 -32
  341. package/dist/mesh3.d.ts.map +0 -1
  342. package/dist/mesh3.js +0 -142
  343. package/dist/mesh3.js.map +0 -1
  344. package/dist/point2.d.ts +0 -41
  345. package/dist/point2.d.ts.map +0 -1
  346. package/dist/point2.js +0 -92
  347. package/dist/point2.js.map +0 -1
  348. package/dist/point3.d.ts +0 -43
  349. package/dist/point3.d.ts.map +0 -1
  350. package/dist/point3.js +0 -103
  351. package/dist/point3.js.map +0 -1
  352. package/dist/point4.d.ts +0 -12
  353. package/dist/point4.d.ts.map +0 -1
  354. package/dist/point4.js +0 -28
  355. package/dist/point4.js.map +0 -1
  356. package/dist/rect2.d.ts +0 -54
  357. package/dist/rect2.d.ts.map +0 -1
  358. package/dist/rect2.js +0 -149
  359. package/dist/rect2.js.map +0 -1
  360. package/dist/size2.d.ts +0 -33
  361. package/dist/size2.d.ts.map +0 -1
  362. package/dist/size2.js +0 -81
  363. package/dist/size2.js.map +0 -1
  364. package/dist/size3.d.ts +0 -21
  365. package/dist/size3.d.ts.map +0 -1
  366. package/dist/size3.js +0 -59
  367. package/dist/size3.js.map +0 -1
  368. package/dist/size4.d.ts +0 -10
  369. package/dist/size4.d.ts.map +0 -1
  370. package/dist/size4.js +0 -16
  371. package/dist/size4.js.map +0 -1
@@ -0,0 +1,83 @@
1
+ import type { Brand_ } from "./_brand.js";
2
+ /**
3
+ * An axis-aligned box in 2 dimensions, stored as its minimum corner then its
4
+ * maximum corner (min/max, so a left-top-right-bottom rectangle on a y-down
5
+ * screen). A box with a minimum above its maximum on some axis is empty.
6
+ *
7
+ * A plain array of 4 binary64 numbers carrying a type-level brand, holding
8
+ * exactly the numbers one element of the matching bulk buffer holds, in the
9
+ * same order.
10
+ *
11
+ * Only {@link box2Create}, {@link box2Of}, {@link box2Clone}, {@link box2FromArray}
12
+ * and the functions that write an `out` make one; see `Vec3` in
13
+ * `@ac-kit/math-linear` for the rules that bind callers who bypass the types.
14
+ */
15
+ export type Box2 = [minX: number, minY: number, maxX: number, maxY: number] & Brand_<"Box2">;
16
+ /** A {@link Box2} that is only read. */
17
+ export type ReadonlyBox2 = readonly [
18
+ minX: number,
19
+ minY: number,
20
+ maxX: number,
21
+ maxY: number
22
+ ] & Brand_<"Box2">;
23
+ /**
24
+ * Creates the empty box (`+∞` minima, `−∞` maxima): nothing intersects it, and
25
+ * its union with a box is that box.
26
+ *
27
+ * Allocates; keep it out of hot loops.
28
+ */
29
+ export declare function box2Create(): Box2;
30
+ /**
31
+ * Creates the box with the components `minX, minY, maxX, maxY`, in storage
32
+ * order.
33
+ *
34
+ * Allocates; keep it out of hot loops.
35
+ */
36
+ export declare function box2Of(minX: number, minY: number, maxX: number, maxY: number): Box2;
37
+ /**
38
+ * Creates a copy of `a`. Like every creator it starts from a clean array.
39
+ *
40
+ * Allocates; keep it out of hot loops.
41
+ */
42
+ export declare function box2Clone(a: ReadonlyBox2): Box2;
43
+ /** Writes the components, in storage order, into `out`. */
44
+ export declare function box2Set(out: Box2, minX: number, minY: number, maxX: number, maxY: number): Box2;
45
+ /** Writes a copy of `a` into `out`. `out` may be `a`. */
46
+ export declare function box2Copy(out: Box2, a: ReadonlyBox2): Box2;
47
+ /**
48
+ * Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
49
+ * included, and an infinity equals itself. See {@link box2IsClose} for a
50
+ * tolerant test.
51
+ */
52
+ export declare function box2Equals(a: ReadonlyBox2, b: ReadonlyBox2): boolean;
53
+ /**
54
+ * Component-wise approximate equality: every pair differs by at most
55
+ * `tolerance`, an absolute bound in the caller's units, and an infinity is
56
+ * close only to itself. Not transitive, so never a basis for ordering or a
57
+ * container key: use {@link box2Equals} there.
58
+ *
59
+ * @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
60
+ */
61
+ export declare function box2IsClose(a: ReadonlyBox2, b: ReadonlyBox2, tolerance?: number): boolean;
62
+ /**
63
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
64
+ * origin): `source[offset … offset + 4)` copied into `out`, each element that
65
+ * is not a number written as `NaN`, an index past the end of `source` too, so
66
+ * `out` never holds a non-number. A cold path: buffers use {@link box2Load}.
67
+ * O(1).
68
+ *
69
+ * `source` may be `out` itself: the 4 elements are read before the first write.
70
+ *
71
+ * @param out The box to fill.
72
+ * @param source The array to read, of any length and any content.
73
+ * @param offset The index of the first component in `source`.
74
+ * @returns `out`.
75
+ */
76
+ export declare function box2FromArray(out: Box2, source: ArrayLike<number>, offset?: number): Box2;
77
+ /**
78
+ * Whether every component is a finite number: the check to run after parsing
79
+ * untrusted data or before an upload, as operations never check. A component
80
+ * that is not a number at all counts as not finite.
81
+ */
82
+ export declare function box2IsFinite(value: ReadonlyBox2): boolean;
83
+ //# sourceMappingURL=box2-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box2-record.d.ts","sourceRoot":"","sources":["../src/box2-record.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAC1E,MAAM,CAAC,MAAM,CAAC,CAAC;AAEhB,wCAAwC;AACxC,MAAM,MAAM,YAAY,GAAG,SAAS;IACnC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACZ,GACA,MAAM,CAAC,MAAM,CAAC,CAAC;AAQhB;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAOjC;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACV,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAO/C;AAED,2DAA2D;AAC3D,wBAAgB,OAAO,CACtB,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACV,IAAI,CAMN;AAED,yDAAyD;AACzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,GAAG,IAAI,CAMzD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,OAAO,CAEpE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAC1B,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,YAAY,EACf,SAAS,GAAE,MAA8C,GACvD,OAAO,CAOT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,MAAM,SAAI,GACR,IAAI,CAUN;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAOzD"}
@@ -0,0 +1,124 @@
1
+ // Generated from scripts/templates/record.liquid by scripts/generate-records.ts. Do not edit.
2
+ import { isCloseAbsolute, numberAtOrNaN } from "@ac-kit/core";
3
+ import { geometryConfig } from "./globals.js";
4
+ /**
5
+ * Every creator copies this array, which holds non-integer doubles and is never
6
+ * exposed: nothing a caller does can change the element kind it copies.
7
+ */
8
+ const TEMPLATE_ = [0.5, 0.5, 0.5, 0.5];
9
+ /**
10
+ * Creates the empty box (`+∞` minima, `−∞` maxima): nothing intersects it, and
11
+ * its union with a box is that box.
12
+ *
13
+ * Allocates; keep it out of hot loops.
14
+ */
15
+ export function box2Create() {
16
+ const out = TEMPLATE_.slice();
17
+ out[0] = Number.POSITIVE_INFINITY;
18
+ out[1] = Number.POSITIVE_INFINITY;
19
+ out[2] = Number.NEGATIVE_INFINITY;
20
+ out[3] = Number.NEGATIVE_INFINITY;
21
+ return out;
22
+ }
23
+ /**
24
+ * Creates the box with the components `minX, minY, maxX, maxY`, in storage
25
+ * order.
26
+ *
27
+ * Allocates; keep it out of hot loops.
28
+ */
29
+ export function box2Of(minX, minY, maxX, maxY) {
30
+ const out = TEMPLATE_.slice();
31
+ out[0] = minX;
32
+ out[1] = minY;
33
+ out[2] = maxX;
34
+ out[3] = maxY;
35
+ return out;
36
+ }
37
+ /**
38
+ * Creates a copy of `a`. Like every creator it starts from a clean array.
39
+ *
40
+ * Allocates; keep it out of hot loops.
41
+ */
42
+ export function box2Clone(a) {
43
+ const out = TEMPLATE_.slice();
44
+ out[0] = a[0];
45
+ out[1] = a[1];
46
+ out[2] = a[2];
47
+ out[3] = a[3];
48
+ return out;
49
+ }
50
+ /** Writes the components, in storage order, into `out`. */
51
+ export function box2Set(out, minX, minY, maxX, maxY) {
52
+ out[0] = minX;
53
+ out[1] = minY;
54
+ out[2] = maxX;
55
+ out[3] = maxY;
56
+ return out;
57
+ }
58
+ /** Writes a copy of `a` into `out`. `out` may be `a`. */
59
+ export function box2Copy(out, a) {
60
+ out[0] = a[0];
61
+ out[1] = a[1];
62
+ out[2] = a[2];
63
+ out[3] = a[3];
64
+ return out;
65
+ }
66
+ /**
67
+ * Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
68
+ * included, and an infinity equals itself. See {@link box2IsClose} for a
69
+ * tolerant test.
70
+ */
71
+ export function box2Equals(a, b) {
72
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
73
+ }
74
+ /**
75
+ * Component-wise approximate equality: every pair differs by at most
76
+ * `tolerance`, an absolute bound in the caller's units, and an infinity is
77
+ * close only to itself. Not transitive, so never a basis for ordering or a
78
+ * container key: use {@link box2Equals} there.
79
+ *
80
+ * @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
81
+ */
82
+ export function box2IsClose(a, b, tolerance = geometryConfig.defaultLinearTolerance) {
83
+ return (isCloseAbsolute(a[0], b[0], tolerance) &&
84
+ isCloseAbsolute(a[1], b[1], tolerance) &&
85
+ isCloseAbsolute(a[2], b[2], tolerance) &&
86
+ isCloseAbsolute(a[3], b[3], tolerance));
87
+ }
88
+ /**
89
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
90
+ * origin): `source[offset … offset + 4)` copied into `out`, each element that
91
+ * is not a number written as `NaN`, an index past the end of `source` too, so
92
+ * `out` never holds a non-number. A cold path: buffers use {@link box2Load}.
93
+ * O(1).
94
+ *
95
+ * `source` may be `out` itself: the 4 elements are read before the first write.
96
+ *
97
+ * @param out The box to fill.
98
+ * @param source The array to read, of any length and any content.
99
+ * @param offset The index of the first component in `source`.
100
+ * @returns `out`.
101
+ */
102
+ export function box2FromArray(out, source, offset = 0) {
103
+ const value0 = numberAtOrNaN(source, offset);
104
+ const value1 = numberAtOrNaN(source, offset + 1);
105
+ const value2 = numberAtOrNaN(source, offset + 2);
106
+ const value3 = numberAtOrNaN(source, offset + 3);
107
+ out[0] = value0;
108
+ out[1] = value1;
109
+ out[2] = value2;
110
+ out[3] = value3;
111
+ return out;
112
+ }
113
+ /**
114
+ * Whether every component is a finite number: the check to run after parsing
115
+ * untrusted data or before an upload, as operations never check. A component
116
+ * that is not a number at all counts as not finite.
117
+ */
118
+ export function box2IsFinite(value) {
119
+ return (Number.isFinite(value[0]) &&
120
+ Number.isFinite(value[1]) &&
121
+ Number.isFinite(value[2]) &&
122
+ Number.isFinite(value[3]));
123
+ }
124
+ //# sourceMappingURL=box2-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box2-record.js","sourceRoot":"","sources":["../src/box2-record.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA2B9C;;;GAGG;AACH,MAAM,SAAS,GAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,UAAU;IACzB,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAU,CAAC;IACtC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAClC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAClC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAClC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAClC,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CACrB,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,IAAY;IAEZ,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAU,CAAC;IACtC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACd,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACd,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACd,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACd,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,S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;IAChB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAmB;IAC/C,OAAO,CACN,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;AACH,CAAC"}
package/dist/box2.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import type { ReadonlyAffine2 } from "@ac-kit/math-linear";
2
+ import type { Box2, ReadonlyBox2 } from "./box2-record.js";
3
+ /**
4
+ * Writes the box with its top-left corner at `[x, y]` and the size `width ×
5
+ * height` into `out`: the way in from a `DOMRect`, a Canvas rectangle or any
6
+ * origin-and-size record. A negative size gives an empty box.
7
+ */
8
+ export declare function box2FromXywh(out: Box2, x: number, y: number, width: number, height: number): Box2;
9
+ /**
10
+ * {@link box2ContainsPoint} with the components as arguments, for pointer
11
+ * events: whether `(x, y)` lies in the box, boundary included.
12
+ */
13
+ export declare function box2ContainsXy(box: ReadonlyBox2, x: number, y: number): boolean;
14
+ /** The extent on x, `maxX − minX`; negative for an empty box. */
15
+ export declare function box2Width(box: ReadonlyBox2): number;
16
+ /** The extent on y, `maxY − minY`; negative for an empty box. */
17
+ export declare function box2Height(box: ReadonlyBox2): number;
18
+ /** The area, `0` for an empty box. */
19
+ export declare function box2Area(box: ReadonlyBox2): number;
20
+ /**
21
+ * The width divided by the height: `Infinity` for a flat box of positive width,
22
+ * `NaN` for a point.
23
+ */
24
+ export declare function box2AspectRatio(box: ReadonlyBox2): number;
25
+ /**
26
+ * Writes into `out` the largest box with the aspect ratio of `box` that fits in
27
+ * `container`, centred in it (letterboxing). A box of zero or non-finite aspect
28
+ * ratio gives non-finite bounds. `out` may be `box` or `container`.
29
+ */
30
+ export declare function box2FitInside(out: Box2, box: ReadonlyBox2, container: ReadonlyBox2): Box2;
31
+ /**
32
+ * Writes the bounds of the box moved by `transform` into `out`: exact for the
33
+ * translations, scales and quarter turns, the enclosing box for any other
34
+ * rotation or shear (Arvo's method). An empty box gives an empty box. `out` may
35
+ * be `box`.
36
+ */
37
+ export declare function box2TransformAffine2(out: Box2, box: ReadonlyBox2, transform: ReadonlyAffine2): Box2;
38
+ //# sourceMappingURL=box2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box2.d.ts","sourceRoot":"","sources":["../src/box2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,GAAG,EAAE,IAAI,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACZ,IAAI,CAMN;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,YAAY,EACjB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACP,OAAO,CAET;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAEnD;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAEpD;AAED,sCAAsC;AACtC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAIlD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,YAAY,GACrB,IAAI,CAiBN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,eAAe,GACxB,IAAI,CAyBN"}
package/dist/box2.js ADDED
@@ -0,0 +1,97 @@
1
+ import { box2Empty } from "./box2-componentwise.js";
2
+ /**
3
+ * Writes the box with its top-left corner at `[x, y]` and the size `width ×
4
+ * height` into `out`: the way in from a `DOMRect`, a Canvas rectangle or any
5
+ * origin-and-size record. A negative size gives an empty box.
6
+ */
7
+ export function box2FromXywh(out, x, y, width, height) {
8
+ out[0] = x;
9
+ out[1] = y;
10
+ out[2] = x + width;
11
+ out[3] = y + height;
12
+ return out;
13
+ }
14
+ /**
15
+ * {@link box2ContainsPoint} with the components as arguments, for pointer
16
+ * events: whether `(x, y)` lies in the box, boundary included.
17
+ */
18
+ export function box2ContainsXy(box, x, y) {
19
+ return x >= box[0] && x <= box[2] && y >= box[1] && y <= box[3];
20
+ }
21
+ /** The extent on x, `maxX − minX`; negative for an empty box. */
22
+ export function box2Width(box) {
23
+ return box[2] - box[0];
24
+ }
25
+ /** The extent on y, `maxY − minY`; negative for an empty box. */
26
+ export function box2Height(box) {
27
+ return box[3] - box[1];
28
+ }
29
+ /** The area, `0` for an empty box. */
30
+ export function box2Area(box) {
31
+ const width = box[2] - box[0];
32
+ const height = box[3] - box[1];
33
+ return width < 0 || height < 0 ? 0 : width * height;
34
+ }
35
+ /**
36
+ * The width divided by the height: `Infinity` for a flat box of positive width,
37
+ * `NaN` for a point.
38
+ */
39
+ export function box2AspectRatio(box) {
40
+ return (box[2] - box[0]) / (box[3] - box[1]);
41
+ }
42
+ /**
43
+ * Writes into `out` the largest box with the aspect ratio of `box` that fits in
44
+ * `container`, centred in it (letterboxing). A box of zero or non-finite aspect
45
+ * ratio gives non-finite bounds. `out` may be `box` or `container`.
46
+ */
47
+ export function box2FitInside(out, box, container) {
48
+ const aspect = (box[2] - box[0]) / (box[3] - box[1]);
49
+ const containerWidth = container[2] - container[0];
50
+ const containerHeight = container[3] - container[1];
51
+ const centerX = (container[0] + container[2]) / 2;
52
+ const centerY = (container[1] + container[3]) / 2;
53
+ let width = containerWidth;
54
+ let height = containerWidth / aspect;
55
+ if (height > containerHeight) {
56
+ height = containerHeight;
57
+ width = containerHeight * aspect;
58
+ }
59
+ out[0] = centerX - width / 2;
60
+ out[1] = centerY - height / 2;
61
+ out[2] = centerX + width / 2;
62
+ out[3] = centerY + height / 2;
63
+ return out;
64
+ }
65
+ /**
66
+ * Writes the bounds of the box moved by `transform` into `out`: exact for the
67
+ * translations, scales and quarter turns, the enclosing box for any other
68
+ * rotation or shear (Arvo's method). An empty box gives an empty box. `out` may
69
+ * be `box`.
70
+ */
71
+ export function box2TransformAffine2(out, box, transform) {
72
+ const minX = box[0];
73
+ const minY = box[1];
74
+ const maxX = box[2];
75
+ const maxY = box[3];
76
+ if (minX > maxX || minY > maxY) {
77
+ return box2Empty(out);
78
+ }
79
+ const a = transform[0];
80
+ const b = transform[1];
81
+ const c = transform[2];
82
+ const d = transform[3];
83
+ const aMin = a * minX;
84
+ const aMax = a * maxX;
85
+ const bMin = b * minX;
86
+ const bMax = b * maxX;
87
+ const cMin = c * minY;
88
+ const cMax = c * maxY;
89
+ const dMin = d * minY;
90
+ const dMax = d * maxY;
91
+ out[0] = transform[4] + Math.min(aMin, aMax) + Math.min(cMin, cMax);
92
+ out[1] = transform[5] + Math.min(bMin, bMax) + Math.min(dMin, dMax);
93
+ out[2] = transform[4] + Math.max(aMin, aMax) + Math.max(cMin, cMax);
94
+ out[3] = transform[5] + Math.max(bMin, bMax) + Math.max(dMin, dMax);
95
+ return out;
96
+ }
97
+ //# sourceMappingURL=box2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box2.js","sourceRoot":"","sources":["../src/box2.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD;;;;GAIG;AAC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I,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpE,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpE,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpE,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpE,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { ReadonlyBox3, Box3 } from "./box3-record.js";
2
+ /**
3
+ * Creates a buffer for `count` boxes: a zero-filled `Float64Array` of `count ×
4
+ * 6` numbers, element `i` at `[i·6, i·6 + 6)`. Allocates.
5
+ *
6
+ * @throws {RangeError} When `count` is not a non-negative safe integer or
7
+ * `count × 6` is not a valid typed array length.
8
+ */
9
+ export declare function box3ArrayCreate(count: number): Float64Array<ArrayBuffer>;
10
+ /**
11
+ * Writes element `index` of `array`, the numbers at `[index·6, index·6 + 6)`,
12
+ * into `out`. Each component is written as `+array[i]`, so an index past the
13
+ * end of `array` gives `NaN`, never `undefined`: the box stays clean whatever
14
+ * the caller does. Checking the index is the job of the checked layer.
15
+ *
16
+ * The box is copied: it is never a view of `array`. O(1).
17
+ */
18
+ export declare function box3Load(out: Box3, array: Float64Array, index: number): Box3;
19
+ /**
20
+ * Writes `value` into `array` as element `index`, at `[index·6, index·6 + 6)`.
21
+ * An element past the end of `array` writes nothing, as a typed array drops an
22
+ * out-of-range write. O(1).
23
+ */
24
+ export declare function box3Store(array: Float64Array, index: number, value: ReadonlyBox3): void;
25
+ /**
26
+ * Like {@link box3Load} for interleaved data: element `index` starts at `offset +
27
+ * index·stride`, both counted in numbers, and its 6 components follow one
28
+ * another. An index past the end gives `NaN` components. O(1).
29
+ */
30
+ export declare function box3LoadStrided(out: Box3, array: Float64Array, offset: number, stride: number, index: number): Box3;
31
+ /**
32
+ * Like {@link box3Store} for interleaved data: element `index` starts at `offset +
33
+ * index·stride`, both counted in numbers. A component past the end of `array`
34
+ * writes nothing. O(1).
35
+ */
36
+ export declare function box3StoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyBox3): void;
37
+ /**
38
+ * Narrows `value` to binary32 and writes its 6 components into `array` from
39
+ * element `offset` on, unrolled: the way to stage a bounds or instance value
40
+ * for the GPU, where `array.set` costs several times as much for one value. A
41
+ * component past the end of `array` writes nothing. O(1).
42
+ */
43
+ export declare function box3StoreFloat32(array: Float32Array, offset: number, value: ReadonlyBox3): void;
44
+ /**
45
+ * Whether every number of `array` is finite: the check for a buffer of box3
46
+ * elements read from untrusted data or about to be uploaded. The length is not
47
+ * required to be a multiple of 6. O(n).
48
+ */
49
+ export declare function box3ArrayIsFinite(array: Float64Array): boolean;
50
+ //# sourceMappingURL=box3-array-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box3-array-boundary.d.ts","sourceRoot":"","sources":["../src/box3-array-boundary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAGxE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAU5E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACxB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GACjB,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,IAAI,CAUN;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GACjB,IAAI,CAQN;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GACjB,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAU9D"}
@@ -0,0 +1,107 @@
1
+ // Generated from scripts/templates/array-boundary.liquid by scripts/generate-records.ts. Do not edit.
2
+ import { assertInteger } from "@ac-kit/core";
3
+ /**
4
+ * Creates a buffer for `count` boxes: a zero-filled `Float64Array` of `count ×
5
+ * 6` numbers, element `i` at `[i·6, i·6 + 6)`. Allocates.
6
+ *
7
+ * @throws {RangeError} When `count` is not a non-negative safe integer or
8
+ * `count × 6` is not a valid typed array length.
9
+ */
10
+ export function box3ArrayCreate(count) {
11
+ assertInteger(count, "box3ArrayCreate: count", 0);
12
+ return new Float64Array(count * 6);
13
+ }
14
+ /**
15
+ * Writes element `index` of `array`, the numbers at `[index·6, index·6 + 6)`,
16
+ * into `out`. Each component is written as `+array[i]`, so an index past the
17
+ * end of `array` gives `NaN`, never `undefined`: the box stays clean whatever
18
+ * the caller does. Checking the index is the job of the checked layer.
19
+ *
20
+ * The box is copied: it is never a view of `array`. O(1).
21
+ */
22
+ export function box3Load(out, array, index) {
23
+ const base = index * 6;
24
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
25
+ out[0] = +array[base];
26
+ out[1] = +array[base + 1];
27
+ out[2] = +array[base + 2];
28
+ out[3] = +array[base + 3];
29
+ out[4] = +array[base + 4];
30
+ out[5] = +array[base + 5];
31
+ return out;
32
+ }
33
+ /**
34
+ * Writes `value` into `array` as element `index`, at `[index·6, index·6 + 6)`.
35
+ * An element past the end of `array` writes nothing, as a typed array drops an
36
+ * out-of-range write. O(1).
37
+ */
38
+ export function box3Store(array, index, value) {
39
+ const base = index * 6;
40
+ array[base] = value[0];
41
+ array[base + 1] = value[1];
42
+ array[base + 2] = value[2];
43
+ array[base + 3] = value[3];
44
+ array[base + 4] = value[4];
45
+ array[base + 5] = value[5];
46
+ }
47
+ /**
48
+ * Like {@link box3Load} for interleaved data: element `index` starts at `offset +
49
+ * index·stride`, both counted in numbers, and its 6 components follow one
50
+ * another. An index past the end gives `NaN` components. O(1).
51
+ */
52
+ export function box3LoadStrided(out, array, offset, stride, index) {
53
+ const base = offset + index * stride;
54
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
55
+ out[0] = +array[base];
56
+ out[1] = +array[base + 1];
57
+ out[2] = +array[base + 2];
58
+ out[3] = +array[base + 3];
59
+ out[4] = +array[base + 4];
60
+ out[5] = +array[base + 5];
61
+ return out;
62
+ }
63
+ /**
64
+ * Like {@link box3Store} for interleaved data: element `index` starts at `offset +
65
+ * index·stride`, both counted in numbers. A component past the end of `array`
66
+ * writes nothing. O(1).
67
+ */
68
+ export function box3StoreStrided(array, offset, stride, index, value) {
69
+ const base = offset + index * stride;
70
+ array[base] = value[0];
71
+ array[base + 1] = value[1];
72
+ array[base + 2] = value[2];
73
+ array[base + 3] = value[3];
74
+ array[base + 4] = value[4];
75
+ array[base + 5] = value[5];
76
+ }
77
+ /**
78
+ * Narrows `value` to binary32 and writes its 6 components into `array` from
79
+ * element `offset` on, unrolled: the way to stage a bounds or instance value
80
+ * for the GPU, where `array.set` costs several times as much for one value. A
81
+ * component past the end of `array` writes nothing. O(1).
82
+ */
83
+ export function box3StoreFloat32(array, offset, value) {
84
+ array[offset] = value[0];
85
+ array[offset + 1] = value[1];
86
+ array[offset + 2] = value[2];
87
+ array[offset + 3] = value[3];
88
+ array[offset + 4] = value[4];
89
+ array[offset + 5] = value[5];
90
+ }
91
+ /**
92
+ * Whether every number of `array` is finite: the check for a buffer of box3
93
+ * elements read from untrusted data or about to be uploaded. The length is not
94
+ * required to be a multiple of 6. O(n).
95
+ */
96
+ export function box3ArrayIsFinite(array) {
97
+ // A loop, not `array.every(Number.isFinite)`: measured at 0.5–0.7 ms against
98
+ // 4.1 ms per million numbers on Node (the callback is not inlined), and the
99
+ // check runs on every upload of an untrusted buffer.
100
+ for (let index = 0; index < array.length; index++) {
101
+ if (!Number.isFinite(array[index])) {
102
+ return false;
103
+ }
104
+ }
105
+ return true;
106
+ }
107
+ //# sourceMappingURL=box3-array-boundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box3-array-boundary.js","sourceRoot":"","sources":["../src/box3-array-boundary.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAEtG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,aAAa,CAAC,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAS,EAAE,KAAmB,EAAE,KAAa;IACrE,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,mEAAmE;IACnE,GAAG,CAAC,CAAC,CAAC,GAAG,CA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,UAAU,gBAAgB,CAC/B,KAAmB,EACnB,MAAc,EACd,KAAmB;IAEnB,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACzB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACpD,6EAA6E;IAC7E,4EAA4E;IAC5E,qDAAqD;IACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,110 @@
1
+ import type { ReadonlyVec3, Vec3 } from "@ac-kit/math-linear";
2
+ import type { ReadonlyBox3, Box3 } from "./box3-record.js";
3
+ /**
4
+ * Writes the empty box into `out`: `+∞` minima and `−∞` maxima, so that the
5
+ * union with any box is that box and nothing intersects it.
6
+ */
7
+ export declare function box3Empty(out: Box3): Box3;
8
+ /**
9
+ * Writes the box of the given `center` and `size` (the full extent on each
10
+ * axis) into `out`. A negative size gives an empty box.
11
+ */
12
+ export declare function box3FromCenterSize(out: Box3, center: ReadonlyVec3, size: ReadonlyVec3): Box3;
13
+ /** Writes the box spanned by any two opposite corners into `out`. */
14
+ export declare function box3FromCorners(out: Box3, a: ReadonlyVec3, b: ReadonlyVec3): Box3;
15
+ /**
16
+ * Writes the bounds of the 3-number points of `points` into `out`; an empty
17
+ * buffer gives the empty box. A point with a `NaN` component leaves that axis
18
+ * to the other points. O(n).
19
+ *
20
+ * @throws {RangeError} When `points.length` is not a multiple of 3.
21
+ */
22
+ export declare function box3FromPoints(out: Box3, points: Float64Array): Box3;
23
+ /**
24
+ * Like {@link box3FromPoints} for interleaved data: point `i` starts at `offset +
25
+ * i·stride`, both counted in numbers, for `count` points. O(count).
26
+ *
27
+ * @throws {RangeError} When `count` is not a non-negative integer or the last
28
+ * point does not fit in `points`.
29
+ */
30
+ export declare function box3FromPointsStrided(out: Box3, points: Float64Array, offset: number, stride: number, count: number): Box3;
31
+ /**
32
+ * Whether the box has a minimum above its maximum on some axis. `NaN` is not
33
+ * above anything.
34
+ */
35
+ export declare function box3IsEmpty(box: ReadonlyBox3): boolean;
36
+ /**
37
+ * Writes the extent of the box on each axis, `max − min`, into `out`. An empty
38
+ * box gives negative extents.
39
+ */
40
+ export declare function box3Size(out: Vec3, box: ReadonlyBox3): Vec3;
41
+ /**
42
+ * Writes the centre of the box into `out`. An empty box gives `NaN` where a
43
+ * bound is infinite.
44
+ */
45
+ export declare function box3Center(out: Vec3, box: ReadonlyBox3): Vec3;
46
+ /** Whether `point` lies in the box, boundary included. */
47
+ export declare function box3ContainsPoint(box: ReadonlyBox3, point: ReadonlyVec3): boolean;
48
+ /**
49
+ * Whether `inner` lies in the box, boundary included. An empty `inner` is
50
+ * contained in any box.
51
+ */
52
+ export declare function box3ContainsBox3(box: ReadonlyBox3, inner: ReadonlyBox3): boolean;
53
+ /**
54
+ * Whether the two boxes share a point, boundaries included. An empty box (an
55
+ * inverted axis) intersects nothing.
56
+ */
57
+ export declare function box3IntersectsBox3(a: ReadonlyBox3, b: ReadonlyBox3): boolean;
58
+ /**
59
+ * Writes the common part of two boxes into `out`; disjoint boxes give an empty
60
+ * box ({@link box3IsEmpty}).
61
+ */
62
+ export declare function box3Intersection(out: Box3, a: ReadonlyBox3, b: ReadonlyBox3): Box3;
63
+ /**
64
+ * Writes the smallest box holding both boxes into `out`; an empty box (an
65
+ * inverted axis) adds nothing, and two empty boxes give {@link box3Empty}. `out`
66
+ * may be `a` or `b`.
67
+ */
68
+ export declare function box3Union(out: Box3, a: ReadonlyBox3, b: ReadonlyBox3): Box3;
69
+ /** Writes the smallest box holding `box` and `point` into `out`. */
70
+ export declare function box3ExpandByPoint(out: Box3, box: ReadonlyBox3, point: ReadonlyVec3): Box3;
71
+ /**
72
+ * Writes `box` grown by `margin` on every side into `out`; a negative margin
73
+ * insets and may empty the box.
74
+ */
75
+ export declare function box3ExpandByScalar(out: Box3, box: ReadonlyBox3, margin: number): Box3;
76
+ /** Writes `box` moved by `offset` into `out`. */
77
+ export declare function box3Translate(out: Box3, box: ReadonlyBox3, offset: ReadonlyVec3): Box3;
78
+ /**
79
+ * Writes the point of the box nearest to `point` into `out`; `out` may be
80
+ * `point`. An empty box gives an unspecified point.
81
+ */
82
+ export declare function box3ClampPoint(out: Vec3, box: ReadonlyBox3, point: ReadonlyVec3): Vec3;
83
+ /** The distance from `point` to the box: `0` inside or on it. */
84
+ export declare function box3DistanceToPoint(box: ReadonlyBox3, point: ReadonlyVec3): number;
85
+ /**
86
+ * Writes the bounds interpolated from `a` (`t = 0`) to `b` (`t = 1`, exact)
87
+ * into `out`. Not math-scalar's `lerp`, which is `a + (b − a)·t` and misses `b`
88
+ * by rounding at `t = 1`.
89
+ */
90
+ export declare function box3Lerp(out: Box3, a: ReadonlyBox3, b: ReadonlyBox3, t: number): Box3;
91
+ /**
92
+ * Writes the coordinates of `point` inside the box, `0` at the minimum corner
93
+ * and `1` at the maximum, into `out`: the inverse of {@link box3PointAt}. A flat
94
+ * axis gives non-finite coordinates.
95
+ */
96
+ export declare function box3Parameter(out: Vec3, box: ReadonlyBox3, point: ReadonlyVec3): Vec3;
97
+ /**
98
+ * Writes the point of the box at `parameter` (`0` at the minimum corner, `1` at
99
+ * the maximum) into `out`.
100
+ */
101
+ export declare function box3PointAt(out: Vec3, box: ReadonlyBox3, parameter: ReadonlyVec3): Vec3;
102
+ /**
103
+ * Writes the union of every box of `boxes` (6 numbers each) into `out`; an
104
+ * empty buffer, or one of empty (inverted) boxes only, gives the empty box.
105
+ * O(n).
106
+ *
107
+ * @throws {RangeError} When `boxes.length` is not a multiple of 6.
108
+ */
109
+ export declare function box3ArrayUnion(out: Box3, boxes: Float64Array): Box3;
110
+ //# sourceMappingURL=box3-componentwise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box3-componentwise.d.ts","sourceRoot":"","sources":["../src/box3-componentwise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAQzC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,YAAY,GAChB,IAAI,CAQN;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAC9B,GAAG,EAAE,IAAI,EACT,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,YAAY,GACb,IAAI,CAQN;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA2CpE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK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