@ac-kit/math-geometry 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/README.md +43 -3
- package/dist/_polygon3-cross.d.ts +23 -0
- package/dist/_polygon3-cross.d.ts.map +1 -0
- package/dist/_polygon3-cross.js +418 -0
- package/dist/_polygon3-cross.js.map +1 -0
- package/dist/_triangle3-cross.d.ts +66 -0
- package/dist/_triangle3-cross.d.ts.map +1 -0
- package/dist/_triangle3-cross.js +396 -0
- package/dist/_triangle3-cross.js.map +1 -0
- package/dist/line2.d.ts +4 -0
- package/dist/line2.d.ts.map +1 -1
- package/dist/line2.js +26 -5
- package/dist/line2.js.map +1 -1
- package/dist/mesh/_index-kernels-u16.d.ts +51 -9
- package/dist/mesh/_index-kernels-u16.d.ts.map +1 -1
- package/dist/mesh/_index-kernels-u16.js +905 -124
- package/dist/mesh/_index-kernels-u16.js.map +1 -1
- package/dist/mesh/_index-kernels-u32.d.ts +51 -9
- package/dist/mesh/_index-kernels-u32.d.ts.map +1 -1
- package/dist/mesh/_index-kernels-u32.js +905 -124
- package/dist/mesh/_index-kernels-u32.js.map +1 -1
- package/dist/mesh/mesh3-kernels.d.ts +56 -16
- package/dist/mesh/mesh3-kernels.d.ts.map +1 -1
- package/dist/mesh/mesh3-kernels.js +56 -16
- package/dist/mesh/mesh3-kernels.js.map +1 -1
- package/dist/plane3.d.ts +4 -3
- package/dist/plane3.d.ts.map +1 -1
- package/dist/plane3.js +18 -35
- package/dist/plane3.js.map +1 -1
- package/dist/polygon2.d.ts +54 -4
- package/dist/polygon2.d.ts.map +1 -1
- package/dist/polygon2.js +297 -7
- package/dist/polygon2.js.map +1 -1
- package/dist/polygon3.d.ts +19 -3
- package/dist/polygon3.d.ts.map +1 -1
- package/dist/polygon3.js +40 -16
- package/dist/polygon3.js.map +1 -1
- package/dist/quadtree.d.ts +40 -23
- package/dist/quadtree.d.ts.map +1 -1
- package/dist/quadtree.js +196 -119
- package/dist/quadtree.js.map +1 -1
- package/dist/segment2.d.ts +6 -1
- package/dist/segment2.d.ts.map +1 -1
- package/dist/segment2.js +20 -4
- package/dist/segment2.js.map +1 -1
- package/dist/triangle3.d.ts +20 -1
- package/dist/triangle3.d.ts.map +1 -1
- package/dist/triangle3.js +38 -18
- package/dist/triangle3.js.map +1 -1
- package/package.json +7 -7
package/dist/quadtree.d.ts
CHANGED
|
@@ -46,12 +46,14 @@ export type QuadtreeVisitor = Callable<[
|
|
|
46
46
|
*
|
|
47
47
|
* Aggregates (Barnes–Hut charge centres, collision radii, counts) are the
|
|
48
48
|
* caller's: allocate `Float64Array(tree.nodeCount() * k)` and fill it in
|
|
49
|
-
* `visitAfter`.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
49
|
+
* `visitAfter`. Storage is struct-of-arrays typed columns grown geometrically
|
|
50
|
+
* and reused, the root cell lives in a `Float64Array`, and every traversal runs
|
|
51
|
+
* on a preallocated typed-array stack; the visitor gets each cell as a box the
|
|
52
|
+
* traversal reuses rather than four numbers. So once the engine has optimised
|
|
53
|
+
* the calls and the columns have reached the size a workload needs, `assign`,
|
|
54
|
+
* `visit`, `visitAfter`, `find` and `forEachInBox` allocate 0 B. (A double the
|
|
55
|
+
* caller passes to `find` or `add` may still be boxed by the caller's own
|
|
56
|
+
* code.) Node numbers are dense (`0 … nodeCount() − 1`) and **valid until the
|
|
55
57
|
* next mutation** (`assign`, `add`, `remove`, `clear`); mutating the tree from
|
|
56
58
|
* inside a visitor is not supported. Queries and traversals may nest freely.
|
|
57
59
|
*
|
|
@@ -86,13 +88,23 @@ export declare class Quadtree {
|
|
|
86
88
|
private parents;
|
|
87
89
|
private children;
|
|
88
90
|
private nodes;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Root cell: minX, minY, maxX, maxY; NaN when empty. A typed array, so
|
|
93
|
+
* writing a bound never boxes a double.
|
|
94
|
+
*/
|
|
95
|
+
private readonly root;
|
|
96
|
+
/**
|
|
97
|
+
* Whether `root` holds a cell. A flag rather than a NaN test: an engine tier
|
|
98
|
+
* that calls `Number.isNaN` out of line boxes the double it passes.
|
|
99
|
+
*/
|
|
100
|
+
private hasRoot;
|
|
101
|
+
/** The point `cover` reaches, then the box `reroot` holds. */
|
|
102
|
+
private readonly target;
|
|
93
103
|
private readonly walks;
|
|
94
104
|
private walkDepth;
|
|
95
|
-
|
|
105
|
+
/** Nodes being freed by `remove`: `deadCount` of them. */
|
|
106
|
+
private dead;
|
|
107
|
+
private deadCount;
|
|
96
108
|
private readonly childKeys;
|
|
97
109
|
/** Live ids gathered for a re-rooting rebuild. */
|
|
98
110
|
private rebuildIds;
|
|
@@ -183,29 +195,33 @@ export declare class Quadtree {
|
|
|
183
195
|
private hasOtherChild;
|
|
184
196
|
/** The single child of `node`, or −1 when it has none or several. */
|
|
185
197
|
private onlyChild;
|
|
198
|
+
private pushDead;
|
|
186
199
|
/**
|
|
187
200
|
* Frees the nodes in `dead` in O(their number), keeping node numbers dense by
|
|
188
201
|
* moving the last live node into each hole.
|
|
189
202
|
*/
|
|
190
203
|
private releaseDead;
|
|
191
204
|
/**
|
|
192
|
-
* Grows the root cell until it holds
|
|
193
|
-
* as the doubled cell has the old root as an exact quadrant;
|
|
194
|
-
* tree is re-rooted on exactly representable edges and rebuilt.
|
|
205
|
+
* Grows the root cell until it holds the point in `target`: d3-quadtree's
|
|
206
|
+
* `cover`, as long as the doubled cell has the old root as an exact quadrant;
|
|
207
|
+
* otherwise the tree is re-rooted on exactly representable edges and rebuilt.
|
|
208
|
+
* The point comes through `target`, not as arguments: a call that is not
|
|
209
|
+
* inlined would box both doubles.
|
|
195
210
|
*/
|
|
196
211
|
private cover;
|
|
197
212
|
/**
|
|
198
|
-
* Doubles the root cell toward
|
|
199
|
-
* Refused when rounding would make the old root anything but
|
|
200
|
-
* quadrant as every traversal computes it: the existing cells
|
|
213
|
+
* Doubles the root cell toward the point in `target`, anchored on the
|
|
214
|
+
* opposite corner. Refused when rounding would make the old root anything but
|
|
215
|
+
* the new root's quadrant as every traversal computes it: the existing cells
|
|
216
|
+
* would move.
|
|
201
217
|
*/
|
|
202
218
|
private double;
|
|
203
219
|
/**
|
|
204
|
-
* Replaces the root by a square cell holding the closed box
|
|
205
|
-
* multiples of a quarter of its power-of-two
|
|
206
|
-
* representable; later doublings then stay exact
|
|
207
|
-
* about 2⁵⁰-fold or past the box's magnitude.
|
|
208
|
-
* ascending id order.
|
|
220
|
+
* Replaces the root by a square cell holding the closed box in `target` (loX,
|
|
221
|
+
* loY, hiX, hiY), whose edges are multiples of a quarter of its power-of-two
|
|
222
|
+
* size, every one exactly representable; later doublings then stay exact
|
|
223
|
+
* until the root has grown about 2⁵⁰-fold or past the box's magnitude.
|
|
224
|
+
* Reinserts the points, in ascending id order.
|
|
209
225
|
*/
|
|
210
226
|
private reroot;
|
|
211
227
|
/**
|
|
@@ -227,7 +243,8 @@ export declare class Quadtree {
|
|
|
227
243
|
private acquireWalk;
|
|
228
244
|
/**
|
|
229
245
|
* Branch and bound, nearest cell first; `walk.keys` holds each pending cell's
|
|
230
|
-
* distance.
|
|
246
|
+
* distance. The query is `walk.point` and the radius `walk.keys[0]`, not
|
|
247
|
+
* arguments: a call that is not inlined would box the doubles.
|
|
231
248
|
*/
|
|
232
249
|
private findWith;
|
|
233
250
|
private setRoot;
|
package/dist/quadtree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quadtree.d.ts","sourceRoot":"","sources":["../src/quadtree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"quadtree.d.ts","sourceRoot":"","sources":["../src/quadtree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAA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