@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.
- package/CHANGELOG.md +228 -0
- package/README.md +323 -52
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_ear-clipping.d.ts +20 -0
- package/dist/_ear-clipping.d.ts.map +1 -0
- package/dist/_ear-clipping.js +360 -0
- package/dist/_ear-clipping.js.map +1 -0
- package/dist/_ray3-intersect.d.ts +19 -0
- package/dist/_ray3-intersect.d.ts.map +1 -0
- package/dist/_ray3-intersect.js +122 -0
- package/dist/_ray3-intersect.js.map +1 -0
- package/dist/box2-array-boundary.d.ts +50 -0
- package/dist/box2-array-boundary.d.ts.map +1 -0
- package/dist/box2-array-boundary.js +97 -0
- package/dist/box2-array-boundary.js.map +1 -0
- package/dist/box2-array.d.ts +42 -0
- package/dist/box2-array.d.ts.map +1 -0
- package/dist/box2-array.js +134 -0
- package/dist/box2-array.js.map +1 -0
- package/dist/box2-componentwise.d.ts +110 -0
- package/dist/box2-componentwise.d.ts.map +1 -0
- package/dist/box2-componentwise.js +325 -0
- package/dist/box2-componentwise.js.map +1 -0
- package/dist/box2-grid-index.d.ts +67 -0
- package/dist/box2-grid-index.d.ts.map +1 -0
- package/dist/box2-grid-index.js +198 -0
- package/dist/box2-grid-index.js.map +1 -0
- package/dist/box2-record.d.ts +83 -0
- package/dist/box2-record.d.ts.map +1 -0
- package/dist/box2-record.js +124 -0
- package/dist/box2-record.js.map +1 -0
- package/dist/box2.d.ts +38 -0
- package/dist/box2.d.ts.map +1 -0
- package/dist/box2.js +97 -0
- package/dist/box2.js.map +1 -0
- package/dist/box3-array-boundary.d.ts +50 -0
- package/dist/box3-array-boundary.d.ts.map +1 -0
- package/dist/box3-array-boundary.js +107 -0
- package/dist/box3-array-boundary.js.map +1 -0
- package/dist/box3-componentwise.d.ts +110 -0
- package/dist/box3-componentwise.d.ts.map +1 -0
- package/dist/box3-componentwise.js +392 -0
- package/dist/box3-componentwise.js.map +1 -0
- package/dist/box3-record.d.ts +92 -0
- package/dist/box3-record.d.ts.map +1 -0
- package/dist/box3-record.js +147 -0
- package/dist/box3-record.js.map +1 -0
- package/dist/box3.d.ts +19 -16
- package/dist/box3.d.ts.map +1 -1
- package/dist/box3.js +73 -76
- package/dist/box3.js.map +1 -1
- package/dist/box4-array-boundary.d.ts +50 -0
- package/dist/box4-array-boundary.d.ts.map +1 -0
- package/dist/box4-array-boundary.js +117 -0
- package/dist/box4-array-boundary.js.map +1 -0
- package/dist/box4-componentwise.d.ts +110 -0
- package/dist/box4-componentwise.d.ts.map +1 -0
- package/dist/box4-componentwise.js +459 -0
- package/dist/box4-componentwise.js.map +1 -0
- package/dist/box4-record.d.ts +96 -0
- package/dist/box4-record.d.ts.map +1 -0
- package/dist/box4-record.js +167 -0
- package/dist/box4-record.js.map +1 -0
- package/dist/box4.d.ts +13 -8
- package/dist/box4.d.ts.map +1 -1
- package/dist/box4.js +27 -5
- package/dist/box4.js.map +1 -1
- package/dist/circle2-array-boundary.d.ts +51 -0
- package/dist/circle2-array-boundary.d.ts.map +1 -0
- package/dist/circle2-array-boundary.js +93 -0
- package/dist/circle2-array-boundary.js.map +1 -0
- package/dist/circle2-array.d.ts +17 -0
- package/dist/circle2-array.d.ts.map +1 -0
- package/dist/circle2-array.js +44 -0
- package/dist/circle2-array.js.map +1 -0
- package/dist/circle2-record.d.ts +81 -0
- package/dist/circle2-record.d.ts.map +1 -0
- package/dist/circle2-record.js +114 -0
- package/dist/circle2-record.js.map +1 -0
- package/dist/circle2.d.ts +27 -82
- package/dist/circle2.d.ts.map +1 -1
- package/dist/circle2.js +59 -104
- package/dist/circle2.js.map +1 -1
- package/dist/coordinates/cylindrical-record.d.ts +86 -0
- package/dist/coordinates/cylindrical-record.d.ts.map +1 -0
- package/dist/coordinates/cylindrical-record.js +114 -0
- package/dist/coordinates/cylindrical-record.js.map +1 -0
- package/dist/coordinates/horizontal-record.d.ts +86 -0
- package/dist/coordinates/horizontal-record.d.ts.map +1 -0
- package/dist/coordinates/horizontal-record.js +114 -0
- package/dist/coordinates/horizontal-record.js.map +1 -0
- package/dist/coordinates/horizontal.d.ts +48 -0
- package/dist/coordinates/horizontal.d.ts.map +1 -0
- package/dist/coordinates/horizontal.js +100 -0
- package/dist/coordinates/horizontal.js.map +1 -0
- package/dist/coordinates/index.d.ts +10 -0
- package/dist/coordinates/index.d.ts.map +1 -0
- package/dist/coordinates/index.js +10 -0
- package/dist/coordinates/index.js.map +1 -0
- package/dist/coordinates/longitude-latitude-record.d.ts +81 -0
- package/dist/coordinates/longitude-latitude-record.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude-record.js +104 -0
- package/dist/coordinates/longitude-latitude-record.js.map +1 -0
- package/dist/coordinates/longitude-latitude.d.ts +33 -0
- package/dist/coordinates/longitude-latitude.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude.js +78 -0
- package/dist/coordinates/longitude-latitude.js.map +1 -0
- package/dist/coordinates/polar-record.d.ts +77 -0
- package/dist/coordinates/polar-record.d.ts.map +1 -0
- package/dist/coordinates/polar-record.js +104 -0
- package/dist/coordinates/polar-record.js.map +1 -0
- package/dist/coordinates/polar.d.ts +28 -0
- package/dist/coordinates/polar.d.ts.map +1 -0
- package/dist/coordinates/polar.js +68 -0
- package/dist/coordinates/polar.js.map +1 -0
- package/dist/coordinates/spherical-cylindrical.d.ts +49 -0
- package/dist/coordinates/spherical-cylindrical.d.ts.map +1 -0
- package/dist/coordinates/spherical-cylindrical.js +110 -0
- package/dist/coordinates/spherical-cylindrical.js.map +1 -0
- package/dist/coordinates/spherical-record.d.ts +86 -0
- package/dist/coordinates/spherical-record.d.ts.map +1 -0
- package/dist/coordinates/spherical-record.js +114 -0
- package/dist/coordinates/spherical-record.js.map +1 -0
- package/dist/frustum3-record.d.ts +132 -0
- package/dist/frustum3-record.d.ts.map +1 -0
- package/dist/frustum3-record.js +333 -0
- package/dist/frustum3-record.js.map +1 -0
- package/dist/frustum3.d.ts +60 -0
- package/dist/frustum3.d.ts.map +1 -0
- package/dist/frustum3.js +186 -0
- package/dist/frustum3.js.map +1 -0
- package/dist/index.d.ts +36 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/line2-record.d.ts +87 -0
- package/dist/line2-record.d.ts.map +1 -0
- package/dist/line2-record.js +123 -0
- package/dist/line2-record.js.map +1 -0
- package/dist/line2.d.ts +20 -33
- package/dist/line2.d.ts.map +1 -1
- package/dist/line2.js +56 -51
- package/dist/line2.js.map +1 -1
- package/dist/line3-record.d.ts +91 -0
- package/dist/line3-record.d.ts.map +1 -0
- package/dist/line3-record.js +146 -0
- package/dist/line3-record.js.map +1 -0
- package/dist/line3.d.ts +11 -24
- package/dist/line3.d.ts.map +1 -1
- package/dist/line3.js +32 -36
- package/dist/line3.js.map +1 -1
- package/dist/mesh/_generator-kit.d.ts +14 -0
- package/dist/mesh/_generator-kit.d.ts.map +1 -0
- package/dist/mesh/_generator-kit.js +39 -0
- package/dist/mesh/_generator-kit.js.map +1 -0
- package/dist/mesh/_index-kernels-u16.d.ts +43 -0
- package/dist/mesh/_index-kernels-u16.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u16.js +264 -0
- package/dist/mesh/_index-kernels-u16.js.map +1 -0
- package/dist/mesh/_index-kernels-u32.d.ts +43 -0
- package/dist/mesh/_index-kernels-u32.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u32.js +264 -0
- package/dist/mesh/_index-kernels-u32.js.map +1 -0
- package/dist/mesh/generate-box.d.ts +16 -0
- package/dist/mesh/generate-box.d.ts.map +1 -0
- package/dist/mesh/generate-box.js +79 -0
- package/dist/mesh/generate-box.js.map +1 -0
- package/dist/mesh/generate-cylinder.d.ts +25 -0
- package/dist/mesh/generate-cylinder.d.ts.map +1 -0
- package/dist/mesh/generate-cylinder.js +117 -0
- package/dist/mesh/generate-cylinder.js.map +1 -0
- package/dist/mesh/generate-heightfield.d.ts +24 -0
- package/dist/mesh/generate-heightfield.d.ts.map +1 -0
- package/dist/mesh/generate-heightfield.js +48 -0
- package/dist/mesh/generate-heightfield.js.map +1 -0
- package/dist/mesh/generate-plane.d.ts +18 -0
- package/dist/mesh/generate-plane.d.ts.map +1 -0
- package/dist/mesh/generate-plane.js +39 -0
- package/dist/mesh/generate-plane.js.map +1 -0
- package/dist/mesh/generate-sphere.d.ts +50 -0
- package/dist/mesh/generate-sphere.d.ts.map +1 -0
- package/dist/mesh/generate-sphere.js +244 -0
- package/dist/mesh/generate-sphere.js.map +1 -0
- package/dist/mesh/index.d.ts +8 -0
- package/dist/mesh/index.d.ts.map +1 -0
- package/dist/mesh/index.js +8 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/mesh3-kernels.d.ts +82 -0
- package/dist/mesh/mesh3-kernels.d.ts.map +1 -0
- package/dist/mesh/mesh3-kernels.js +180 -0
- package/dist/mesh/mesh3-kernels.js.map +1 -0
- package/dist/mesh/mesh3.d.ts +66 -0
- package/dist/mesh/mesh3.d.ts.map +1 -0
- package/dist/mesh/mesh3.js +128 -0
- package/dist/mesh/mesh3.js.map +1 -0
- package/dist/plane3-record.d.ts +88 -0
- package/dist/plane3-record.d.ts.map +1 -0
- package/dist/plane3-record.js +123 -0
- package/dist/plane3-record.js.map +1 -0
- package/dist/plane3.d.ts +42 -28
- package/dist/plane3.d.ts.map +1 -1
- package/dist/plane3.js +166 -48
- package/dist/plane3.js.map +1 -1
- package/dist/polygon2.d.ts +82 -29
- package/dist/polygon2.d.ts.map +1 -1
- package/dist/polygon2.js +236 -93
- package/dist/polygon2.js.map +1 -1
- package/dist/polygon3.d.ts +40 -21
- package/dist/polygon3.d.ts.map +1 -1
- package/dist/polygon3.js +215 -91
- package/dist/polygon3.js.map +1 -1
- package/dist/polyline2.d.ts +37 -0
- package/dist/polyline2.d.ts.map +1 -0
- package/dist/polyline2.js +146 -0
- package/dist/polyline2.js.map +1 -0
- package/dist/polyline3.d.ts +35 -0
- package/dist/polyline3.d.ts.map +1 -0
- package/dist/polyline3.js +159 -0
- package/dist/polyline3.js.map +1 -0
- package/dist/quadtree.d.ts +238 -0
- package/dist/quadtree.d.ts.map +1 -0
- package/dist/quadtree.js +1019 -0
- package/dist/quadtree.js.map +1 -0
- package/dist/ray2-record.d.ts +86 -0
- package/dist/ray2-record.d.ts.map +1 -0
- package/dist/ray2-record.js +123 -0
- package/dist/ray2-record.js.map +1 -0
- package/dist/ray2.d.ts +38 -13
- package/dist/ray2.d.ts.map +1 -1
- package/dist/ray2.js +85 -22
- package/dist/ray2.js.map +1 -1
- package/dist/ray3-array.d.ts +27 -0
- package/dist/ray3-array.d.ts.map +1 -0
- package/dist/ray3-array.js +89 -0
- package/dist/ray3-array.js.map +1 -0
- package/dist/ray3-record.d.ts +90 -0
- package/dist/ray3-record.d.ts.map +1 -0
- package/dist/ray3-record.js +146 -0
- package/dist/ray3-record.js.map +1 -0
- package/dist/ray3.d.ts +72 -25
- package/dist/ray3.d.ts.map +1 -1
- package/dist/ray3.js +233 -64
- package/dist/ray3.js.map +1 -1
- package/dist/segment2-record.d.ts +80 -0
- package/dist/segment2-record.d.ts.map +1 -0
- package/dist/segment2-record.js +122 -0
- package/dist/segment2-record.js.map +1 -0
- package/dist/segment2.d.ts +34 -19
- package/dist/segment2.d.ts.map +1 -1
- package/dist/segment2.js +88 -42
- package/dist/segment2.js.map +1 -1
- package/dist/segment3-record.d.ts +90 -0
- package/dist/segment3-record.d.ts.map +1 -0
- package/dist/segment3-record.js +146 -0
- package/dist/segment3-record.js.map +1 -0
- package/dist/segment3.d.ts +24 -12
- package/dist/segment3.d.ts.map +1 -1
- package/dist/segment3.js +67 -30
- package/dist/segment3.js.map +1 -1
- package/dist/size.d.ts +40 -0
- package/dist/size.d.ts.map +1 -0
- package/dist/size.js +72 -0
- package/dist/size.js.map +1 -0
- package/dist/sphere3-array-boundary.d.ts +51 -0
- package/dist/sphere3-array-boundary.d.ts.map +1 -0
- package/dist/sphere3-array-boundary.js +98 -0
- package/dist/sphere3-array-boundary.js.map +1 -0
- package/dist/sphere3-record.d.ts +88 -0
- package/dist/sphere3-record.d.ts.map +1 -0
- package/dist/sphere3-record.js +123 -0
- package/dist/sphere3-record.js.map +1 -0
- package/dist/sphere3.d.ts +55 -12
- package/dist/sphere3.d.ts.map +1 -1
- package/dist/sphere3.js +233 -24
- package/dist/sphere3.js.map +1 -1
- package/dist/spherical/cap.d.ts +56 -0
- package/dist/spherical/cap.d.ts.map +1 -0
- package/dist/spherical/cap.js +363 -0
- package/dist/spherical/cap.js.map +1 -0
- package/dist/spherical/great-circle.d.ts +39 -0
- package/dist/spherical/great-circle.d.ts.map +1 -0
- package/dist/spherical/great-circle.js +158 -0
- package/dist/spherical/great-circle.js.map +1 -0
- package/dist/spherical/index.d.ts +3 -0
- package/dist/spherical/index.d.ts.map +1 -0
- package/dist/spherical/index.js +3 -0
- package/dist/spherical/index.js.map +1 -0
- package/dist/triangle2-record.d.ts +91 -0
- package/dist/triangle2-record.d.ts.map +1 -0
- package/dist/triangle2-record.js +146 -0
- package/dist/triangle2-record.js.map +1 -0
- package/dist/triangle2.d.ts +29 -14
- package/dist/triangle2.d.ts.map +1 -1
- package/dist/triangle2.js +86 -22
- package/dist/triangle2.js.map +1 -1
- package/dist/triangle3-record.d.ts +97 -0
- package/dist/triangle3-record.d.ts.map +1 -0
- package/dist/triangle3-record.js +178 -0
- package/dist/triangle3-record.js.map +1 -0
- package/dist/triangle3.d.ts +41 -17
- package/dist/triangle3.d.ts.map +1 -1
- package/dist/triangle3.js +267 -38
- package/dist/triangle3.js.map +1 -1
- package/package.json +15 -8
- package/dist/angles.d.ts +0 -31
- package/dist/angles.d.ts.map +0 -1
- package/dist/angles.js +0 -53
- package/dist/angles.js.map +0 -1
- package/dist/coordinate-spaces.d.ts +0 -39
- package/dist/coordinate-spaces.d.ts.map +0 -1
- package/dist/coordinate-spaces.js +0 -52
- package/dist/coordinate-spaces.js.map +0 -1
- package/dist/coordinates-vec2.d.ts +0 -7
- package/dist/coordinates-vec2.d.ts.map +0 -1
- package/dist/coordinates-vec2.js +0 -35
- package/dist/coordinates-vec2.js.map +0 -1
- package/dist/coordinates-vec3.d.ts +0 -11
- package/dist/coordinates-vec3.d.ts.map +0 -1
- package/dist/coordinates-vec3.js +0 -61
- package/dist/coordinates-vec3.js.map +0 -1
- package/dist/coordinates.d.ts +0 -54
- package/dist/coordinates.d.ts.map +0 -1
- package/dist/coordinates.js +0 -2
- package/dist/coordinates.js.map +0 -1
- package/dist/euler-angles-quaternion.d.ts +0 -7
- package/dist/euler-angles-quaternion.d.ts.map +0 -1
- package/dist/euler-angles-quaternion.js +0 -100
- package/dist/euler-angles-quaternion.js.map +0 -1
- package/dist/euler-angles.d.ts +0 -33
- package/dist/euler-angles.d.ts.map +0 -1
- package/dist/euler-angles.js +0 -35
- package/dist/euler-angles.js.map +0 -1
- package/dist/geometry-vectors.d.ts +0 -11
- package/dist/geometry-vectors.d.ts.map +0 -1
- package/dist/geometry-vectors.js +0 -19
- package/dist/geometry-vectors.js.map +0 -1
- package/dist/mesh3.d.ts +0 -32
- package/dist/mesh3.d.ts.map +0 -1
- package/dist/mesh3.js +0 -142
- package/dist/mesh3.js.map +0 -1
- package/dist/point2.d.ts +0 -41
- package/dist/point2.d.ts.map +0 -1
- package/dist/point2.js +0 -92
- package/dist/point2.js.map +0 -1
- package/dist/point3.d.ts +0 -43
- package/dist/point3.d.ts.map +0 -1
- package/dist/point3.js +0 -103
- package/dist/point3.js.map +0 -1
- package/dist/point4.d.ts +0 -12
- package/dist/point4.d.ts.map +0 -1
- package/dist/point4.js +0 -28
- package/dist/point4.js.map +0 -1
- package/dist/rect2.d.ts +0 -54
- package/dist/rect2.d.ts.map +0 -1
- package/dist/rect2.js +0 -149
- package/dist/rect2.js.map +0 -1
- package/dist/size2.d.ts +0 -33
- package/dist/size2.d.ts.map +0 -1
- package/dist/size2.js +0 -81
- package/dist/size2.js.map +0 -1
- package/dist/size3.d.ts +0 -21
- package/dist/size3.d.ts.map +0 -1
- package/dist/size3.js +0 -59
- package/dist/size3.js.map +0 -1
- package/dist/size4.d.ts +0 -10
- package/dist/size4.d.ts.map +0 -1
- package/dist/size4.js +0 -16
- package/dist/size4.js.map +0 -1
|
@@ -0,0 +1,104 @@
|
|
|
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];
|
|
9
|
+
/**
|
|
10
|
+
* Creates the position `[0, 0]`, on the equator at +X.
|
|
11
|
+
*
|
|
12
|
+
* Allocates; keep it out of hot loops.
|
|
13
|
+
*/
|
|
14
|
+
export function longitudeLatitudeCreate() {
|
|
15
|
+
const out = TEMPLATE_.slice();
|
|
16
|
+
out[0] = 0;
|
|
17
|
+
out[1] = 0;
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates the longitude and latitude with the components `longitude, latitude`,
|
|
22
|
+
* in storage order.
|
|
23
|
+
*
|
|
24
|
+
* Allocates; keep it out of hot loops.
|
|
25
|
+
*/
|
|
26
|
+
export function longitudeLatitudeOf(longitude, latitude) {
|
|
27
|
+
const out = TEMPLATE_.slice();
|
|
28
|
+
out[0] = longitude;
|
|
29
|
+
out[1] = latitude;
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
34
|
+
*
|
|
35
|
+
* Allocates; keep it out of hot loops.
|
|
36
|
+
*/
|
|
37
|
+
export function longitudeLatitudeClone(a) {
|
|
38
|
+
const out = TEMPLATE_.slice();
|
|
39
|
+
out[0] = a[0];
|
|
40
|
+
out[1] = a[1];
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** Writes the components, in storage order, into `out`. */
|
|
44
|
+
export function longitudeLatitudeSet(out, longitude, latitude) {
|
|
45
|
+
out[0] = longitude;
|
|
46
|
+
out[1] = latitude;
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
50
|
+
export function longitudeLatitudeCopy(out, a) {
|
|
51
|
+
out[0] = a[0];
|
|
52
|
+
out[1] = a[1];
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
57
|
+
* included, and an infinity equals itself. See {@link longitudeLatitudeIsClose}
|
|
58
|
+
* for a tolerant test.
|
|
59
|
+
*/
|
|
60
|
+
export function longitudeLatitudeEquals(a, b) {
|
|
61
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
65
|
+
* `tolerance`, an absolute bound in the caller's units, and an infinity is
|
|
66
|
+
* close only to itself. Not transitive, so never a basis for ordering or a
|
|
67
|
+
* container key: use {@link longitudeLatitudeEquals} there.
|
|
68
|
+
*
|
|
69
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
70
|
+
*/
|
|
71
|
+
export function longitudeLatitudeIsClose(a, b, tolerance = geometryConfig.defaultLinearTolerance) {
|
|
72
|
+
return (isCloseAbsolute(a[0], b[0], tolerance) &&
|
|
73
|
+
isCloseAbsolute(a[1], b[1], tolerance));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
77
|
+
* origin): `source[offset … offset + 2)` copied into `out`, each element that
|
|
78
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
79
|
+
* `out` never holds a non-number. A cold path: buffers use
|
|
80
|
+
* {@link longitudeLatitudeLoad}. O(1).
|
|
81
|
+
*
|
|
82
|
+
* `source` may be `out` itself: the 2 elements are read before the first write.
|
|
83
|
+
*
|
|
84
|
+
* @param out The longitude and latitude to fill.
|
|
85
|
+
* @param source The array to read, of any length and any content.
|
|
86
|
+
* @param offset The index of the first component in `source`.
|
|
87
|
+
* @returns `out`.
|
|
88
|
+
*/
|
|
89
|
+
export function longitudeLatitudeFromArray(out, source, offset = 0) {
|
|
90
|
+
const value0 = numberAtOrNaN(source, offset);
|
|
91
|
+
const value1 = numberAtOrNaN(source, offset + 1);
|
|
92
|
+
out[0] = value0;
|
|
93
|
+
out[1] = value1;
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
98
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
99
|
+
* that is not a number at all counts as not finite.
|
|
100
|
+
*/
|
|
101
|
+
export function longitudeLatitudeIsFinite(value) {
|
|
102
|
+
return Number.isFinite(value[0]) && Number.isFinite(value[1]);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=longitude-latitude-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"longitude-latitude-record.js","sourceRoot":"","sources":["../../src/coordinates/longitude-latitude-record.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA0B/C;;;GAGG;AACH,MAAM,SAAS,GAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACtC,MAAM,GAAG,GAAG,SAAS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AAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACvC,CAA4B,EAC5B,CAA4B,EAC5B,SAAS,GAAW,cAAc,CAAC,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,CACtC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,0BAA0B,CACzC,GAAsB,EACtB,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,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,yBAAyB,CACxC,KAAgC;IAEhC,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReadonlyVec3, Vec3 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { LongitudeLatitude, ReadonlyLongitudeLatitude } from "./longitude-latitude-record.js";
|
|
3
|
+
/**
|
|
4
|
+
* Writes the unit vector of the direction at `coords` on a Z-up sphere into
|
|
5
|
+
* `out`: `[cos(lat)·cos(lon), cos(lat)·sin(lon), sin(lat)]`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function vec3FromLongitudeLatitude(out: Vec3, coords: ReadonlyLongitudeLatitude): Vec3;
|
|
8
|
+
/**
|
|
9
|
+
* Writes the longitude, in `(−π, π]`, and latitude, in `[−π/2, π/2]`, of the
|
|
10
|
+
* direction of `a` into `out`; the length of `a` does not matter. A vector on
|
|
11
|
+
* the Z axis has longitude `0`, and the zero vector gives `[0, 0]`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function longitudeLatitudeFromVec3(out: LongitudeLatitude, a: ReadonlyVec3): LongitudeLatitude;
|
|
14
|
+
/**
|
|
15
|
+
* Writes the unit vector of every `(longitude, latitude)` pair of `input` (two
|
|
16
|
+
* numbers each) into `out` (three numbers each), as
|
|
17
|
+
* {@link vec3FromLongitudeLatitude}. The arrays differ in length, so `out`
|
|
18
|
+
* cannot be `input`. O(n).
|
|
19
|
+
*
|
|
20
|
+
* @throws {RangeError} When `input.length` is odd or `out.length` is not
|
|
21
|
+
* `input.length / 2 · 3`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function vec3ArrayFromLongitudeLatitude<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
24
|
+
/**
|
|
25
|
+
* Writes the longitude and latitude of every vector of `input` (three numbers
|
|
26
|
+
* each) into `out` (two numbers each), as {@link longitudeLatitudeFromVec3}. The
|
|
27
|
+
* arrays differ in length, so `out` cannot be `input`. O(n).
|
|
28
|
+
*
|
|
29
|
+
* @throws {RangeError} When `input.length` is not a multiple of 3 or
|
|
30
|
+
* `out.length` is not `input.length / 3 · 2`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function longitudeLatitudeArrayFromVec3<T extends Float64Array>(out: T, input: Float64Array): T;
|
|
33
|
+
//# sourceMappingURL=longitude-latitude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"longitude-latitude.d.ts","sourceRoot":"","sources":["../../src/coordinates/longitude-latitude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,KAAK,EACX,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,GAC/B,IAAI,CAQN;AAUD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,iBAAiB,EACtB,CAAC,EAAE,YAAY,GACb,iBAAiB,CAOnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,YAAY,EACpE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAeH;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,YAAY,EACpE,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,GACjB,CAAC,CAcH"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { angleNormalizeRad } from "@ac-kit/math-scalar";
|
|
2
|
+
/**
|
|
3
|
+
* Writes the unit vector of the direction at `coords` on a Z-up sphere into
|
|
4
|
+
* `out`: `[cos(lat)·cos(lon), cos(lat)·sin(lon), sin(lat)]`.
|
|
5
|
+
*/
|
|
6
|
+
export function vec3FromLongitudeLatitude(out, coords) {
|
|
7
|
+
const longitude = coords[0];
|
|
8
|
+
const latitude = coords[1];
|
|
9
|
+
const equatorial = Math.cos(latitude);
|
|
10
|
+
out[0] = equatorial * Math.cos(longitude);
|
|
11
|
+
out[1] = equatorial * Math.sin(longitude);
|
|
12
|
+
out[2] = Math.sin(latitude);
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
function longitudeOf_(x, y) {
|
|
16
|
+
return x === 0 && y === 0 ? 0 : angleNormalizeRad(Math.atan2(y, x));
|
|
17
|
+
}
|
|
18
|
+
function latitudeOf_(x, y, z) {
|
|
19
|
+
return Math.atan2(z, Math.sqrt(x * x + y * y)) + 0;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Writes the longitude, in `(−π, π]`, and latitude, in `[−π/2, π/2]`, of the
|
|
23
|
+
* direction of `a` into `out`; the length of `a` does not matter. A vector on
|
|
24
|
+
* the Z axis has longitude `0`, and the zero vector gives `[0, 0]`.
|
|
25
|
+
*/
|
|
26
|
+
export function longitudeLatitudeFromVec3(out, a) {
|
|
27
|
+
const x = a[0];
|
|
28
|
+
const y = a[1];
|
|
29
|
+
const z = a[2];
|
|
30
|
+
out[0] = longitudeOf_(x, y);
|
|
31
|
+
out[1] = latitudeOf_(x, y, z);
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Writes the unit vector of every `(longitude, latitude)` pair of `input` (two
|
|
36
|
+
* numbers each) into `out` (three numbers each), as
|
|
37
|
+
* {@link vec3FromLongitudeLatitude}. The arrays differ in length, so `out`
|
|
38
|
+
* cannot be `input`. O(n).
|
|
39
|
+
*
|
|
40
|
+
* @throws {RangeError} When `input.length` is odd or `out.length` is not
|
|
41
|
+
* `input.length / 2 · 3`.
|
|
42
|
+
*/
|
|
43
|
+
export function vec3ArrayFromLongitudeLatitude(out, input) {
|
|
44
|
+
if (input.length % 2 !== 0 || out.length !== (input.length / 2) * 3) {
|
|
45
|
+
throw new RangeError(`vec3ArrayFromLongitudeLatitude: out has ${out.length} numbers for ${input.length} in input, which must be a multiple of 2 and give 3 per pair.`);
|
|
46
|
+
}
|
|
47
|
+
for (let from = 0, to = 0; from < input.length; from += 2, to += 3) {
|
|
48
|
+
const longitude = input[from];
|
|
49
|
+
const latitude = input[from + 1];
|
|
50
|
+
const equatorial = Math.cos(latitude);
|
|
51
|
+
out[to] = equatorial * Math.cos(longitude);
|
|
52
|
+
out[to + 1] = equatorial * Math.sin(longitude);
|
|
53
|
+
out[to + 2] = Math.sin(latitude);
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Writes the longitude and latitude of every vector of `input` (three numbers
|
|
59
|
+
* each) into `out` (two numbers each), as {@link longitudeLatitudeFromVec3}. The
|
|
60
|
+
* arrays differ in length, so `out` cannot be `input`. O(n).
|
|
61
|
+
*
|
|
62
|
+
* @throws {RangeError} When `input.length` is not a multiple of 3 or
|
|
63
|
+
* `out.length` is not `input.length / 3 · 2`.
|
|
64
|
+
*/
|
|
65
|
+
export function longitudeLatitudeArrayFromVec3(out, input) {
|
|
66
|
+
if (input.length % 3 !== 0 || out.length !== (input.length / 3) * 2) {
|
|
67
|
+
throw new RangeError(`longitudeLatitudeArrayFromVec3: out has ${out.length} numbers for ${input.length} in input, which must be a multiple of 3 and give 2 per vector.`);
|
|
68
|
+
}
|
|
69
|
+
for (let from = 0, to = 0; from < input.length; from += 3, to += 2) {
|
|
70
|
+
const x = input[from];
|
|
71
|
+
const y = input[from + 1];
|
|
72
|
+
const z = input[from + 2];
|
|
73
|
+
out[to] = longitudeOf_(x, y);
|
|
74
|
+
out[to + 1] = latitudeOf_(x, y, z);
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=longitude-latitude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"longitude-latitude.js","sourceRoot":"","sources":["../../src/coordinates/longitude-latitude.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACxC,GAAS,EACT,MAAiC;IAEjC,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,C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AgB,KAAK,CAAC,MAAM,iEAAiE,CAClJ,CAAC;IACH,CAAC;IACD,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAE,CAAC;QACvB,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;QAC3B,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7B,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Brand_ } from "../_brand.js";
|
|
2
|
+
/**
|
|
3
|
+
* Polar coordinates in the plane: the radius, then the angle from +x in
|
|
4
|
+
* radians, counter-clockwise in a y-up frame, in `(−π, π]`.
|
|
5
|
+
*
|
|
6
|
+
* A plain array of 2 binary64 numbers carrying a type-level brand, holding
|
|
7
|
+
* exactly the numbers one element of the matching bulk buffer holds, in the
|
|
8
|
+
* same order.
|
|
9
|
+
*
|
|
10
|
+
* Only {@link polarCoordsCreate}, {@link polarCoordsOf}, {@link polarCoordsClone},
|
|
11
|
+
* {@link polarCoordsFromArray} and the functions that write an `out` make one;
|
|
12
|
+
* see `Vec3` in `@ac-kit/math-linear` for the rules that bind callers who
|
|
13
|
+
* bypass the types.
|
|
14
|
+
*/
|
|
15
|
+
export type PolarCoords = [radius: number, angle: number] & Brand_<"PolarCoords">;
|
|
16
|
+
/** A {@link PolarCoords} that is only read. */
|
|
17
|
+
export type ReadonlyPolarCoords = readonly [radius: number, angle: number] & Brand_<"PolarCoords">;
|
|
18
|
+
/**
|
|
19
|
+
* Creates the polar coordinates `[0, 0]`, the origin.
|
|
20
|
+
*
|
|
21
|
+
* Allocates; keep it out of hot loops.
|
|
22
|
+
*/
|
|
23
|
+
export declare function polarCoordsCreate(): PolarCoords;
|
|
24
|
+
/**
|
|
25
|
+
* Creates the polar coordinates with the components `radius, angle`, in storage
|
|
26
|
+
* order.
|
|
27
|
+
*
|
|
28
|
+
* Allocates; keep it out of hot loops.
|
|
29
|
+
*/
|
|
30
|
+
export declare function polarCoordsOf(radius: number, angle: number): PolarCoords;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
33
|
+
*
|
|
34
|
+
* Allocates; keep it out of hot loops.
|
|
35
|
+
*/
|
|
36
|
+
export declare function polarCoordsClone(a: ReadonlyPolarCoords): PolarCoords;
|
|
37
|
+
/** Writes the components, in storage order, into `out`. */
|
|
38
|
+
export declare function polarCoordsSet(out: PolarCoords, radius: number, angle: number): PolarCoords;
|
|
39
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
40
|
+
export declare function polarCoordsCopy(out: PolarCoords, a: ReadonlyPolarCoords): PolarCoords;
|
|
41
|
+
/**
|
|
42
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
43
|
+
* included, and an infinity equals itself. See {@link polarCoordsIsClose} for a
|
|
44
|
+
* tolerant test.
|
|
45
|
+
*/
|
|
46
|
+
export declare function polarCoordsEquals(a: ReadonlyPolarCoords, b: ReadonlyPolarCoords): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
49
|
+
* `tolerance`, an absolute bound in the caller's units, and an infinity is
|
|
50
|
+
* close only to itself. Not transitive, so never a basis for ordering or a
|
|
51
|
+
* container key: use {@link polarCoordsEquals} there.
|
|
52
|
+
*
|
|
53
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function polarCoordsIsClose(a: ReadonlyPolarCoords, b: ReadonlyPolarCoords, tolerance?: number): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
58
|
+
* origin): `source[offset … offset + 2)` copied into `out`, each element that
|
|
59
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
60
|
+
* `out` never holds a non-number. A cold path: buffers use
|
|
61
|
+
* {@link polarCoordsLoad}. O(1).
|
|
62
|
+
*
|
|
63
|
+
* `source` may be `out` itself: the 2 elements are read before the first write.
|
|
64
|
+
*
|
|
65
|
+
* @param out The polar coordinates to fill.
|
|
66
|
+
* @param source The array to read, of any length and any content.
|
|
67
|
+
* @param offset The index of the first component in `source`.
|
|
68
|
+
* @returns `out`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function polarCoordsFromArray(out: PolarCoords, source: ArrayLike<number>, offset?: number): PolarCoords;
|
|
71
|
+
/**
|
|
72
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
73
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
74
|
+
* that is not a number at all counts as not finite.
|
|
75
|
+
*/
|
|
76
|
+
export declare function polarCoordsIsFinite(value: ReadonlyPolarCoords): boolean;
|
|
77
|
+
//# sourceMappingURL=polar-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polar-record.d.ts","sourceRoot":"","sources":["../../src/coordinates/polar-record.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,GACxD,MAAM,CAAC,aAAa,CAAC,CAAC;AAEvB,+CAA+C;AAC/C,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,GACzE,MAAM,CAAC,aAAa,CAAC,CAAC;AAQvB;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAK/C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAKxE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAKpE;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAC7B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,WAAW,CAIb;AAED,yDAAyD;AACzD,wBAAgB,eAAe,CAC9B,GAAG,EAAE,WAAW,EAChB,CAAC,EAAE,mBAAmB,GACpB,WAAW,CAIb;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAChC,CAAC,EAAE,mBAAmB,EACtB,CAAC,EAAE,mBAAmB,GACpB,OAAO,CAET;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CACjC,CAAC,EAAE,mBAAmB,EACtB,CAAC,EAAE,mBAAmB,EACtB,SAAS,GAAE,MAA8C,GACvD,OAAO,CAKT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,MAAM,SAAI,GACR,WAAW,CAMb;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAEvE"}
|
|
@@ -0,0 +1,104 @@
|
|
|
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];
|
|
9
|
+
/**
|
|
10
|
+
* Creates the polar coordinates `[0, 0]`, the origin.
|
|
11
|
+
*
|
|
12
|
+
* Allocates; keep it out of hot loops.
|
|
13
|
+
*/
|
|
14
|
+
export function polarCoordsCreate() {
|
|
15
|
+
const out = TEMPLATE_.slice();
|
|
16
|
+
out[0] = 0;
|
|
17
|
+
out[1] = 0;
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates the polar coordinates with the components `radius, angle`, in storage
|
|
22
|
+
* order.
|
|
23
|
+
*
|
|
24
|
+
* Allocates; keep it out of hot loops.
|
|
25
|
+
*/
|
|
26
|
+
export function polarCoordsOf(radius, angle) {
|
|
27
|
+
const out = TEMPLATE_.slice();
|
|
28
|
+
out[0] = radius;
|
|
29
|
+
out[1] = angle;
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
34
|
+
*
|
|
35
|
+
* Allocates; keep it out of hot loops.
|
|
36
|
+
*/
|
|
37
|
+
export function polarCoordsClone(a) {
|
|
38
|
+
const out = TEMPLATE_.slice();
|
|
39
|
+
out[0] = a[0];
|
|
40
|
+
out[1] = a[1];
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** Writes the components, in storage order, into `out`. */
|
|
44
|
+
export function polarCoordsSet(out, radius, angle) {
|
|
45
|
+
out[0] = radius;
|
|
46
|
+
out[1] = angle;
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
50
|
+
export function polarCoordsCopy(out, a) {
|
|
51
|
+
out[0] = a[0];
|
|
52
|
+
out[1] = a[1];
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
57
|
+
* included, and an infinity equals itself. See {@link polarCoordsIsClose} for a
|
|
58
|
+
* tolerant test.
|
|
59
|
+
*/
|
|
60
|
+
export function polarCoordsEquals(a, b) {
|
|
61
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
65
|
+
* `tolerance`, an absolute bound in the caller's units, and an infinity is
|
|
66
|
+
* close only to itself. Not transitive, so never a basis for ordering or a
|
|
67
|
+
* container key: use {@link polarCoordsEquals} there.
|
|
68
|
+
*
|
|
69
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
70
|
+
*/
|
|
71
|
+
export function polarCoordsIsClose(a, b, tolerance = geometryConfig.defaultLinearTolerance) {
|
|
72
|
+
return (isCloseAbsolute(a[0], b[0], tolerance) &&
|
|
73
|
+
isCloseAbsolute(a[1], b[1], tolerance));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
77
|
+
* origin): `source[offset … offset + 2)` copied into `out`, each element that
|
|
78
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
79
|
+
* `out` never holds a non-number. A cold path: buffers use
|
|
80
|
+
* {@link polarCoordsLoad}. O(1).
|
|
81
|
+
*
|
|
82
|
+
* `source` may be `out` itself: the 2 elements are read before the first write.
|
|
83
|
+
*
|
|
84
|
+
* @param out The polar coordinates to fill.
|
|
85
|
+
* @param source The array to read, of any length and any content.
|
|
86
|
+
* @param offset The index of the first component in `source`.
|
|
87
|
+
* @returns `out`.
|
|
88
|
+
*/
|
|
89
|
+
export function polarCoordsFromArray(out, source, offset = 0) {
|
|
90
|
+
const value0 = numberAtOrNaN(source, offset);
|
|
91
|
+
const value1 = numberAtOrNaN(source, offset + 1);
|
|
92
|
+
out[0] = value0;
|
|
93
|
+
out[1] = value1;
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
98
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
99
|
+
* that is not a number at all counts as not finite.
|
|
100
|
+
*/
|
|
101
|
+
export function polarCoordsIsFinite(value) {
|
|
102
|
+
return Number.isFinite(value[0]) && Number.isFinite(value[1]);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=polar-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polar-record.js","sourceRoot":"","sources":["../../src/coordinates/polar-record.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAsB/C;;;GAGG;AACH,MAAM,SAAS,GAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAChC,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAiB,CAAC;IAC7C,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,aAAa,CAAC,MAAc,EAAE,KAAa;IAC1D,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAiB,CAAC;IAC7C,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAChB,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACf,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAsB;IACtD,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAiB,CAAC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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,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,mBAAmB,CAAC,KAA0B;IAC7D,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReadonlyVec2, type Vec2 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { PolarCoords, ReadonlyPolarCoords } from "./polar-record.js";
|
|
3
|
+
/**
|
|
4
|
+
* Writes the polar coordinates of `a` into `out`: the length, then the angle
|
|
5
|
+
* from +x, counter-clockwise in a y-up frame, in `(−π, π]`. The zero vector,
|
|
6
|
+
* signed zeros included, gives `[0, 0]`. `out` is not a vector, so it cannot be
|
|
7
|
+
* `a`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function polarFromVec2(out: PolarCoords, a: ReadonlyVec2): PolarCoords;
|
|
10
|
+
/** Writes the point of the polar coordinates `coords` into `out`. */
|
|
11
|
+
export declare function vec2FromPolar(out: Vec2, coords: ReadonlyPolarCoords): Vec2;
|
|
12
|
+
/**
|
|
13
|
+
* Writes the polygonal polar coordinates of `a` into `out`: the radius in the
|
|
14
|
+
* norm whose unit ball is a regular polygon of `sides` sides with circumradius
|
|
15
|
+
* 1 and a vertex at the angle `rotation` (so the radius is `1` on the polygon's
|
|
16
|
+
* boundary, below `1` inside and above `1` outside), then the ordinary angle in
|
|
17
|
+
* `(−π, π]`. The zero vector gives `[0, 0]`.
|
|
18
|
+
*
|
|
19
|
+
* @param sides The number of sides, at least `3` (not checked).
|
|
20
|
+
* @param rotation The angle of a vertex, in radians.
|
|
21
|
+
*/
|
|
22
|
+
export declare function polygonalPolarFromVec2(out: PolarCoords, a: ReadonlyVec2, sides: number, rotation: number): PolarCoords;
|
|
23
|
+
/**
|
|
24
|
+
* Writes the point of the polygonal polar coordinates `coords` (see
|
|
25
|
+
* {@link polygonalPolarFromVec2}) into `out`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function vec2FromPolygonalPolar(out: Vec2, coords: ReadonlyPolarCoords, sides: number, rotation: number): Vec2;
|
|
28
|
+
//# sourceMappingURL=polar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polar.d.ts","sourceRoot":"","sources":["../../src/coordinates/polar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAG/E,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAW1E;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,GAAG,WAAW,CAI5E;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAM1E;AAiBD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,WAAW,EAChB,CAAC,EAAE,YAAY,EACf,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACd,WAAW,CAKb;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACd,IAAI,CAMN"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { mod } from "@ac-kit/core";
|
|
2
|
+
import { vec2Length } from "@ac-kit/math-linear";
|
|
3
|
+
import { angleNormalizeRad, TWO_PI } from "@ac-kit/math-scalar";
|
|
4
|
+
/**
|
|
5
|
+
* The angle of `a` in `(−π, π]`, `0` for the zero vector whatever the signs of
|
|
6
|
+
* its zeros: `+ 0` turns −0 into +0 before `atan2`, which would read `(−0, ±0)`
|
|
7
|
+
* as `±π`.
|
|
8
|
+
*/
|
|
9
|
+
function angleOf_(a) {
|
|
10
|
+
return angleNormalizeRad(Math.atan2(a[1] + 0, a[0] + 0));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Writes the polar coordinates of `a` into `out`: the length, then the angle
|
|
14
|
+
* from +x, counter-clockwise in a y-up frame, in `(−π, π]`. The zero vector,
|
|
15
|
+
* signed zeros included, gives `[0, 0]`. `out` is not a vector, so it cannot be
|
|
16
|
+
* `a`.
|
|
17
|
+
*/
|
|
18
|
+
export function polarFromVec2(out, a) {
|
|
19
|
+
out[0] = vec2Length(a);
|
|
20
|
+
out[1] = angleOf_(a);
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
/** Writes the point of the polar coordinates `coords` into `out`. */
|
|
24
|
+
export function vec2FromPolar(out, coords) {
|
|
25
|
+
const radius = coords[0];
|
|
26
|
+
const angle = coords[1];
|
|
27
|
+
out[0] = radius * Math.cos(angle);
|
|
28
|
+
out[1] = radius * Math.sin(angle);
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `cos` of the offset of `angle` from the bisector of its sector, over `cos` of
|
|
33
|
+
* half a sector: the polygon's boundary distance, inverted.
|
|
34
|
+
*/
|
|
35
|
+
function boundaryRatio_(angle, sides, rotation) {
|
|
36
|
+
const sector = TWO_PI / sides;
|
|
37
|
+
const half = sector / 2;
|
|
38
|
+
const offset = mod(angle - rotation, sector) - half;
|
|
39
|
+
return Math.cos(offset) / Math.cos(half);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Writes the polygonal polar coordinates of `a` into `out`: the radius in the
|
|
43
|
+
* norm whose unit ball is a regular polygon of `sides` sides with circumradius
|
|
44
|
+
* 1 and a vertex at the angle `rotation` (so the radius is `1` on the polygon's
|
|
45
|
+
* boundary, below `1` inside and above `1` outside), then the ordinary angle in
|
|
46
|
+
* `(−π, π]`. The zero vector gives `[0, 0]`.
|
|
47
|
+
*
|
|
48
|
+
* @param sides The number of sides, at least `3` (not checked).
|
|
49
|
+
* @param rotation The angle of a vertex, in radians.
|
|
50
|
+
*/
|
|
51
|
+
export function polygonalPolarFromVec2(out, a, sides, rotation) {
|
|
52
|
+
const angle = angleOf_(a);
|
|
53
|
+
out[0] = vec2Length(a) * boundaryRatio_(angle, sides, rotation);
|
|
54
|
+
out[1] = angle;
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Writes the point of the polygonal polar coordinates `coords` (see
|
|
59
|
+
* {@link polygonalPolarFromVec2}) into `out`.
|
|
60
|
+
*/
|
|
61
|
+
export function vec2FromPolygonalPolar(out, coords, sides, rotation) {
|
|
62
|
+
const angle = coords[1];
|
|
63
|
+
const distance = coords[0] / boundaryRatio_(angle, sides, rotation);
|
|
64
|
+
out[0] = distance * Math.cos(angle);
|
|
65
|
+
out[1] = distance * Math.sin(angle);
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=polar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polar.js","sourceRoot":"","sources":["../../src/coordinates/polar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAgC,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIhE;;;;GAIG;AACH,SAAS,QAAQ,CAAC,C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EACb,QAAgB;IAEhB,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1B,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAChE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACf,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACrC,GAAS,EACT,MAA2B,EAC3B,KAAa,EACb,QAAgB;IAEhB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpE,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ReadonlyVec3, type Vec3 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { CylindricalCoords, ReadonlyCylindricalCoords } from "./cylindrical-record.js";
|
|
3
|
+
import type { ReadonlySphericalCoords, SphericalCoords } from "./spherical-record.js";
|
|
4
|
+
/**
|
|
5
|
+
* Spherical and cylindrical coordinates name their up axis in the function:
|
|
6
|
+
* `…YUp` (azimuth in the XZ plane, graphics) and `…ZUp` (azimuth in the XY
|
|
7
|
+
* plane, ISO 80000-2). Angles in radians; azimuths in `(−π, π]`. Components are
|
|
8
|
+
* read with `+ 0`, which turns −0 into +0: `atan2` would read a signed zero as
|
|
9
|
+
* `π`, and the zero vector and the axis must give the zeros they document
|
|
10
|
+
* whatever the signs of their zeros.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Writes the spherical coordinates of `a` with Y up into `out`: the length, the
|
|
14
|
+
* azimuth `atan2(z, x)` and the inclination from +Y, in `[0, π]`. The
|
|
15
|
+
* inclination is an `atan2`, so the zero vector gives `[0, 0, 0]` and the axis
|
|
16
|
+
* itself azimuth `0`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sphericalFromVec3YUp(out: SphericalCoords, a: ReadonlyVec3): SphericalCoords;
|
|
19
|
+
/** Writes the point of the spherical coordinates `coords` with Y up into `out`. */
|
|
20
|
+
export declare function vec3FromSphericalYUp(out: Vec3, coords: ReadonlySphericalCoords): Vec3;
|
|
21
|
+
/**
|
|
22
|
+
* Writes the spherical coordinates of `a` with Z up (ISO 80000-2) into `out`:
|
|
23
|
+
* the length, the azimuth `atan2(y, x)` from +X toward +Y and the inclination
|
|
24
|
+
* from +Z, in `[0, π]`. The zero vector gives `[0, 0, 0]`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sphericalFromVec3ZUp(out: SphericalCoords, a: ReadonlyVec3): SphericalCoords;
|
|
27
|
+
/** Writes the point of the spherical coordinates `coords` with Z up into `out`. */
|
|
28
|
+
export declare function vec3FromSphericalZUp(out: Vec3, coords: ReadonlySphericalCoords): Vec3;
|
|
29
|
+
/**
|
|
30
|
+
* Writes the cylindrical coordinates of `a` with Y up into `out`: the distance
|
|
31
|
+
* from the Y axis, the azimuth `atan2(z, x)` and the height `y`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function cylindricalFromVec3YUp(out: CylindricalCoords, a: ReadonlyVec3): CylindricalCoords;
|
|
34
|
+
/**
|
|
35
|
+
* Writes the point of the cylindrical coordinates `coords` with Y up into
|
|
36
|
+
* `out`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function vec3FromCylindricalYUp(out: Vec3, coords: ReadonlyCylindricalCoords): Vec3;
|
|
39
|
+
/**
|
|
40
|
+
* Writes the cylindrical coordinates of `a` with Z up into `out`: the distance
|
|
41
|
+
* from the Z axis, the azimuth `atan2(y, x)` and the height `z`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function cylindricalFromVec3ZUp(out: CylindricalCoords, a: ReadonlyVec3): CylindricalCoords;
|
|
44
|
+
/**
|
|
45
|
+
* Writes the point of the cylindrical coordinates `coords` with Z up into
|
|
46
|
+
* `out`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function vec3FromCylindricalZUp(out: Vec3, coords: ReadonlyCylindricalCoords): Vec3;
|
|
49
|
+
//# sourceMappingURL=spherical-cylindrical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spherical-cylindrical.d.ts","sourceRoot":"","sources":["../../src/coordinates/spherical-cylindrical.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,IAAI,EAAc,MAAM,qBAAqB,CAAC;AAG/E,OAAO,KAAK,EACX,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACX,uBAAuB,EACvB,eAAe,EACf,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,eAAe,EACpB,CAAC,EAAE,YAAY,GACb,eAAe,CAQjB;AAED,mFAAmF;AACnF,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,uBAAuB,GAC7B,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,eAAe,EACpB,CAAC,EAAE,YAAY,GACb,eAAe,CAQjB;AAED,mFAAmF;AACnF,wBAAgB,oBAAoB,CACnC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,uBAAuB,GAC7B,IAAI,CASN;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,iBAAiB,EACtB,CAAC,EAAE,YAAY,GACb,iBAAiB,CAOnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,GAC/B,IAAI,CAON;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,iBAAiB,EACtB,CAAC,EAAE,YAAY,GACb,iBAAiB,CAOnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,yBAAyB,GAC/B,IAAI,CAON"}
|