@ac-kit/math-geometry 0.2.3 → 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 +217 -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
package/dist/size.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReadonlyVec2, ReadonlyVec3, Vec2, Vec3 } from "@ac-kit/math-linear";
|
|
2
|
+
/**
|
|
3
|
+
* Sizes are plain vectors (`Vec2`, `Vec3`): the width and height, or width,
|
|
4
|
+
* height and depth. The functions here are the ones that only make sense for a
|
|
5
|
+
* size.
|
|
6
|
+
*/
|
|
7
|
+
/** The width divided by the height. */
|
|
8
|
+
export declare function size2AspectRatio(size: ReadonlyVec2): number;
|
|
9
|
+
/** The area, `width × height`. */
|
|
10
|
+
export declare function size2Area(size: ReadonlyVec2): number;
|
|
11
|
+
/** Whether `size` fits inside `container` on both axes (equal sizes fit). */
|
|
12
|
+
export declare function size2Contains(container: ReadonlyVec2, size: ReadonlyVec2): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether both extents are within `tolerance` of zero.
|
|
15
|
+
*
|
|
16
|
+
* @param tolerance Absolute, in the caller's units; defaults to `0` (exactly
|
|
17
|
+
* zero).
|
|
18
|
+
*/
|
|
19
|
+
export declare function size2IsZero(size: ReadonlyVec2, tolerance?: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Writes into `out` `size` scaled uniformly by the largest factor that makes it
|
|
22
|
+
* fit inside `container`. A zero extent in `size` gives non-finite results.
|
|
23
|
+
* `out` may be `size` or `container`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function size2ScaleToFit(out: Vec2, size: ReadonlyVec2, container: ReadonlyVec2): Vec2;
|
|
26
|
+
/**
|
|
27
|
+
* Writes into `out` `size` scaled uniformly by the smallest factor that makes
|
|
28
|
+
* it cover `container`. A zero extent in `size` gives non-finite results. `out`
|
|
29
|
+
* may be `size` or `container`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function size2ScaleToFill(out: Vec2, size: ReadonlyVec2, container: ReadonlyVec2): Vec2;
|
|
32
|
+
/**
|
|
33
|
+
* Writes into `out` `size` scaled uniformly by the largest factor that makes it
|
|
34
|
+
* fit inside `container`. A zero extent in `size` gives non-finite results.
|
|
35
|
+
* `out` may be `size` or `container`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function size3ScaleToFit(out: Vec3, size: ReadonlyVec3, container: ReadonlyVec3): Vec3;
|
|
38
|
+
/** The volume, `width × height × depth`. */
|
|
39
|
+
export declare function size3Volume(size: ReadonlyVec3): number;
|
|
40
|
+
//# sourceMappingURL=size.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../src/size.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AAEH,uCAAuC;AACvC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAE3D;AAED,kCAAkC;AAClC,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEpD;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAC5B,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,YAAY,GAChB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,SAAI,GAAG,OAAO,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,YAAY,GACrB,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,YAAY,GACrB,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,YAAY,GACrB,IAAI,CAaN;AAED,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEtD"}
|
package/dist/size.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sizes are plain vectors (`Vec2`, `Vec3`): the width and height, or width,
|
|
3
|
+
* height and depth. The functions here are the ones that only make sense for a
|
|
4
|
+
* size.
|
|
5
|
+
*/
|
|
6
|
+
/** The width divided by the height. */
|
|
7
|
+
export function size2AspectRatio(size) {
|
|
8
|
+
return size[0] / size[1];
|
|
9
|
+
}
|
|
10
|
+
/** The area, `width × height`. */
|
|
11
|
+
export function size2Area(size) {
|
|
12
|
+
return size[0] * size[1];
|
|
13
|
+
}
|
|
14
|
+
/** Whether `size` fits inside `container` on both axes (equal sizes fit). */
|
|
15
|
+
export function size2Contains(container, size) {
|
|
16
|
+
return size[0] <= container[0] && size[1] <= container[1];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether both extents are within `tolerance` of zero.
|
|
20
|
+
*
|
|
21
|
+
* @param tolerance Absolute, in the caller's units; defaults to `0` (exactly
|
|
22
|
+
* zero).
|
|
23
|
+
*/
|
|
24
|
+
export function size2IsZero(size, tolerance = 0) {
|
|
25
|
+
return Math.abs(size[0]) <= tolerance && Math.abs(size[1]) <= tolerance;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Writes into `out` `size` scaled uniformly by the largest factor that makes it
|
|
29
|
+
* fit inside `container`. A zero extent in `size` gives non-finite results.
|
|
30
|
+
* `out` may be `size` or `container`.
|
|
31
|
+
*/
|
|
32
|
+
export function size2ScaleToFit(out, size, container) {
|
|
33
|
+
const scale = Math.min(container[0] / size[0], container[1] / size[1]);
|
|
34
|
+
const width = size[0] * scale;
|
|
35
|
+
const height = size[1] * scale;
|
|
36
|
+
out[0] = width;
|
|
37
|
+
out[1] = height;
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Writes into `out` `size` scaled uniformly by the smallest factor that makes
|
|
42
|
+
* it cover `container`. A zero extent in `size` gives non-finite results. `out`
|
|
43
|
+
* may be `size` or `container`.
|
|
44
|
+
*/
|
|
45
|
+
export function size2ScaleToFill(out, size, container) {
|
|
46
|
+
const scale = Math.max(container[0] / size[0], container[1] / size[1]);
|
|
47
|
+
const width = size[0] * scale;
|
|
48
|
+
const height = size[1] * scale;
|
|
49
|
+
out[0] = width;
|
|
50
|
+
out[1] = height;
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Writes into `out` `size` scaled uniformly by the largest factor that makes it
|
|
55
|
+
* fit inside `container`. A zero extent in `size` gives non-finite results.
|
|
56
|
+
* `out` may be `size` or `container`.
|
|
57
|
+
*/
|
|
58
|
+
export function size3ScaleToFit(out, size, container) {
|
|
59
|
+
const scale = Math.min(container[0] / size[0], container[1] / size[1], container[2] / size[2]);
|
|
60
|
+
const width = size[0] * scale;
|
|
61
|
+
const height = size[1] * scale;
|
|
62
|
+
const depth = size[2] * scale;
|
|
63
|
+
out[0] = width;
|
|
64
|
+
out[1] = height;
|
|
65
|
+
out[2] = depth;
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** The volume, `width × height × depth`. */
|
|
69
|
+
export function size3Volume(size) {
|
|
70
|
+
return size[0] * size[1] * size[2];
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=size.js.map
|
package/dist/size.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.js","sourceRoot":"","sources":["../src/size.ts"],"names":[],"mappings":"AAOA;;;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AAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,WAAW,CAAC,IAAkB;IAC7C,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReadonlySphere3, Sphere3 } from "./sphere3-record.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a buffer for `count` spheres: a zero-filled `Float64Array` of `count
|
|
4
|
+
* × 4` numbers, element `i` at `[i·4, i·4 + 4)`. Allocates.
|
|
5
|
+
*
|
|
6
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
7
|
+
* `count × 4` is not a valid typed array length.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sphere3ArrayCreate(count: number): Float64Array<ArrayBuffer>;
|
|
10
|
+
/**
|
|
11
|
+
* Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
|
|
12
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
13
|
+
* end of `array` gives `NaN`, never `undefined`: the sphere stays clean
|
|
14
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
15
|
+
* layer.
|
|
16
|
+
*
|
|
17
|
+
* The sphere is copied: it is never a view of `array`. O(1).
|
|
18
|
+
*/
|
|
19
|
+
export declare function sphere3Load(out: Sphere3, array: Float64Array, index: number): Sphere3;
|
|
20
|
+
/**
|
|
21
|
+
* Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
|
|
22
|
+
* An element past the end of `array` writes nothing, as a typed array drops an
|
|
23
|
+
* out-of-range write. O(1).
|
|
24
|
+
*/
|
|
25
|
+
export declare function sphere3Store(array: Float64Array, index: number, value: ReadonlySphere3): void;
|
|
26
|
+
/**
|
|
27
|
+
* Like {@link sphere3Load} for interleaved data: element `index` starts at
|
|
28
|
+
* `offset + index·stride`, both counted in numbers, and its 4 components follow
|
|
29
|
+
* one another. An index past the end gives `NaN` components. O(1).
|
|
30
|
+
*/
|
|
31
|
+
export declare function sphere3LoadStrided(out: Sphere3, array: Float64Array, offset: number, stride: number, index: number): Sphere3;
|
|
32
|
+
/**
|
|
33
|
+
* Like {@link sphere3Store} for interleaved data: element `index` starts at
|
|
34
|
+
* `offset + index·stride`, both counted in numbers. A component past the end of
|
|
35
|
+
* `array` writes nothing. O(1).
|
|
36
|
+
*/
|
|
37
|
+
export declare function sphere3StoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlySphere3): void;
|
|
38
|
+
/**
|
|
39
|
+
* Narrows `value` to binary32 and writes its 4 components into `array` from
|
|
40
|
+
* element `offset` on, unrolled: the way to stage a bounds or instance value
|
|
41
|
+
* for the GPU, where `array.set` costs several times as much for one value. A
|
|
42
|
+
* component past the end of `array` writes nothing. O(1).
|
|
43
|
+
*/
|
|
44
|
+
export declare function sphere3StoreFloat32(array: Float32Array, offset: number, value: ReadonlySphere3): void;
|
|
45
|
+
/**
|
|
46
|
+
* Whether every number of `array` is finite: the check for a buffer of sphere3
|
|
47
|
+
* elements read from untrusted data or about to be uploaded. The length is not
|
|
48
|
+
* required to be a multiple of 4. O(n).
|
|
49
|
+
*/
|
|
50
|
+
export declare function sphere3ArrayIsFinite(array: Float64Array): boolean;
|
|
51
|
+
//# sourceMappingURL=sphere3-array-boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sphere3-array-boundary.d.ts","sourceRoot":"","sources":["../src/sphere3-array-boundary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAG3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAC1B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,GACX,OAAO,CAQT;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,GACpB,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,OAAO,CAQT;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,eAAe,GACpB,IAAI,CAMN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,GACpB,IAAI,CAKN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAUjE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Generated from scripts/templates/array-boundary.liquid by scripts/generate-records.ts. Do not edit.
|
|
2
|
+
import { assertInteger } from "@ac-kit/core";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a buffer for `count` spheres: a zero-filled `Float64Array` of `count
|
|
5
|
+
* × 4` numbers, element `i` at `[i·4, i·4 + 4)`. Allocates.
|
|
6
|
+
*
|
|
7
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
8
|
+
* `count × 4` is not a valid typed array length.
|
|
9
|
+
*/
|
|
10
|
+
export function sphere3ArrayCreate(count) {
|
|
11
|
+
assertInteger(count, "sphere3ArrayCreate: count", 0);
|
|
12
|
+
return new Float64Array(count * 4);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
|
|
16
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
17
|
+
* end of `array` gives `NaN`, never `undefined`: the sphere stays clean
|
|
18
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
19
|
+
* layer.
|
|
20
|
+
*
|
|
21
|
+
* The sphere is copied: it is never a view of `array`. O(1).
|
|
22
|
+
*/
|
|
23
|
+
export function sphere3Load(out, array, index) {
|
|
24
|
+
const base = index * 4;
|
|
25
|
+
// The `!` is for the compiler: past the end `+undefined` is `NaN`.
|
|
26
|
+
out[0] = +array[base];
|
|
27
|
+
out[1] = +array[base + 1];
|
|
28
|
+
out[2] = +array[base + 2];
|
|
29
|
+
out[3] = +array[base + 3];
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
|
|
34
|
+
* An element past the end of `array` writes nothing, as a typed array drops an
|
|
35
|
+
* out-of-range write. O(1).
|
|
36
|
+
*/
|
|
37
|
+
export function sphere3Store(array, index, value) {
|
|
38
|
+
const base = index * 4;
|
|
39
|
+
array[base] = value[0];
|
|
40
|
+
array[base + 1] = value[1];
|
|
41
|
+
array[base + 2] = value[2];
|
|
42
|
+
array[base + 3] = value[3];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Like {@link sphere3Load} for interleaved data: element `index` starts at
|
|
46
|
+
* `offset + index·stride`, both counted in numbers, and its 4 components follow
|
|
47
|
+
* one another. An index past the end gives `NaN` components. O(1).
|
|
48
|
+
*/
|
|
49
|
+
export function sphere3LoadStrided(out, array, offset, stride, index) {
|
|
50
|
+
const base = offset + index * stride;
|
|
51
|
+
// The `!` is for the compiler: past the end `+undefined` is `NaN`.
|
|
52
|
+
out[0] = +array[base];
|
|
53
|
+
out[1] = +array[base + 1];
|
|
54
|
+
out[2] = +array[base + 2];
|
|
55
|
+
out[3] = +array[base + 3];
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Like {@link sphere3Store} for interleaved data: element `index` starts at
|
|
60
|
+
* `offset + index·stride`, both counted in numbers. A component past the end of
|
|
61
|
+
* `array` writes nothing. O(1).
|
|
62
|
+
*/
|
|
63
|
+
export function sphere3StoreStrided(array, offset, stride, index, value) {
|
|
64
|
+
const base = offset + index * stride;
|
|
65
|
+
array[base] = value[0];
|
|
66
|
+
array[base + 1] = value[1];
|
|
67
|
+
array[base + 2] = value[2];
|
|
68
|
+
array[base + 3] = value[3];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Narrows `value` to binary32 and writes its 4 components into `array` from
|
|
72
|
+
* element `offset` on, unrolled: the way to stage a bounds or instance value
|
|
73
|
+
* for the GPU, where `array.set` costs several times as much for one value. A
|
|
74
|
+
* component past the end of `array` writes nothing. O(1).
|
|
75
|
+
*/
|
|
76
|
+
export function sphere3StoreFloat32(array, offset, value) {
|
|
77
|
+
array[offset] = value[0];
|
|
78
|
+
array[offset + 1] = value[1];
|
|
79
|
+
array[offset + 2] = value[2];
|
|
80
|
+
array[offset + 3] = value[3];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Whether every number of `array` is finite: the check for a buffer of sphere3
|
|
84
|
+
* elements read from untrusted data or about to be uploaded. The length is not
|
|
85
|
+
* required to be a multiple of 4. O(n).
|
|
86
|
+
*/
|
|
87
|
+
export function sphere3ArrayIsFinite(array) {
|
|
88
|
+
// A loop, not `array.every(Number.isFinite)`: measured at 0.5–0.7 ms against
|
|
89
|
+
// 4.1 ms per million numbers on Node (the callback is not inlined), and the
|
|
90
|
+
// check runs on every upload of an untrusted buffer.
|
|
91
|
+
for (let index = 0; index < array.length; index++) {
|
|
92
|
+
if (!Number.isFinite(array[index])) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=sphere3-array-boundary.js.map
|
|
@@ -0,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AC;IACzB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAmB;IACvD,6EAA6E;IAC7E,4EAA4E;IAC5E,qDAAqD;IACrD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Brand_ } from "./_brand.js";
|
|
2
|
+
/**
|
|
3
|
+
* A sphere (a ball, for the containment tests): its centre then its radius, the
|
|
4
|
+
* layout of a GPU `vec4` bounds entry. A negative radius makes the sphere
|
|
5
|
+
* empty.
|
|
6
|
+
*
|
|
7
|
+
* A plain array of 4 binary64 numbers carrying a type-level brand, holding
|
|
8
|
+
* exactly the numbers one element of the matching bulk buffer holds, in the
|
|
9
|
+
* same order.
|
|
10
|
+
*
|
|
11
|
+
* Only {@link sphere3Create}, {@link sphere3Of}, {@link sphere3Clone},
|
|
12
|
+
* {@link sphere3FromArray} 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 Sphere3 = [
|
|
17
|
+
centerX: number,
|
|
18
|
+
centerY: number,
|
|
19
|
+
centerZ: number,
|
|
20
|
+
radius: number
|
|
21
|
+
] & Brand_<"Sphere3">;
|
|
22
|
+
/** A {@link Sphere3} that is only read. */
|
|
23
|
+
export type ReadonlySphere3 = readonly [
|
|
24
|
+
centerX: number,
|
|
25
|
+
centerY: number,
|
|
26
|
+
centerZ: number,
|
|
27
|
+
radius: number
|
|
28
|
+
] & Brand_<"Sphere3">;
|
|
29
|
+
/**
|
|
30
|
+
* Creates the sphere of radius 0 at the origin.
|
|
31
|
+
*
|
|
32
|
+
* Allocates; keep it out of hot loops.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sphere3Create(): Sphere3;
|
|
35
|
+
/**
|
|
36
|
+
* Creates the sphere with the components `centerX, centerY, centerZ, radius`,
|
|
37
|
+
* in storage order.
|
|
38
|
+
*
|
|
39
|
+
* Allocates; keep it out of hot loops.
|
|
40
|
+
*/
|
|
41
|
+
export declare function sphere3Of(centerX: number, centerY: number, centerZ: number, radius: number): Sphere3;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
44
|
+
*
|
|
45
|
+
* Allocates; keep it out of hot loops.
|
|
46
|
+
*/
|
|
47
|
+
export declare function sphere3Clone(a: ReadonlySphere3): Sphere3;
|
|
48
|
+
/** Writes the components, in storage order, into `out`. */
|
|
49
|
+
export declare function sphere3Set(out: Sphere3, centerX: number, centerY: number, centerZ: number, radius: number): Sphere3;
|
|
50
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
51
|
+
export declare function sphere3Copy(out: Sphere3, a: ReadonlySphere3): Sphere3;
|
|
52
|
+
/**
|
|
53
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
54
|
+
* included, and an infinity equals itself. See {@link sphere3IsClose} for a
|
|
55
|
+
* tolerant test.
|
|
56
|
+
*/
|
|
57
|
+
export declare function sphere3Equals(a: ReadonlySphere3, b: ReadonlySphere3): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
60
|
+
* `tolerance`, an absolute bound in the caller's units, and an infinity is
|
|
61
|
+
* close only to itself. Not transitive, so never a basis for ordering or a
|
|
62
|
+
* container key: use {@link sphere3Equals} there.
|
|
63
|
+
*
|
|
64
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function sphere3IsClose(a: ReadonlySphere3, b: ReadonlySphere3, tolerance?: number): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
69
|
+
* origin): `source[offset … offset + 4)` copied into `out`, each element that
|
|
70
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
71
|
+
* `out` never holds a non-number. A cold path: buffers use {@link sphere3Load}.
|
|
72
|
+
* O(1).
|
|
73
|
+
*
|
|
74
|
+
* `source` may be `out` itself: the 4 elements are read before the first write.
|
|
75
|
+
*
|
|
76
|
+
* @param out The sphere to fill.
|
|
77
|
+
* @param source The array to read, of any length and any content.
|
|
78
|
+
* @param offset The index of the first component in `source`.
|
|
79
|
+
* @returns `out`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function sphere3FromArray(out: Sphere3, source: ArrayLike<number>, offset?: number): Sphere3;
|
|
82
|
+
/**
|
|
83
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
84
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
85
|
+
* that is not a number at all counts as not finite.
|
|
86
|
+
*/
|
|
87
|
+
export declare function sphere3IsFinite(value: ReadonlySphere3): boolean;
|
|
88
|
+
//# sourceMappingURL=sphere3-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sphere3-record.d.ts","sourceRoot":"","sources":["../src/sphere3-record.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,OAAO,GAAG;IACrB,OAAO,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T;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAO/D"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Generated from scripts/templates/record.liquid by scripts/generate-records.ts. Do not edit.
|
|
2
|
+
import { isCloseAbsolute, numberAtOrNaN } from "@ac-kit/core";
|
|
3
|
+
import { geometryConfig } from "./globals.js";
|
|
4
|
+
/**
|
|
5
|
+
* Every creator copies this array, which holds non-integer doubles and is never
|
|
6
|
+
* exposed: nothing a caller does can change the element kind it copies.
|
|
7
|
+
*/
|
|
8
|
+
const TEMPLATE_ = [0.5, 0.5, 0.5, 0.5];
|
|
9
|
+
/**
|
|
10
|
+
* Creates the sphere of radius 0 at the origin.
|
|
11
|
+
*
|
|
12
|
+
* Allocates; keep it out of hot loops.
|
|
13
|
+
*/
|
|
14
|
+
export function sphere3Create() {
|
|
15
|
+
const out = TEMPLATE_.slice();
|
|
16
|
+
out[0] = 0;
|
|
17
|
+
out[1] = 0;
|
|
18
|
+
out[2] = 0;
|
|
19
|
+
out[3] = 0;
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates the sphere with the components `centerX, centerY, centerZ, radius`,
|
|
24
|
+
* in storage order.
|
|
25
|
+
*
|
|
26
|
+
* Allocates; keep it out of hot loops.
|
|
27
|
+
*/
|
|
28
|
+
export function sphere3Of(centerX, centerY, centerZ, radius) {
|
|
29
|
+
const out = TEMPLATE_.slice();
|
|
30
|
+
out[0] = centerX;
|
|
31
|
+
out[1] = centerY;
|
|
32
|
+
out[2] = centerZ;
|
|
33
|
+
out[3] = radius;
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
38
|
+
*
|
|
39
|
+
* Allocates; keep it out of hot loops.
|
|
40
|
+
*/
|
|
41
|
+
export function sphere3Clone(a) {
|
|
42
|
+
const out = TEMPLATE_.slice();
|
|
43
|
+
out[0] = a[0];
|
|
44
|
+
out[1] = a[1];
|
|
45
|
+
out[2] = a[2];
|
|
46
|
+
out[3] = a[3];
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/** Writes the components, in storage order, into `out`. */
|
|
50
|
+
export function sphere3Set(out, centerX, centerY, centerZ, radius) {
|
|
51
|
+
out[0] = centerX;
|
|
52
|
+
out[1] = centerY;
|
|
53
|
+
out[2] = centerZ;
|
|
54
|
+
out[3] = radius;
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
58
|
+
export function sphere3Copy(out, a) {
|
|
59
|
+
out[0] = a[0];
|
|
60
|
+
out[1] = a[1];
|
|
61
|
+
out[2] = a[2];
|
|
62
|
+
out[3] = a[3];
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
67
|
+
* included, and an infinity equals itself. See {@link sphere3IsClose} for a
|
|
68
|
+
* tolerant test.
|
|
69
|
+
*/
|
|
70
|
+
export function sphere3Equals(a, b) {
|
|
71
|
+
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
75
|
+
* `tolerance`, an absolute bound in the caller's units, and an infinity is
|
|
76
|
+
* close only to itself. Not transitive, so never a basis for ordering or a
|
|
77
|
+
* container key: use {@link sphere3Equals} there.
|
|
78
|
+
*
|
|
79
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
80
|
+
*/
|
|
81
|
+
export function sphere3IsClose(a, b, tolerance = geometryConfig.defaultLinearTolerance) {
|
|
82
|
+
return (isCloseAbsolute(a[0], b[0], tolerance) &&
|
|
83
|
+
isCloseAbsolute(a[1], b[1], tolerance) &&
|
|
84
|
+
isCloseAbsolute(a[2], b[2], tolerance) &&
|
|
85
|
+
isCloseAbsolute(a[3], b[3], tolerance));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The checked way in from untyped data (JSON, messages, arrays of unknown
|
|
89
|
+
* origin): `source[offset … offset + 4)` copied into `out`, each element that
|
|
90
|
+
* is not a number written as `NaN`, an index past the end of `source` too, so
|
|
91
|
+
* `out` never holds a non-number. A cold path: buffers use {@link sphere3Load}.
|
|
92
|
+
* O(1).
|
|
93
|
+
*
|
|
94
|
+
* `source` may be `out` itself: the 4 elements are read before the first write.
|
|
95
|
+
*
|
|
96
|
+
* @param out The sphere to fill.
|
|
97
|
+
* @param source The array to read, of any length and any content.
|
|
98
|
+
* @param offset The index of the first component in `source`.
|
|
99
|
+
* @returns `out`.
|
|
100
|
+
*/
|
|
101
|
+
export function sphere3FromArray(out, source, offset = 0) {
|
|
102
|
+
const value0 = numberAtOrNaN(source, offset);
|
|
103
|
+
const value1 = numberAtOrNaN(source, offset + 1);
|
|
104
|
+
const value2 = numberAtOrNaN(source, offset + 2);
|
|
105
|
+
const value3 = numberAtOrNaN(source, offset + 3);
|
|
106
|
+
out[0] = value0;
|
|
107
|
+
out[1] = value1;
|
|
108
|
+
out[2] = value2;
|
|
109
|
+
out[3] = value3;
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether every component is a finite number: the check to run after parsing
|
|
114
|
+
* untrusted data or before an upload, as operations never check. A component
|
|
115
|
+
* that is not a number at all counts as not finite.
|
|
116
|
+
*/
|
|
117
|
+
export function sphere3IsFinite(value) {
|
|
118
|
+
return (Number.isFinite(value[0]) &&
|
|
119
|
+
Number.isFinite(value[1]) &&
|
|
120
|
+
Number.isFinite(value[2]) &&
|
|
121
|
+
Number.isFinite(value[3]));
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=sphere3-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sphere3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ACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACzB,CAAC;AACH,CAAC"}
|
package/dist/sphere3.d.ts
CHANGED
|
@@ -1,13 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare function
|
|
1
|
+
import type { ReadonlyAffine3, ReadonlyVec3 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { Box3, ReadonlyBox3 } from "./box3-record.js";
|
|
3
|
+
import type { ReadonlySphere3, Sphere3 } from "./sphere3-record.js";
|
|
4
|
+
/** The surface area, `4 π r²`; `0` for a negative radius (an empty sphere). */
|
|
5
|
+
export declare function sphere3SurfaceArea(sphere: ReadonlySphere3): number;
|
|
6
|
+
/** The volume, `4/3 π r³`; `0` for a negative radius. */
|
|
7
|
+
export declare function sphere3Volume(sphere: ReadonlySphere3): number;
|
|
8
|
+
/**
|
|
9
|
+
* Whether `point` lies in the ball, boundary included: exact, `|p − c|² ≤ r²`.
|
|
10
|
+
* A negative radius contains nothing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sphere3ContainsPoint(sphere: ReadonlySphere3, point: ReadonlyVec3): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the two balls share a point, boundaries included. A negative radius
|
|
15
|
+
* intersects nothing.
|
|
16
|
+
*/
|
|
17
|
+
export declare function sphere3IntersectsSphere3(a: ReadonlySphere3, b: ReadonlySphere3): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the ball and the box share a point, boundaries included. An empty box
|
|
20
|
+
* or a negative radius intersects nothing.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sphere3IntersectsBox3(sphere: ReadonlySphere3, box: ReadonlyBox3): boolean;
|
|
23
|
+
/** Writes `sphere` moved by `offset` into `out`. `out` may be `sphere`. */
|
|
24
|
+
export declare function sphere3Translate(out: Sphere3, sphere: ReadonlySphere3, offset: ReadonlyVec3): Sphere3;
|
|
25
|
+
/**
|
|
26
|
+
* Writes the sphere moved by `transform` into `out`: the centre transformed,
|
|
27
|
+
* the radius times an upper bound of the largest scale of the linear part `A`
|
|
28
|
+
* (its spectral norm). The bound is `√min(‖AᵀA‖∞, tr AᵀA)`: both the largest
|
|
29
|
+
* absolute row sum of the Gram matrix and its trace bound its largest
|
|
30
|
+
* eigenvalue, so the sphere holds the image of the original for any transform,
|
|
31
|
+
* shears included (the longest column alone does not). It is exact for a
|
|
32
|
+
* rotation with a uniform or an axis-aligned scale (up to rounding), and within
|
|
33
|
+
* a factor √3 of the best otherwise. `out` may be `sphere`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function sphere3TransformAffine3(out: Sphere3, sphere: ReadonlySphere3, transform: ReadonlyAffine3): Sphere3;
|
|
36
|
+
/**
|
|
37
|
+
* Writes an approximate bounding sphere of the points of `points` (three
|
|
38
|
+
* numbers each) into `out`, by Ritter's method: within about 5–20 % of the
|
|
39
|
+
* smallest enclosing sphere, never smaller than it, and every point inside. An
|
|
40
|
+
* empty buffer gives the empty sphere (centre at the origin, radius `−∞`). Two
|
|
41
|
+
* passes, O(n).
|
|
42
|
+
*
|
|
43
|
+
* @throws {RangeError} When `points.length` is not a multiple of 3.
|
|
44
|
+
*/
|
|
45
|
+
export declare function sphere3FromPoints(out: Sphere3, points: Float64Array): Sphere3;
|
|
46
|
+
/**
|
|
47
|
+
* Writes the sphere through the corners of `box` into `out`; an empty box gives
|
|
48
|
+
* the empty sphere (radius `−∞`).
|
|
49
|
+
*/
|
|
50
|
+
export declare function sphere3FromBox3(out: Sphere3, box: ReadonlyBox3): Sphere3;
|
|
51
|
+
/**
|
|
52
|
+
* Writes the smallest box holding the sphere into `out`; a negative radius
|
|
53
|
+
* gives an empty box.
|
|
54
|
+
*/
|
|
55
|
+
export declare function sphere3BoundingBox(out: Box3, sphere: ReadonlySphere3): Box3;
|
|
13
56
|
//# sourceMappingURL=sphere3.d.ts.map
|
package/dist/sphere3.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sphere3.d.ts","sourceRoot":"","sources":["../src/sphere3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sphere3.d.ts","sourceRoot":"","sources":["../src/sphere3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEpE,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAGlE;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAG7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,YAAY,GACjB,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACvC,CAAC,EAAE,eAAe,EAClB,CAAC,EAAE,eAAe,GAChB,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,YAAY,GACf,OAAO,CAYT;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,YAAY,GAClB,OAAO,CAOT;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,eAAe,EACvB,SAAS,EA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