@ac-kit/math-geometry 0.2.3 → 0.4.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 (379) hide show
  1. package/CHANGELOG.md +321 -0
  2. package/README.md +363 -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/_polygon3-cross.d.ts +23 -0
  12. package/dist/_polygon3-cross.d.ts.map +1 -0
  13. package/dist/_polygon3-cross.js +418 -0
  14. package/dist/_polygon3-cross.js.map +1 -0
  15. package/dist/_ray3-intersect.d.ts +19 -0
  16. package/dist/_ray3-intersect.d.ts.map +1 -0
  17. package/dist/_ray3-intersect.js +122 -0
  18. package/dist/_ray3-intersect.js.map +1 -0
  19. package/dist/_triangle3-cross.d.ts +66 -0
  20. package/dist/_triangle3-cross.d.ts.map +1 -0
  21. package/dist/_triangle3-cross.js +396 -0
  22. package/dist/_triangle3-cross.js.map +1 -0
  23. package/dist/box2-array-boundary.d.ts +50 -0
  24. package/dist/box2-array-boundary.d.ts.map +1 -0
  25. package/dist/box2-array-boundary.js +97 -0
  26. package/dist/box2-array-boundary.js.map +1 -0
  27. package/dist/box2-array.d.ts +42 -0
  28. package/dist/box2-array.d.ts.map +1 -0
  29. package/dist/box2-array.js +134 -0
  30. package/dist/box2-array.js.map +1 -0
  31. package/dist/box2-componentwise.d.ts +110 -0
  32. package/dist/box2-componentwise.d.ts.map +1 -0
  33. package/dist/box2-componentwise.js +325 -0
  34. package/dist/box2-componentwise.js.map +1 -0
  35. package/dist/box2-grid-index.d.ts +67 -0
  36. package/dist/box2-grid-index.d.ts.map +1 -0
  37. package/dist/box2-grid-index.js +198 -0
  38. package/dist/box2-grid-index.js.map +1 -0
  39. package/dist/box2-record.d.ts +83 -0
  40. package/dist/box2-record.d.ts.map +1 -0
  41. package/dist/box2-record.js +124 -0
  42. package/dist/box2-record.js.map +1 -0
  43. package/dist/box2.d.ts +38 -0
  44. package/dist/box2.d.ts.map +1 -0
  45. package/dist/box2.js +97 -0
  46. package/dist/box2.js.map +1 -0
  47. package/dist/box3-array-boundary.d.ts +50 -0
  48. package/dist/box3-array-boundary.d.ts.map +1 -0
  49. package/dist/box3-array-boundary.js +107 -0
  50. package/dist/box3-array-boundary.js.map +1 -0
  51. package/dist/box3-componentwise.d.ts +110 -0
  52. package/dist/box3-componentwise.d.ts.map +1 -0
  53. package/dist/box3-componentwise.js +392 -0
  54. package/dist/box3-componentwise.js.map +1 -0
  55. package/dist/box3-record.d.ts +92 -0
  56. package/dist/box3-record.d.ts.map +1 -0
  57. package/dist/box3-record.js +147 -0
  58. package/dist/box3-record.js.map +1 -0
  59. package/dist/box3.d.ts +19 -16
  60. package/dist/box3.d.ts.map +1 -1
  61. package/dist/box3.js +73 -76
  62. package/dist/box3.js.map +1 -1
  63. package/dist/box4-array-boundary.d.ts +50 -0
  64. package/dist/box4-array-boundary.d.ts.map +1 -0
  65. package/dist/box4-array-boundary.js +117 -0
  66. package/dist/box4-array-boundary.js.map +1 -0
  67. package/dist/box4-componentwise.d.ts +110 -0
  68. package/dist/box4-componentwise.d.ts.map +1 -0
  69. package/dist/box4-componentwise.js +459 -0
  70. package/dist/box4-componentwise.js.map +1 -0
  71. package/dist/box4-record.d.ts +96 -0
  72. package/dist/box4-record.d.ts.map +1 -0
  73. package/dist/box4-record.js +167 -0
  74. package/dist/box4-record.js.map +1 -0
  75. package/dist/box4.d.ts +13 -8
  76. package/dist/box4.d.ts.map +1 -1
  77. package/dist/box4.js +27 -5
  78. package/dist/box4.js.map +1 -1
  79. package/dist/circle2-array-boundary.d.ts +51 -0
  80. package/dist/circle2-array-boundary.d.ts.map +1 -0
  81. package/dist/circle2-array-boundary.js +93 -0
  82. package/dist/circle2-array-boundary.js.map +1 -0
  83. package/dist/circle2-array.d.ts +17 -0
  84. package/dist/circle2-array.d.ts.map +1 -0
  85. package/dist/circle2-array.js +44 -0
  86. package/dist/circle2-array.js.map +1 -0
  87. package/dist/circle2-record.d.ts +81 -0
  88. package/dist/circle2-record.d.ts.map +1 -0
  89. package/dist/circle2-record.js +114 -0
  90. package/dist/circle2-record.js.map +1 -0
  91. package/dist/circle2.d.ts +27 -82
  92. package/dist/circle2.d.ts.map +1 -1
  93. package/dist/circle2.js +59 -104
  94. package/dist/circle2.js.map +1 -1
  95. package/dist/coordinates/cylindrical-record.d.ts +86 -0
  96. package/dist/coordinates/cylindrical-record.d.ts.map +1 -0
  97. package/dist/coordinates/cylindrical-record.js +114 -0
  98. package/dist/coordinates/cylindrical-record.js.map +1 -0
  99. package/dist/coordinates/horizontal-record.d.ts +86 -0
  100. package/dist/coordinates/horizontal-record.d.ts.map +1 -0
  101. package/dist/coordinates/horizontal-record.js +114 -0
  102. package/dist/coordinates/horizontal-record.js.map +1 -0
  103. package/dist/coordinates/horizontal.d.ts +48 -0
  104. package/dist/coordinates/horizontal.d.ts.map +1 -0
  105. package/dist/coordinates/horizontal.js +100 -0
  106. package/dist/coordinates/horizontal.js.map +1 -0
  107. package/dist/coordinates/index.d.ts +10 -0
  108. package/dist/coordinates/index.d.ts.map +1 -0
  109. package/dist/coordinates/index.js +10 -0
  110. package/dist/coordinates/index.js.map +1 -0
  111. package/dist/coordinates/longitude-latitude-record.d.ts +81 -0
  112. package/dist/coordinates/longitude-latitude-record.d.ts.map +1 -0
  113. package/dist/coordinates/longitude-latitude-record.js +104 -0
  114. package/dist/coordinates/longitude-latitude-record.js.map +1 -0
  115. package/dist/coordinates/longitude-latitude.d.ts +33 -0
  116. package/dist/coordinates/longitude-latitude.d.ts.map +1 -0
  117. package/dist/coordinates/longitude-latitude.js +78 -0
  118. package/dist/coordinates/longitude-latitude.js.map +1 -0
  119. package/dist/coordinates/polar-record.d.ts +77 -0
  120. package/dist/coordinates/polar-record.d.ts.map +1 -0
  121. package/dist/coordinates/polar-record.js +104 -0
  122. package/dist/coordinates/polar-record.js.map +1 -0
  123. package/dist/coordinates/polar.d.ts +28 -0
  124. package/dist/coordinates/polar.d.ts.map +1 -0
  125. package/dist/coordinates/polar.js +68 -0
  126. package/dist/coordinates/polar.js.map +1 -0
  127. package/dist/coordinates/spherical-cylindrical.d.ts +49 -0
  128. package/dist/coordinates/spherical-cylindrical.d.ts.map +1 -0
  129. package/dist/coordinates/spherical-cylindrical.js +110 -0
  130. package/dist/coordinates/spherical-cylindrical.js.map +1 -0
  131. package/dist/coordinates/spherical-record.d.ts +86 -0
  132. package/dist/coordinates/spherical-record.d.ts.map +1 -0
  133. package/dist/coordinates/spherical-record.js +114 -0
  134. package/dist/coordinates/spherical-record.js.map +1 -0
  135. package/dist/frustum3-record.d.ts +132 -0
  136. package/dist/frustum3-record.d.ts.map +1 -0
  137. package/dist/frustum3-record.js +333 -0
  138. package/dist/frustum3-record.js.map +1 -0
  139. package/dist/frustum3.d.ts +60 -0
  140. package/dist/frustum3.d.ts.map +1 -0
  141. package/dist/frustum3.js +186 -0
  142. package/dist/frustum3.js.map +1 -0
  143. package/dist/index.d.ts +36 -16
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +36 -16
  146. package/dist/index.js.map +1 -1
  147. package/dist/line2-record.d.ts +87 -0
  148. package/dist/line2-record.d.ts.map +1 -0
  149. package/dist/line2-record.js +123 -0
  150. package/dist/line2-record.js.map +1 -0
  151. package/dist/line2.d.ts +24 -33
  152. package/dist/line2.d.ts.map +1 -1
  153. package/dist/line2.js +78 -52
  154. package/dist/line2.js.map +1 -1
  155. package/dist/line3-record.d.ts +91 -0
  156. package/dist/line3-record.d.ts.map +1 -0
  157. package/dist/line3-record.js +146 -0
  158. package/dist/line3-record.js.map +1 -0
  159. package/dist/line3.d.ts +11 -24
  160. package/dist/line3.d.ts.map +1 -1
  161. package/dist/line3.js +32 -36
  162. package/dist/line3.js.map +1 -1
  163. package/dist/mesh/_generator-kit.d.ts +14 -0
  164. package/dist/mesh/_generator-kit.d.ts.map +1 -0
  165. package/dist/mesh/_generator-kit.js +39 -0
  166. package/dist/mesh/_generator-kit.js.map +1 -0
  167. package/dist/mesh/_index-kernels-u16.d.ts +85 -0
  168. package/dist/mesh/_index-kernels-u16.d.ts.map +1 -0
  169. package/dist/mesh/_index-kernels-u16.js +1045 -0
  170. package/dist/mesh/_index-kernels-u16.js.map +1 -0
  171. package/dist/mesh/_index-kernels-u32.d.ts +85 -0
  172. package/dist/mesh/_index-kernels-u32.d.ts.map +1 -0
  173. package/dist/mesh/_index-kernels-u32.js +1045 -0
  174. package/dist/mesh/_index-kernels-u32.js.map +1 -0
  175. package/dist/mesh/generate-box.d.ts +16 -0
  176. package/dist/mesh/generate-box.d.ts.map +1 -0
  177. package/dist/mesh/generate-box.js +79 -0
  178. package/dist/mesh/generate-box.js.map +1 -0
  179. package/dist/mesh/generate-cylinder.d.ts +25 -0
  180. package/dist/mesh/generate-cylinder.d.ts.map +1 -0
  181. package/dist/mesh/generate-cylinder.js +117 -0
  182. package/dist/mesh/generate-cylinder.js.map +1 -0
  183. package/dist/mesh/generate-heightfield.d.ts +24 -0
  184. package/dist/mesh/generate-heightfield.d.ts.map +1 -0
  185. package/dist/mesh/generate-heightfield.js +48 -0
  186. package/dist/mesh/generate-heightfield.js.map +1 -0
  187. package/dist/mesh/generate-plane.d.ts +18 -0
  188. package/dist/mesh/generate-plane.d.ts.map +1 -0
  189. package/dist/mesh/generate-plane.js +39 -0
  190. package/dist/mesh/generate-plane.js.map +1 -0
  191. package/dist/mesh/generate-sphere.d.ts +50 -0
  192. package/dist/mesh/generate-sphere.d.ts.map +1 -0
  193. package/dist/mesh/generate-sphere.js +244 -0
  194. package/dist/mesh/generate-sphere.js.map +1 -0
  195. package/dist/mesh/index.d.ts +8 -0
  196. package/dist/mesh/index.d.ts.map +1 -0
  197. package/dist/mesh/index.js +8 -0
  198. package/dist/mesh/index.js.map +1 -0
  199. package/dist/mesh/mesh3-kernels.d.ts +122 -0
  200. package/dist/mesh/mesh3-kernels.d.ts.map +1 -0
  201. package/dist/mesh/mesh3-kernels.js +220 -0
  202. package/dist/mesh/mesh3-kernels.js.map +1 -0
  203. package/dist/mesh/mesh3.d.ts +66 -0
  204. package/dist/mesh/mesh3.d.ts.map +1 -0
  205. package/dist/mesh/mesh3.js +128 -0
  206. package/dist/mesh/mesh3.js.map +1 -0
  207. package/dist/plane3-record.d.ts +88 -0
  208. package/dist/plane3-record.d.ts.map +1 -0
  209. package/dist/plane3-record.js +123 -0
  210. package/dist/plane3-record.js.map +1 -0
  211. package/dist/plane3.d.ts +43 -28
  212. package/dist/plane3.d.ts.map +1 -1
  213. package/dist/plane3.js +149 -48
  214. package/dist/plane3.js.map +1 -1
  215. package/dist/polygon2.d.ts +132 -29
  216. package/dist/polygon2.d.ts.map +1 -1
  217. package/dist/polygon2.js +529 -96
  218. package/dist/polygon2.js.map +1 -1
  219. package/dist/polygon3.d.ts +56 -21
  220. package/dist/polygon3.d.ts.map +1 -1
  221. package/dist/polygon3.js +239 -91
  222. package/dist/polygon3.js.map +1 -1
  223. package/dist/polyline2.d.ts +37 -0
  224. package/dist/polyline2.d.ts.map +1 -0
  225. package/dist/polyline2.js +146 -0
  226. package/dist/polyline2.js.map +1 -0
  227. package/dist/polyline3.d.ts +35 -0
  228. package/dist/polyline3.d.ts.map +1 -0
  229. package/dist/polyline3.js +159 -0
  230. package/dist/polyline3.js.map +1 -0
  231. package/dist/quadtree.d.ts +255 -0
  232. package/dist/quadtree.d.ts.map +1 -0
  233. package/dist/quadtree.js +1096 -0
  234. package/dist/quadtree.js.map +1 -0
  235. package/dist/ray2-record.d.ts +86 -0
  236. package/dist/ray2-record.d.ts.map +1 -0
  237. package/dist/ray2-record.js +123 -0
  238. package/dist/ray2-record.js.map +1 -0
  239. package/dist/ray2.d.ts +38 -13
  240. package/dist/ray2.d.ts.map +1 -1
  241. package/dist/ray2.js +85 -22
  242. package/dist/ray2.js.map +1 -1
  243. package/dist/ray3-array.d.ts +27 -0
  244. package/dist/ray3-array.d.ts.map +1 -0
  245. package/dist/ray3-array.js +89 -0
  246. package/dist/ray3-array.js.map +1 -0
  247. package/dist/ray3-record.d.ts +90 -0
  248. package/dist/ray3-record.d.ts.map +1 -0
  249. package/dist/ray3-record.js +146 -0
  250. package/dist/ray3-record.js.map +1 -0
  251. package/dist/ray3.d.ts +72 -25
  252. package/dist/ray3.d.ts.map +1 -1
  253. package/dist/ray3.js +233 -64
  254. package/dist/ray3.js.map +1 -1
  255. package/dist/segment2-record.d.ts +80 -0
  256. package/dist/segment2-record.d.ts.map +1 -0
  257. package/dist/segment2-record.js +122 -0
  258. package/dist/segment2-record.js.map +1 -0
  259. package/dist/segment2.d.ts +39 -19
  260. package/dist/segment2.d.ts.map +1 -1
  261. package/dist/segment2.js +104 -42
  262. package/dist/segment2.js.map +1 -1
  263. package/dist/segment3-record.d.ts +90 -0
  264. package/dist/segment3-record.d.ts.map +1 -0
  265. package/dist/segment3-record.js +146 -0
  266. package/dist/segment3-record.js.map +1 -0
  267. package/dist/segment3.d.ts +24 -12
  268. package/dist/segment3.d.ts.map +1 -1
  269. package/dist/segment3.js +67 -30
  270. package/dist/segment3.js.map +1 -1
  271. package/dist/size.d.ts +40 -0
  272. package/dist/size.d.ts.map +1 -0
  273. package/dist/size.js +72 -0
  274. package/dist/size.js.map +1 -0
  275. package/dist/sphere3-array-boundary.d.ts +51 -0
  276. package/dist/sphere3-array-boundary.d.ts.map +1 -0
  277. package/dist/sphere3-array-boundary.js +98 -0
  278. package/dist/sphere3-array-boundary.js.map +1 -0
  279. package/dist/sphere3-record.d.ts +88 -0
  280. package/dist/sphere3-record.d.ts.map +1 -0
  281. package/dist/sphere3-record.js +123 -0
  282. package/dist/sphere3-record.js.map +1 -0
  283. package/dist/sphere3.d.ts +55 -12
  284. package/dist/sphere3.d.ts.map +1 -1
  285. package/dist/sphere3.js +233 -24
  286. package/dist/sphere3.js.map +1 -1
  287. package/dist/spherical/cap.d.ts +56 -0
  288. package/dist/spherical/cap.d.ts.map +1 -0
  289. package/dist/spherical/cap.js +363 -0
  290. package/dist/spherical/cap.js.map +1 -0
  291. package/dist/spherical/great-circle.d.ts +39 -0
  292. package/dist/spherical/great-circle.d.ts.map +1 -0
  293. package/dist/spherical/great-circle.js +158 -0
  294. package/dist/spherical/great-circle.js.map +1 -0
  295. package/dist/spherical/index.d.ts +3 -0
  296. package/dist/spherical/index.d.ts.map +1 -0
  297. package/dist/spherical/index.js +3 -0
  298. package/dist/spherical/index.js.map +1 -0
  299. package/dist/triangle2-record.d.ts +91 -0
  300. package/dist/triangle2-record.d.ts.map +1 -0
  301. package/dist/triangle2-record.js +146 -0
  302. package/dist/triangle2-record.js.map +1 -0
  303. package/dist/triangle2.d.ts +29 -14
  304. package/dist/triangle2.d.ts.map +1 -1
  305. package/dist/triangle2.js +86 -22
  306. package/dist/triangle2.js.map +1 -1
  307. package/dist/triangle3-record.d.ts +97 -0
  308. package/dist/triangle3-record.d.ts.map +1 -0
  309. package/dist/triangle3-record.js +178 -0
  310. package/dist/triangle3-record.js.map +1 -0
  311. package/dist/triangle3.d.ts +60 -17
  312. package/dist/triangle3.d.ts.map +1 -1
  313. package/dist/triangle3.js +287 -38
  314. package/dist/triangle3.js.map +1 -1
  315. package/package.json +15 -8
  316. package/dist/angles.d.ts +0 -31
  317. package/dist/angles.d.ts.map +0 -1
  318. package/dist/angles.js +0 -53
  319. package/dist/angles.js.map +0 -1
  320. package/dist/coordinate-spaces.d.ts +0 -39
  321. package/dist/coordinate-spaces.d.ts.map +0 -1
  322. package/dist/coordinate-spaces.js +0 -52
  323. package/dist/coordinate-spaces.js.map +0 -1
  324. package/dist/coordinates-vec2.d.ts +0 -7
  325. package/dist/coordinates-vec2.d.ts.map +0 -1
  326. package/dist/coordinates-vec2.js +0 -35
  327. package/dist/coordinates-vec2.js.map +0 -1
  328. package/dist/coordinates-vec3.d.ts +0 -11
  329. package/dist/coordinates-vec3.d.ts.map +0 -1
  330. package/dist/coordinates-vec3.js +0 -61
  331. package/dist/coordinates-vec3.js.map +0 -1
  332. package/dist/coordinates.d.ts +0 -54
  333. package/dist/coordinates.d.ts.map +0 -1
  334. package/dist/coordinates.js +0 -2
  335. package/dist/coordinates.js.map +0 -1
  336. package/dist/euler-angles-quaternion.d.ts +0 -7
  337. package/dist/euler-angles-quaternion.d.ts.map +0 -1
  338. package/dist/euler-angles-quaternion.js +0 -100
  339. package/dist/euler-angles-quaternion.js.map +0 -1
  340. package/dist/euler-angles.d.ts +0 -33
  341. package/dist/euler-angles.d.ts.map +0 -1
  342. package/dist/euler-angles.js +0 -35
  343. package/dist/euler-angles.js.map +0 -1
  344. package/dist/geometry-vectors.d.ts +0 -11
  345. package/dist/geometry-vectors.d.ts.map +0 -1
  346. package/dist/geometry-vectors.js +0 -19
  347. package/dist/geometry-vectors.js.map +0 -1
  348. package/dist/mesh3.d.ts +0 -32
  349. package/dist/mesh3.d.ts.map +0 -1
  350. package/dist/mesh3.js +0 -142
  351. package/dist/mesh3.js.map +0 -1
  352. package/dist/point2.d.ts +0 -41
  353. package/dist/point2.d.ts.map +0 -1
  354. package/dist/point2.js +0 -92
  355. package/dist/point2.js.map +0 -1
  356. package/dist/point3.d.ts +0 -43
  357. package/dist/point3.d.ts.map +0 -1
  358. package/dist/point3.js +0 -103
  359. package/dist/point3.js.map +0 -1
  360. package/dist/point4.d.ts +0 -12
  361. package/dist/point4.d.ts.map +0 -1
  362. package/dist/point4.js +0 -28
  363. package/dist/point4.js.map +0 -1
  364. package/dist/rect2.d.ts +0 -54
  365. package/dist/rect2.d.ts.map +0 -1
  366. package/dist/rect2.js +0 -149
  367. package/dist/rect2.js.map +0 -1
  368. package/dist/size2.d.ts +0 -33
  369. package/dist/size2.d.ts.map +0 -1
  370. package/dist/size2.js +0 -81
  371. package/dist/size2.js.map +0 -1
  372. package/dist/size3.d.ts +0 -21
  373. package/dist/size3.d.ts.map +0 -1
  374. package/dist/size3.js +0 -59
  375. package/dist/size3.js.map +0 -1
  376. package/dist/size4.d.ts +0 -10
  377. package/dist/size4.d.ts.map +0 -1
  378. package/dist/size4.js +0 -16
  379. package/dist/size4.js.map +0 -1
@@ -0,0 +1,110 @@
1
+ import { vec3Length } from "@ac-kit/math-linear";
2
+ import { angleNormalizeRad } from "@ac-kit/math-scalar";
3
+ /**
4
+ * Spherical and cylindrical coordinates name their up axis in the function:
5
+ * `…YUp` (azimuth in the XZ plane, graphics) and `…ZUp` (azimuth in the XY
6
+ * plane, ISO 80000-2). Angles in radians; azimuths in `(−π, π]`. Components are
7
+ * read with `+ 0`, which turns −0 into +0: `atan2` would read a signed zero as
8
+ * `π`, and the zero vector and the axis must give the zeros they document
9
+ * whatever the signs of their zeros.
10
+ */
11
+ /**
12
+ * Writes the spherical coordinates of `a` with Y up into `out`: the length, the
13
+ * azimuth `atan2(z, x)` and the inclination from +Y, in `[0, π]`. The
14
+ * inclination is an `atan2`, so the zero vector gives `[0, 0, 0]` and the axis
15
+ * itself azimuth `0`.
16
+ */
17
+ export function sphericalFromVec3YUp(out, a) {
18
+ const x = a[0] + 0;
19
+ const y = a[1] + 0;
20
+ const z = a[2] + 0;
21
+ out[0] = vec3Length(a);
22
+ out[1] = angleNormalizeRad(Math.atan2(z, x));
23
+ out[2] = Math.atan2(Math.sqrt(x * x + z * z), y);
24
+ return out;
25
+ }
26
+ /** Writes the point of the spherical coordinates `coords` with Y up into `out`. */
27
+ export function vec3FromSphericalYUp(out, coords) {
28
+ const radius = coords[0];
29
+ const azimuth = coords[1];
30
+ const inclination = coords[2];
31
+ const planar = radius * Math.sin(inclination);
32
+ out[0] = planar * Math.cos(azimuth);
33
+ out[1] = radius * Math.cos(inclination);
34
+ out[2] = planar * Math.sin(azimuth);
35
+ return out;
36
+ }
37
+ /**
38
+ * Writes the spherical coordinates of `a` with Z up (ISO 80000-2) into `out`:
39
+ * the length, the azimuth `atan2(y, x)` from +X toward +Y and the inclination
40
+ * from +Z, in `[0, π]`. The zero vector gives `[0, 0, 0]`.
41
+ */
42
+ export function sphericalFromVec3ZUp(out, a) {
43
+ const x = a[0] + 0;
44
+ const y = a[1] + 0;
45
+ const z = a[2] + 0;
46
+ out[0] = vec3Length(a);
47
+ out[1] = angleNormalizeRad(Math.atan2(y, x));
48
+ out[2] = Math.atan2(Math.sqrt(x * x + y * y), z);
49
+ return out;
50
+ }
51
+ /** Writes the point of the spherical coordinates `coords` with Z up into `out`. */
52
+ export function vec3FromSphericalZUp(out, coords) {
53
+ const radius = coords[0];
54
+ const azimuth = coords[1];
55
+ const inclination = coords[2];
56
+ const planar = radius * Math.sin(inclination);
57
+ out[0] = planar * Math.cos(azimuth);
58
+ out[1] = planar * Math.sin(azimuth);
59
+ out[2] = radius * Math.cos(inclination);
60
+ return out;
61
+ }
62
+ /**
63
+ * Writes the cylindrical coordinates of `a` with Y up into `out`: the distance
64
+ * from the Y axis, the azimuth `atan2(z, x)` and the height `y`.
65
+ */
66
+ export function cylindricalFromVec3YUp(out, a) {
67
+ const x = a[0] + 0;
68
+ const z = a[2] + 0;
69
+ out[0] = Math.sqrt(x * x + z * z);
70
+ out[1] = angleNormalizeRad(Math.atan2(z, x));
71
+ out[2] = a[1];
72
+ return out;
73
+ }
74
+ /**
75
+ * Writes the point of the cylindrical coordinates `coords` with Y up into
76
+ * `out`.
77
+ */
78
+ export function vec3FromCylindricalYUp(out, coords) {
79
+ const radius = coords[0];
80
+ const azimuth = coords[1];
81
+ out[0] = radius * Math.cos(azimuth);
82
+ out[1] = coords[2];
83
+ out[2] = radius * Math.sin(azimuth);
84
+ return out;
85
+ }
86
+ /**
87
+ * Writes the cylindrical coordinates of `a` with Z up into `out`: the distance
88
+ * from the Z axis, the azimuth `atan2(y, x)` and the height `z`.
89
+ */
90
+ export function cylindricalFromVec3ZUp(out, a) {
91
+ const x = a[0] + 0;
92
+ const y = a[1] + 0;
93
+ out[0] = Math.sqrt(x * x + y * y);
94
+ out[1] = angleNormalizeRad(Math.atan2(y, x));
95
+ out[2] = a[2];
96
+ return out;
97
+ }
98
+ /**
99
+ * Writes the point of the cylindrical coordinates `coords` with Z up into
100
+ * `out`.
101
+ */
102
+ export function vec3FromCylindricalZUp(out, coords) {
103
+ const radius = coords[0];
104
+ const azimuth = coords[1];
105
+ out[0] = radius * Math.cos(azimuth);
106
+ out[1] = radius * Math.sin(azimuth);
107
+ out[2] = coords[2];
108
+ return out;
109
+ }
110
+ //# sourceMappingURL=spherical-cylindrical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spherical-cylindrical.js","sourceRoot":"","sources":["../../src/coordinates/spherical-cylindrical.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAWxD;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CACnC,GAAoB,EACpB,CAAe;IAEf,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnB,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,GAAG,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7C,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,mFAAmF;AAC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AAC,CAAC;IACpC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,86 @@
1
+ import type { Brand_ } from "../_brand.js";
2
+ /**
3
+ * Spherical coordinates: the radius, the azimuth in the equatorial plane and
4
+ * the inclination from the up axis, in radians. Which axis is up is in the name
5
+ * of the function that converts (`…YUp`, `…ZUp`), not in the type.
6
+ *
7
+ * A plain array of 3 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 sphericalCoordsCreate}, {@link sphericalCoordsOf},
12
+ * {@link sphericalCoordsClone}, {@link sphericalCoordsFromArray} and the
13
+ * functions that write an `out` make one; see `Vec3` in `@ac-kit/math-linear`
14
+ * for the rules that bind callers who bypass the types.
15
+ */
16
+ export type SphericalCoords = [
17
+ radius: number,
18
+ azimuth: number,
19
+ inclination: number
20
+ ] & Brand_<"SphericalCoords">;
21
+ /** A {@link SphericalCoords} that is only read. */
22
+ export type ReadonlySphericalCoords = readonly [
23
+ radius: number,
24
+ azimuth: number,
25
+ inclination: number
26
+ ] & Brand_<"SphericalCoords">;
27
+ /**
28
+ * Creates the spherical coordinates `[0, 0, 0]`, the origin.
29
+ *
30
+ * Allocates; keep it out of hot loops.
31
+ */
32
+ export declare function sphericalCoordsCreate(): SphericalCoords;
33
+ /**
34
+ * Creates the spherical coordinates with the components `radius, azimuth,
35
+ * inclination`, in storage order.
36
+ *
37
+ * Allocates; keep it out of hot loops.
38
+ */
39
+ export declare function sphericalCoordsOf(radius: number, azimuth: number, inclination: number): SphericalCoords;
40
+ /**
41
+ * Creates a copy of `a`. Like every creator it starts from a clean array.
42
+ *
43
+ * Allocates; keep it out of hot loops.
44
+ */
45
+ export declare function sphericalCoordsClone(a: ReadonlySphericalCoords): SphericalCoords;
46
+ /** Writes the components, in storage order, into `out`. */
47
+ export declare function sphericalCoordsSet(out: SphericalCoords, radius: number, azimuth: number, inclination: number): SphericalCoords;
48
+ /** Writes a copy of `a` into `out`. `out` may be `a`. */
49
+ export declare function sphericalCoordsCopy(out: SphericalCoords, a: ReadonlySphericalCoords): SphericalCoords;
50
+ /**
51
+ * Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
52
+ * included, and an infinity equals itself. See {@link sphericalCoordsIsClose}
53
+ * for a tolerant test.
54
+ */
55
+ export declare function sphericalCoordsEquals(a: ReadonlySphericalCoords, b: ReadonlySphericalCoords): boolean;
56
+ /**
57
+ * Component-wise approximate equality: every pair differs by at most
58
+ * `tolerance`, an absolute bound in the caller's units, and an infinity is
59
+ * close only to itself. Not transitive, so never a basis for ordering or a
60
+ * container key: use {@link sphericalCoordsEquals} there.
61
+ *
62
+ * @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
63
+ */
64
+ export declare function sphericalCoordsIsClose(a: ReadonlySphericalCoords, b: ReadonlySphericalCoords, tolerance?: number): boolean;
65
+ /**
66
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
67
+ * origin): `source[offset … offset + 3)` copied into `out`, each element that
68
+ * is not a number written as `NaN`, an index past the end of `source` too, so
69
+ * `out` never holds a non-number. A cold path: buffers use
70
+ * {@link sphericalCoordsLoad}. O(1).
71
+ *
72
+ * `source` may be `out` itself: the 3 elements are read before the first write.
73
+ *
74
+ * @param out The spherical coordinates to fill.
75
+ * @param source The array to read, of any length and any content.
76
+ * @param offset The index of the first component in `source`.
77
+ * @returns `out`.
78
+ */
79
+ export declare function sphericalCoordsFromArray(out: SphericalCoords, source: ArrayLike<number>, offset?: number): SphericalCoords;
80
+ /**
81
+ * Whether every component is a finite number: the check to run after parsing
82
+ * untrusted data or before an upload, as operations never check. A component
83
+ * that is not a number at all counts as not finite.
84
+ */
85
+ export declare function sphericalCoordsIsFinite(value: ReadonlySphericalCoords): boolean;
86
+ //# sourceMappingURL=spherical-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spherical-record.d.ts","sourceRoot":"","sources":["../../src/coordinates/spherical-record.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,MAAM;CACnB,GACA,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAE3B,mDAAmD;AACnD,MAAM,MAAM,uBAAuB,GAAG,SAAS;IAC9C,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,MAAM;CACnB,GACA,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAQ3B;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAMvD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GACjB,eAAe,CAMjB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,CAAC,EAAE,uBAAuB,GACxB,eAAe,CAMjB;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GACjB,eAAe,CAKjB;AAED,yDAAyD;AACzD,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,eAAe,EACpB,CAAC,EAAE,uBAAuB,GACxB,eAAe,CAKjB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,CAAC,EAAE,uBAAuB,EAC1B,CAAC,EAAE,uBAAuB,GACxB,OAAO,CAET;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACrC,CAAC,EAAE,uBAAuB,EAC1B,CAAC,EAAE,uBAAuB,EAC1B,SAAS,GAAE,MAA8C,GACvD,OAAO,CAMT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,MAAM,SAAI,GACR,eAAe,CAQjB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,uBAAuB,GAC5B,OAAO,CAMT"}
@@ -0,0 +1,114 @@
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];
9
+ /**
10
+ * Creates the spherical coordinates `[0, 0, 0]`, the origin.
11
+ *
12
+ * Allocates; keep it out of hot loops.
13
+ */
14
+ export function sphericalCoordsCreate() {
15
+ const out = TEMPLATE_.slice();
16
+ out[0] = 0;
17
+ out[1] = 0;
18
+ out[2] = 0;
19
+ return out;
20
+ }
21
+ /**
22
+ * Creates the spherical coordinates with the components `radius, azimuth,
23
+ * inclination`, in storage order.
24
+ *
25
+ * Allocates; keep it out of hot loops.
26
+ */
27
+ export function sphericalCoordsOf(radius, azimuth, inclination) {
28
+ const out = TEMPLATE_.slice();
29
+ out[0] = radius;
30
+ out[1] = azimuth;
31
+ out[2] = inclination;
32
+ return out;
33
+ }
34
+ /**
35
+ * Creates a copy of `a`. Like every creator it starts from a clean array.
36
+ *
37
+ * Allocates; keep it out of hot loops.
38
+ */
39
+ export function sphericalCoordsClone(a) {
40
+ const out = TEMPLATE_.slice();
41
+ out[0] = a[0];
42
+ out[1] = a[1];
43
+ out[2] = a[2];
44
+ return out;
45
+ }
46
+ /** Writes the components, in storage order, into `out`. */
47
+ export function sphericalCoordsSet(out, radius, azimuth, inclination) {
48
+ out[0] = radius;
49
+ out[1] = azimuth;
50
+ out[2] = inclination;
51
+ return out;
52
+ }
53
+ /** Writes a copy of `a` into `out`. `out` may be `a`. */
54
+ export function sphericalCoordsCopy(out, a) {
55
+ out[0] = a[0];
56
+ out[1] = a[1];
57
+ out[2] = a[2];
58
+ return out;
59
+ }
60
+ /**
61
+ * Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
62
+ * included, and an infinity equals itself. See {@link sphericalCoordsIsClose}
63
+ * for a tolerant test.
64
+ */
65
+ export function sphericalCoordsEquals(a, b) {
66
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
67
+ }
68
+ /**
69
+ * Component-wise approximate equality: every pair differs by at most
70
+ * `tolerance`, an absolute bound in the caller's units, and an infinity is
71
+ * close only to itself. Not transitive, so never a basis for ordering or a
72
+ * container key: use {@link sphericalCoordsEquals} there.
73
+ *
74
+ * @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
75
+ */
76
+ export function sphericalCoordsIsClose(a, b, tolerance = geometryConfig.defaultLinearTolerance) {
77
+ return (isCloseAbsolute(a[0], b[0], tolerance) &&
78
+ isCloseAbsolute(a[1], b[1], tolerance) &&
79
+ isCloseAbsolute(a[2], b[2], tolerance));
80
+ }
81
+ /**
82
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
83
+ * origin): `source[offset … offset + 3)` copied into `out`, each element that
84
+ * is not a number written as `NaN`, an index past the end of `source` too, so
85
+ * `out` never holds a non-number. A cold path: buffers use
86
+ * {@link sphericalCoordsLoad}. O(1).
87
+ *
88
+ * `source` may be `out` itself: the 3 elements are read before the first write.
89
+ *
90
+ * @param out The spherical coordinates to fill.
91
+ * @param source The array to read, of any length and any content.
92
+ * @param offset The index of the first component in `source`.
93
+ * @returns `out`.
94
+ */
95
+ export function sphericalCoordsFromArray(out, source, offset = 0) {
96
+ const value0 = numberAtOrNaN(source, offset);
97
+ const value1 = numberAtOrNaN(source, offset + 1);
98
+ const value2 = numberAtOrNaN(source, offset + 2);
99
+ out[0] = value0;
100
+ out[1] = value1;
101
+ out[2] = value2;
102
+ return out;
103
+ }
104
+ /**
105
+ * Whether every component is a finite number: the check to run after parsing
106
+ * untrusted data or before an upload, as operations never check. A component
107
+ * that is not a number at all counts as not finite.
108
+ */
109
+ export function sphericalCoordsIsFinite(value) {
110
+ return (Number.isFinite(value[0]) &&
111
+ Number.isFinite(value[1]) &&
112
+ Number.isFinite(value[2]));
113
+ }
114
+ //# sourceMappingURL=spherical-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spherical-record.js","sourceRoot":"","sources":["../../src/coordinates/spherical-record.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA+B/C;;;GAGG;AACH,MAAM,SAAS,GAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACpC,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAqB,CAAC;IACjD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAChC,MAAc,EACd,OAAe,EACf,WAAmB;IAEnB,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAqB,CAAC;IACjD,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IACjB,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;IACrB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,CAA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AC,sBAAsB;IAEzD,OAAO,CACN,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;QACtC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;QACtC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CACtC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB,CACvC,GAAoB,EACpB,MAAyB,EACzB,MAAM,GAAG,CAAC;IAEV,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACjD,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACtC,KAA8B;IAE9B,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,CACzB,CAAC;AACH,CAAC"}
@@ -0,0 +1,132 @@
1
+ import type { Brand_ } from "./_brand.js";
2
+ /**
3
+ * Six inward-facing planes, in the order left, right, bottom, top, near, far,
4
+ * each as four numbers (`normalX, normalY, normalZ, d` of a `Plane3`): a point
5
+ * is inside when it is on the positive side of all six.
6
+ *
7
+ * A plain array of 24 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 frustum3Create}, {@link frustum3Of}, {@link frustum3Clone},
12
+ * {@link frustum3FromArray} and the functions that write an `out` make one; see
13
+ * `Vec3` in `@ac-kit/math-linear` for the rules that bind callers who bypass
14
+ * the types.
15
+ */
16
+ export type Frustum3 = [
17
+ leftNormalX: number,
18
+ leftNormalY: number,
19
+ leftNormalZ: number,
20
+ leftD: number,
21
+ rightNormalX: number,
22
+ rightNormalY: number,
23
+ rightNormalZ: number,
24
+ rightD: number,
25
+ bottomNormalX: number,
26
+ bottomNormalY: number,
27
+ bottomNormalZ: number,
28
+ bottomD: number,
29
+ topNormalX: number,
30
+ topNormalY: number,
31
+ topNormalZ: number,
32
+ topD: number,
33
+ nearNormalX: number,
34
+ nearNormalY: number,
35
+ nearNormalZ: number,
36
+ nearD: number,
37
+ farNormalX: number,
38
+ farNormalY: number,
39
+ farNormalZ: number,
40
+ farD: number
41
+ ] & Brand_<"Frustum3">;
42
+ /** A {@link Frustum3} that is only read. */
43
+ export type ReadonlyFrustum3 = readonly [
44
+ leftNormalX: number,
45
+ leftNormalY: number,
46
+ leftNormalZ: number,
47
+ leftD: number,
48
+ rightNormalX: number,
49
+ rightNormalY: number,
50
+ rightNormalZ: number,
51
+ rightD: number,
52
+ bottomNormalX: number,
53
+ bottomNormalY: number,
54
+ bottomNormalZ: number,
55
+ bottomD: number,
56
+ topNormalX: number,
57
+ topNormalY: number,
58
+ topNormalZ: number,
59
+ topD: number,
60
+ nearNormalX: number,
61
+ nearNormalY: number,
62
+ nearNormalZ: number,
63
+ nearD: number,
64
+ farNormalX: number,
65
+ farNormalY: number,
66
+ farNormalZ: number,
67
+ farD: number
68
+ ] & Brand_<"Frustum3">;
69
+ /**
70
+ * Creates the all-zero frustum (six zero planes).
71
+ *
72
+ * Allocates; keep it out of hot loops.
73
+ */
74
+ export declare function frustum3Create(): Frustum3;
75
+ /**
76
+ * Creates the frustum with the components `leftNormalX, leftNormalY,
77
+ * leftNormalZ, leftD, rightNormalX, rightNormalY, rightNormalZ, rightD,
78
+ * bottomNormalX, bottomNormalY, bottomNormalZ, bottomD, topNormalX, topNormalY,
79
+ * topNormalZ, topD, nearNormalX, nearNormalY, nearNormalZ, nearD, farNormalX,
80
+ * farNormalY, farNormalZ, farD`, in storage order.
81
+ *
82
+ * Allocates; keep it out of hot loops.
83
+ */
84
+ export declare function frustum3Of(leftNormalX: number, leftNormalY: number, leftNormalZ: number, leftD: number, rightNormalX: number, rightNormalY: number, rightNormalZ: number, rightD: number, bottomNormalX: number, bottomNormalY: number, bottomNormalZ: number, bottomD: number, topNormalX: number, topNormalY: number, topNormalZ: number, topD: number, nearNormalX: number, nearNormalY: number, nearNormalZ: number, nearD: number, farNormalX: number, farNormalY: number, farNormalZ: number, farD: number): Frustum3;
85
+ /**
86
+ * Creates a copy of `a`. Like every creator it starts from a clean array.
87
+ *
88
+ * Allocates; keep it out of hot loops.
89
+ */
90
+ export declare function frustum3Clone(a: ReadonlyFrustum3): Frustum3;
91
+ /** Writes the components, in storage order, into `out`. */
92
+ export declare function frustum3Set(out: Frustum3, leftNormalX: number, leftNormalY: number, leftNormalZ: number, leftD: number, rightNormalX: number, rightNormalY: number, rightNormalZ: number, rightD: number, bottomNormalX: number, bottomNormalY: number, bottomNormalZ: number, bottomD: number, topNormalX: number, topNormalY: number, topNormalZ: number, topD: number, nearNormalX: number, nearNormalY: number, nearNormalZ: number, nearD: number, farNormalX: number, farNormalY: number, farNormalZ: number, farD: number): Frustum3;
93
+ /** Writes a copy of `a` into `out`. `out` may be `a`. */
94
+ export declare function frustum3Copy(out: Frustum3, a: ReadonlyFrustum3): Frustum3;
95
+ /**
96
+ * Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
97
+ * included, and an infinity equals itself. See {@link frustum3IsClose} for a
98
+ * tolerant test.
99
+ */
100
+ export declare function frustum3Equals(a: ReadonlyFrustum3, b: ReadonlyFrustum3): boolean;
101
+ /**
102
+ * Component-wise approximate equality: every pair differs by at most
103
+ * `tolerance`, an absolute bound in the caller's units, and an infinity is
104
+ * close only to itself. Not transitive, so never a basis for ordering or a
105
+ * container key: use {@link frustum3Equals} there.
106
+ *
107
+ * @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
108
+ */
109
+ export declare function frustum3IsClose(a: ReadonlyFrustum3, b: ReadonlyFrustum3, tolerance?: number): boolean;
110
+ /**
111
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
112
+ * origin): `source[offset … offset + 24)` copied into `out`, each element that
113
+ * is not a number written as `NaN`, an index past the end of `source` too, so
114
+ * `out` never holds a non-number. A cold path: buffers use {@link frustum3Load}.
115
+ * O(1).
116
+ *
117
+ * `source` may be `out` itself: the 24 elements are read before the first
118
+ * write.
119
+ *
120
+ * @param out The frustum to fill.
121
+ * @param source The array to read, of any length and any content.
122
+ * @param offset The index of the first component in `source`.
123
+ * @returns `out`.
124
+ */
125
+ export declare function frustum3FromArray(out: Frustum3, source: ArrayLike<number>, offset?: number): Frustum3;
126
+ /**
127
+ * Whether every component is a finite number: the check to run after parsing
128
+ * untrusted data or before an upload, as operations never check. A component
129
+ * that is not a number at all counts as not finite.
130
+ */
131
+ export declare function frustum3IsFinite(value: ReadonlyFrustum3): boolean;
132
+ //# sourceMappingURL=frustum3-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frustum3-record.d.ts","sourceRoot":"","sources":["../src/frustum3-record.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,MAAM;IACnB,KAAK,EAAE,MAAM;IACb,YAAY,EA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