@woosh/meep-engine 2.60.1 → 2.61.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/build/meep.cjs +20117 -20157
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +20117 -20157
- package/package.json +1 -1
- package/src/core/binary/BitSet.js +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +30 -182
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.spec.js +27 -1
- package/src/core/geom/ConicRay.js +16 -21
- package/src/core/geom/ConicRay.spec.js +24 -0
- package/src/core/geom/packing/miniball/Miniball.js +68 -117
- package/src/core/geom/packing/miniball/Miniball.spec.js +3 -3
- package/src/core/geom/packing/miniball/Subspan.js +47 -34
- package/src/core/geom/packing/miniball/miniball_compute_quality.js +64 -0
- package/src/core/math/bessel_3.js +1 -0
- package/src/core/math/random/randomBytes.js +2 -2
- package/src/core/math/sqr.js +8 -0
- package/src/core/model/node-graph/Connection.js +21 -23
- package/src/core/model/node-graph/DataType.js +16 -17
- package/src/core/model/node-graph/NodeGraph.js +49 -50
- package/src/core/model/node-graph/node/NodeDescription.js +42 -44
- package/src/core/model/node-graph/node/NodeInstance.js +59 -60
- package/src/core/model/node-graph/node/NodeInstancePortReference.js +27 -29
- package/src/core/model/node-graph/node/NodeRegistry.js +16 -18
- package/src/core/model/node-graph/node/Port.js +35 -37
- package/src/core/model/node-graph/node/parameter/NodeParameterDescription.js +27 -13
- package/src/core/path/computePathDirectory.spec.js +8 -0
- package/src/core/process/BaseProcess.d.ts +5 -0
- package/src/core/process/WatchDog.js +76 -75
- package/src/core/process/action/AsynchronousAction.js +24 -22
- package/src/core/process/executor/profile/Profile.js +34 -24
- package/src/core/process/executor/profile/TraceEvent.js +75 -75
- package/src/core/process/worker/OnDemandWorkerManager.js +27 -30
- package/src/core/process/worker/WorkerBuilder.js +149 -149
- package/src/core/process/worker/WorkerProxy.js +25 -21
- package/src/core/process/worker/extractTransferables.js +2 -2
- package/src/engine/Engine.js +58 -53
- package/src/engine/EngineConfiguration.d.ts +4 -4
- package/src/engine/ecs/EntityManager.js +517 -614
- package/src/engine/ecs/System.js +2 -2
- package/src/engine/ecs/transform/Transform.d.ts +7 -5
- package/src/engine/ecs/transform/Transform.js +30 -16
- package/src/engine/ecs/validateSystem.js +89 -0
- package/src/engine/graphics/GraphicsEngine.js +433 -483
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +46 -48
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +2 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +60 -62
- package/src/engine/graphics/ecs/water2/shader/testWaterShader.js +20 -22
- package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +156 -180
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +69 -71
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +51 -53
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +67 -69
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +56 -58
- package/src/engine/graphics/shadows/testShadowMapRendering.js +30 -34
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.spec.js +22 -20
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_linear.js +10 -13
- package/src/engine/graphics/texture/virtual/VirtualTexture.spec.js +1 -1
- package/src/engine/plugin/EnginePluginManager.d.ts +6 -1
- package/src/engine/ecs/components/ClingToHeightMap.js +0 -19
- package/src/engine/ecs/components/SynchronizePosition.js +0 -15
- package/src/engine/ecs/systems/ClingToHeightMapSystem.js +0 -170
- package/src/engine/ecs/systems/SynchronizePositionSystem.js +0 -43
|
@@ -6,23 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import {assert} from "../../../assert.js";
|
|
10
|
+
import {sqr} from "../../../math/sqr.js";
|
|
11
|
+
import {Subspan} from "./Subspan.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @returns {number[]}
|
|
14
|
+
* Small number
|
|
15
|
+
* @type {number}
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
const result = new Array(n);
|
|
19
|
-
|
|
20
|
-
for (let i = 0; i < n; i++) {
|
|
21
|
-
result[i] = 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
17
|
+
const Epsilon = 1.0E-14;
|
|
26
18
|
|
|
27
19
|
/**
|
|
28
20
|
* Limit to how many iterations algorithm is allowed to perform, this is to cover poorly converging cases
|
|
@@ -32,24 +24,32 @@ const MAX_ITERATIONS = 10000;
|
|
|
32
24
|
|
|
33
25
|
/**
|
|
34
26
|
* Computes the miniball of the given point set.
|
|
35
|
-
*
|
|
36
|
-
* Notice that the point set `pts` is assumed to be immutable during the computation. That
|
|
37
|
-
* is, if you add, remove, or change points in the point set, you have to create a new instance of
|
|
38
|
-
* {@link Miniball}.
|
|
39
|
-
*
|
|
40
|
-
* @param {PointSet} pts
|
|
41
|
-
* the point set
|
|
42
27
|
* @class
|
|
43
28
|
*/
|
|
44
|
-
class Miniball {
|
|
29
|
+
export class Miniball {
|
|
45
30
|
/**
|
|
31
|
+
* Notice that the point set `points` is assumed to be immutable during the computation.
|
|
32
|
+
* That is, if you add, remove, or change points in the point set, you have to create a new instance of {@link Miniball}.
|
|
46
33
|
*
|
|
47
|
-
* @param {PointSet}
|
|
34
|
+
* @param {PointSet} points the point set
|
|
48
35
|
*/
|
|
49
|
-
constructor(
|
|
36
|
+
constructor(points) {
|
|
37
|
+
assert.defined(points, 'points');
|
|
38
|
+
|
|
50
39
|
this.iteration = 0;
|
|
51
40
|
this.distToAff = 0;
|
|
52
41
|
this.distToAffSquare = 0;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* The squared radius of the miniball.
|
|
45
|
+
*
|
|
46
|
+
* This is equivalent to `radius() * radius()`.
|
|
47
|
+
*
|
|
48
|
+
* Precondition: `!isEmpty()`
|
|
49
|
+
*
|
|
50
|
+
* @type {number}
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
53
|
this.__squaredRadius = 0;
|
|
54
54
|
this.__radius = 0;
|
|
55
55
|
this.stopper = 0;
|
|
@@ -57,40 +57,46 @@ class Miniball {
|
|
|
57
57
|
/**
|
|
58
58
|
* @type {PointSet}
|
|
59
59
|
*/
|
|
60
|
-
this.S =
|
|
60
|
+
this.S = points;
|
|
61
61
|
|
|
62
62
|
this.__size = this.S.size();
|
|
63
63
|
|
|
64
|
+
const dimension_count = this.S.dimension();
|
|
65
|
+
|
|
64
66
|
/**
|
|
65
67
|
* Number of dimensions (2 for 2d, 3 for 3d etc.)
|
|
66
68
|
* @type {Number}
|
|
67
69
|
*/
|
|
68
|
-
this.dim =
|
|
70
|
+
this.dim = dimension_count;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
// pre-allocated continuous chunk of memory to make execution faster by reducing cache miss rate
|
|
74
|
+
const buffer = new ArrayBuffer(8 * (dimension_count * 4 + 1));
|
|
69
75
|
|
|
70
76
|
/**
|
|
71
77
|
*
|
|
72
|
-
* @type {number[]}
|
|
78
|
+
* @type {number[]|Float64Array}
|
|
73
79
|
* @private
|
|
74
80
|
*/
|
|
75
|
-
this.__center =
|
|
81
|
+
this.__center = new Float64Array(buffer, 0, dimension_count);
|
|
76
82
|
|
|
77
83
|
/**
|
|
78
84
|
*
|
|
79
|
-
* @type {number[]}
|
|
85
|
+
* @type {number[]|Float64Array}
|
|
80
86
|
*/
|
|
81
|
-
this.centerToAff =
|
|
87
|
+
this.centerToAff = new Float64Array(buffer, 8 * dimension_count, dimension_count);
|
|
82
88
|
|
|
83
89
|
/**
|
|
84
90
|
*
|
|
85
|
-
* @type {number[]}
|
|
91
|
+
* @type {number[]|Float64Array}
|
|
86
92
|
*/
|
|
87
|
-
this.centerToPoint =
|
|
93
|
+
this.centerToPoint = new Float64Array(buffer, 8 * 2 * dimension_count, dimension_count);
|
|
88
94
|
|
|
89
95
|
/**
|
|
90
96
|
*
|
|
91
|
-
* @type {number[]}
|
|
97
|
+
* @type {number[]|Float64Array}
|
|
92
98
|
*/
|
|
93
|
-
this.lambdas =
|
|
99
|
+
this.lambdas = new Float64Array(buffer, 8 * 3 * dimension_count, dimension_count + 1);
|
|
94
100
|
|
|
95
101
|
/**
|
|
96
102
|
*
|
|
@@ -102,7 +108,7 @@ class Miniball {
|
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
/**
|
|
105
|
-
* Whether
|
|
111
|
+
* Whether the miniball is the empty set, equivalently, whether `points.size() == 0`
|
|
106
112
|
* was true when this miniball instance was constructed.
|
|
107
113
|
*
|
|
108
114
|
* Notice that the miniball of a point set <i>S</i> is empty if and only if <i>S={}</i>.
|
|
@@ -125,27 +131,22 @@ class Miniball {
|
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
/**
|
|
128
|
-
* The
|
|
129
|
-
*
|
|
130
|
-
* This is equivalent to `radius() * radius()`.
|
|
134
|
+
* The Euclidean coordinates of the center of the miniball.
|
|
131
135
|
*
|
|
132
136
|
* Precondition: `!isEmpty()`
|
|
133
137
|
*
|
|
134
|
-
* @return {number} the
|
|
138
|
+
* @return {number[]} an array holding the coordinates of the center of the miniball
|
|
135
139
|
*/
|
|
136
|
-
|
|
137
|
-
return this.
|
|
140
|
+
center() {
|
|
141
|
+
return this.__center;
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
/**
|
|
141
|
-
* The Euclidean coordinates of the center of the miniball.
|
|
142
|
-
*
|
|
143
|
-
* Precondition: `!isEmpty()`
|
|
144
145
|
*
|
|
145
|
-
* @
|
|
146
|
+
* @returns {Subspan}
|
|
146
147
|
*/
|
|
147
|
-
|
|
148
|
-
return this.
|
|
148
|
+
get support() {
|
|
149
|
+
return this.__support;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
/**
|
|
@@ -159,20 +160,6 @@ class Miniball {
|
|
|
159
160
|
return this.__size;
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
/**
|
|
163
|
-
* TODO
|
|
164
|
-
*
|
|
165
|
-
* @return {*}
|
|
166
|
-
*/
|
|
167
|
-
support() {
|
|
168
|
-
throw new Error("Not implemented yet.");
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/*private*/
|
|
172
|
-
static sqr(x) {
|
|
173
|
-
return x * x;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
163
|
/**
|
|
177
164
|
* Sets up the search ball with an arbitrary point of <i>S</i> as center and with exactly one of
|
|
178
165
|
* the points farthest from center in the support. So the current ball contains all points of
|
|
@@ -205,7 +192,7 @@ class Miniball {
|
|
|
205
192
|
let dist = 0;
|
|
206
193
|
|
|
207
194
|
for (i = 0; i < dim; ++i) {
|
|
208
|
-
dist +=
|
|
195
|
+
dist += sqr(pointSet.coord(j, i) - center[i]);
|
|
209
196
|
}
|
|
210
197
|
|
|
211
198
|
if (dist >= this.__squaredRadius) {
|
|
@@ -226,13 +213,19 @@ class Miniball {
|
|
|
226
213
|
|
|
227
214
|
/*private*/
|
|
228
215
|
updateRadius() {
|
|
229
|
-
|
|
216
|
+
const any = this.__support.anyMember();
|
|
230
217
|
this.__squaredRadius = 0;
|
|
231
|
-
|
|
232
|
-
|
|
218
|
+
|
|
219
|
+
const dim = this.dim;
|
|
220
|
+
|
|
221
|
+
const center = this.__center;
|
|
222
|
+
const points = this.S;
|
|
223
|
+
|
|
224
|
+
for (let i = 0; i < dim; ++i) {
|
|
225
|
+
this.__squaredRadius += sqr(points.coord(any, i) - center[i]);
|
|
226
|
+
}
|
|
227
|
+
|
|
233
228
|
this.__radius = Math.sqrt(this.__squaredRadius);
|
|
234
|
-
//if (com.dreizak.miniball.highdim.Logging.log)
|
|
235
|
-
// com.dreizak.miniball.highdim.Logging.debug("current radius = " + this.__radius);
|
|
236
229
|
}
|
|
237
230
|
|
|
238
231
|
/**
|
|
@@ -253,18 +246,15 @@ class Miniball {
|
|
|
253
246
|
const centerToAff = this.centerToAff;
|
|
254
247
|
|
|
255
248
|
for (this.iteration = 0; this.iteration < MAX_ITERATIONS; this.iteration++) {
|
|
256
|
-
|
|
257
|
-
// com.dreizak.miniball.highdim.Logging.debug("Iteration " + this.iteration);
|
|
258
|
-
// com.dreizak.miniball.highdim.Logging.debug(this.__support.size() + " points on the boundary");
|
|
259
|
-
//}
|
|
249
|
+
|
|
260
250
|
this.computeDistToAff();
|
|
251
|
+
|
|
261
252
|
while (
|
|
262
|
-
this.distToAff <=
|
|
253
|
+
this.distToAff <= Epsilon * this.__radius
|
|
263
254
|
|| support.size() === dim + 1
|
|
264
255
|
) {
|
|
265
256
|
if (!this.successfulDrop()) {
|
|
266
|
-
//
|
|
267
|
-
// com.dreizak.miniball.highdim.Logging.info("Done");
|
|
257
|
+
// done
|
|
268
258
|
return;
|
|
269
259
|
}
|
|
270
260
|
this.computeDistToAff();
|
|
@@ -376,7 +366,7 @@ class Miniball {
|
|
|
376
366
|
dirPointProd += centerToAff[i] * centerToPoint[i];
|
|
377
367
|
}
|
|
378
368
|
|
|
379
|
-
if ((this.distToAffSquare - dirPointProd) < (
|
|
369
|
+
if ((this.distToAffSquare - dirPointProd) < (Epsilon * this.__radius * this.distToAff)) {
|
|
380
370
|
continue;
|
|
381
371
|
}
|
|
382
372
|
|
|
@@ -400,43 +390,9 @@ class Miniball {
|
|
|
400
390
|
return scale;
|
|
401
391
|
}
|
|
402
392
|
|
|
403
|
-
/**
|
|
404
|
-
* Verifies that the computed ball is indeed the miniball.
|
|
405
|
-
*
|
|
406
|
-
* This method should be called for testing purposes only; it may not be very efficient.
|
|
407
|
-
* @return {Quality}
|
|
408
|
-
*/
|
|
409
|
-
verify() {
|
|
410
|
-
let min_lambda = 1;
|
|
411
|
-
let max_overlength = 0;
|
|
412
|
-
let min_underlength = 0;
|
|
413
|
-
let ball_error;
|
|
414
|
-
let qr_error = this.__support.representationError();
|
|
415
|
-
this.__support.findAffineCoefficients(this.__center, this.lambdas);
|
|
416
|
-
for (let k = 0; k < this.__support.size(); ++k)
|
|
417
|
-
if (this.lambdas[k] <= min_lambda)
|
|
418
|
-
min_lambda = this.lambdas[k];
|
|
419
|
-
|
|
420
|
-
for (let k = 0; k < this.S.size(); ++k) {
|
|
421
|
-
for (let i = 0; i < this.dim; ++i)
|
|
422
|
-
this.centerToPoint[i] = this.S.coord(k, i) - this.__center[i];
|
|
423
|
-
let sqDist = 0;
|
|
424
|
-
for (let i = 0; i < this.dim; ++i)
|
|
425
|
-
sqDist += Miniball.sqr(this.centerToPoint[i]);
|
|
426
|
-
ball_error = Math.sqrt(sqDist) - this.__radius;
|
|
427
|
-
if (ball_error > max_overlength)
|
|
428
|
-
max_overlength = ball_error;
|
|
429
|
-
if (this.__support.isMember(k))
|
|
430
|
-
if (ball_error < min_underlength)
|
|
431
|
-
min_underlength = ball_error;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return new Quality(qr_error, min_lambda, max_overlength / this.__radius, Math.abs(min_underlength / this.__radius), this.iteration, this.__support.size());
|
|
435
|
-
}
|
|
436
393
|
|
|
437
394
|
/**
|
|
438
|
-
* Outputs information about the miniball
|
|
439
|
-
* {@link #verify()} (and as a consequence, {@link #toString()} is expensive to call).
|
|
395
|
+
* Outputs information about the miniball
|
|
440
396
|
* @return {string}
|
|
441
397
|
*/
|
|
442
398
|
toString() {
|
|
@@ -451,14 +407,9 @@ class Miniball {
|
|
|
451
407
|
s += (", ");
|
|
452
408
|
}
|
|
453
409
|
|
|
454
|
-
s += `), radius=${this.__radius}, squaredRadius=${this.__squaredRadius}
|
|
410
|
+
s += `), radius=${this.__radius}, squaredRadius=${this.__squaredRadius}`;
|
|
455
411
|
}
|
|
456
412
|
s += "]";
|
|
457
413
|
return s;
|
|
458
414
|
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
Miniball.Eps = 1.0E-14;
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
export { Miniball };
|
|
415
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {Miniball} from "./Miniball.js";
|
|
2
|
+
import {PointSet} from "./PointSet.js";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
test("empty point set in 1d", () => {
|
|
@@ -12,7 +12,7 @@ test("single point in 1d", () => {
|
|
|
12
12
|
|
|
13
13
|
const miniball = new Miniball(new PointSet(1, 1, [7]));
|
|
14
14
|
|
|
15
|
-
expect(miniball.center()).toEqual([7]);
|
|
15
|
+
expect(Array.from(miniball.center())).toEqual([7]);
|
|
16
16
|
expect(miniball.radius()).toEqual(0);
|
|
17
17
|
|
|
18
18
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @generated Generated from Java with JSweet 2.2.0-SNAPSHOT - http://www.jsweet.org
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {BitSet} from "../../../binary/BitSet.js";
|
|
9
9
|
|
|
10
10
|
export class Subspan {
|
|
11
11
|
/**
|
|
@@ -305,32 +305,38 @@ export class Subspan {
|
|
|
305
305
|
*
|
|
306
306
|
* Complexity: O(dim^2)
|
|
307
307
|
*
|
|
308
|
-
* @param {
|
|
309
|
-
* Euclidean coordinates of point <i>p</i>
|
|
310
|
-
* @
|
|
311
|
-
* the squared length of <i>w</i>
|
|
312
|
-
* @return {number}
|
|
308
|
+
* @param {number[]} p
|
|
309
|
+
* @param {number[]} w Euclidean coordinates of point <i>p</i>
|
|
310
|
+
* @return {number} the squared length of <i>w</i>
|
|
313
311
|
*/
|
|
314
312
|
shortestVectorToSpan(p, w) {
|
|
315
|
-
|
|
313
|
+
const o = this.origin();
|
|
316
314
|
|
|
317
315
|
const dim = this.dim;
|
|
318
316
|
|
|
319
317
|
const S = this.S;
|
|
318
|
+
|
|
320
319
|
for (let i = 0; i < dim; ++i) {
|
|
321
320
|
w[i] = S.coord(o, i) - p[i];
|
|
322
321
|
}
|
|
323
322
|
|
|
324
323
|
const Q = this.Q;
|
|
325
324
|
|
|
326
|
-
|
|
325
|
+
const r = this.r;
|
|
326
|
+
|
|
327
|
+
for (let j = 0; j < r; ++j) {
|
|
327
328
|
let scale = 0;
|
|
329
|
+
|
|
330
|
+
const QJ = Q[j];
|
|
331
|
+
|
|
328
332
|
for (let i = 0; i < dim; ++i) {
|
|
329
|
-
scale += w[i] *
|
|
333
|
+
scale += w[i] * QJ[i];
|
|
330
334
|
}
|
|
335
|
+
|
|
331
336
|
for (let i = 0; i < dim; ++i) {
|
|
332
|
-
w[i] -= scale *
|
|
337
|
+
w[i] -= scale * QJ[i];
|
|
333
338
|
}
|
|
339
|
+
|
|
334
340
|
}
|
|
335
341
|
|
|
336
342
|
let sl = 0;
|
|
@@ -348,37 +354,44 @@ export class Subspan {
|
|
|
348
354
|
* @return {number}
|
|
349
355
|
*/
|
|
350
356
|
representationError() {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
a.push(0);
|
|
361
|
-
return a;
|
|
362
|
-
})(this.dim);
|
|
357
|
+
|
|
358
|
+
const size = this.size();
|
|
359
|
+
|
|
360
|
+
const lambdas = new Float64Array(size);
|
|
361
|
+
|
|
362
|
+
const dim = this.dim;
|
|
363
|
+
|
|
364
|
+
const pt = new Float64Array(dim);
|
|
365
|
+
|
|
363
366
|
let max = 0;
|
|
364
|
-
|
|
365
|
-
for (let j = 0; j <
|
|
366
|
-
for (let i = 0; i <
|
|
367
|
+
|
|
368
|
+
for (let j = 0; j < size; ++j) {
|
|
369
|
+
for (let i = 0; i < dim; ++i) {
|
|
367
370
|
pt[i] = this.S.coord(this.globalIndex(j), i);
|
|
371
|
+
}
|
|
372
|
+
|
|
368
373
|
this.findAffineCoefficients(pt, lambdas);
|
|
369
|
-
|
|
370
|
-
|
|
374
|
+
|
|
375
|
+
let error = Math.abs(lambdas[j] - 1.0);
|
|
376
|
+
|
|
377
|
+
if (error > max) {
|
|
371
378
|
max = error;
|
|
379
|
+
}
|
|
380
|
+
|
|
372
381
|
for (let i = 0; i < j; ++i) {
|
|
373
|
-
error = Math.abs(lambdas[i]
|
|
374
|
-
if (error > max)
|
|
382
|
+
error = Math.abs(lambdas[i]);
|
|
383
|
+
if (error > max) {
|
|
375
384
|
max = error;
|
|
385
|
+
}
|
|
376
386
|
}
|
|
377
387
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
388
|
+
// skip over lambdas[j]
|
|
389
|
+
|
|
390
|
+
for (let i = j + 1; i < size; ++i) {
|
|
391
|
+
error = Math.abs(lambdas[i]);
|
|
392
|
+
if (error > max) {
|
|
381
393
|
max = error;
|
|
394
|
+
}
|
|
382
395
|
}
|
|
383
396
|
|
|
384
397
|
}
|
|
@@ -396,8 +409,8 @@ export class Subspan {
|
|
|
396
409
|
* Complexity: O(dim^2)
|
|
397
410
|
*
|
|
398
411
|
* Preconditions: c lies in the affine hull aff(M) and size() > 0.
|
|
399
|
-
* @param {
|
|
400
|
-
* @param {
|
|
412
|
+
* @param {number[]|Float64Array} p
|
|
413
|
+
* @param {number[]|Float64Array} lambdas
|
|
401
414
|
*/
|
|
402
415
|
findAffineCoefficients(p, lambdas) {
|
|
403
416
|
let o = this.origin();
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {sqr} from "../../../math/sqr.js";
|
|
2
|
+
import {Quality} from "./Quality.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Verifies that the computed ball is indeed the miniball.
|
|
6
|
+
*
|
|
7
|
+
* This method should be called for testing purposes only; it may not be very efficient.
|
|
8
|
+
* @param {Miniball} miniball
|
|
9
|
+
* @return {Quality}
|
|
10
|
+
*/
|
|
11
|
+
export function miniball_compute_quality(miniball) {
|
|
12
|
+
const support = miniball.support;
|
|
13
|
+
const points = miniball.S;
|
|
14
|
+
const center = miniball.center();
|
|
15
|
+
const dimension_count = miniball.dim;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
let min_lambda = 1;
|
|
19
|
+
let max_overlength = 0;
|
|
20
|
+
let min_underlength = 0;
|
|
21
|
+
let ball_error;
|
|
22
|
+
|
|
23
|
+
let qr_error = support.representationError();
|
|
24
|
+
|
|
25
|
+
support.findAffineCoefficients(center, miniball.lambdas);
|
|
26
|
+
|
|
27
|
+
for (let k = 0; k < support.size(); ++k) {
|
|
28
|
+
if (miniball.lambdas[k] <= min_lambda) {
|
|
29
|
+
min_lambda = miniball.lambdas[k];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (let k = 0; k < points.size(); ++k) {
|
|
34
|
+
|
|
35
|
+
for (let i = 0; i < dimension_count; ++i) {
|
|
36
|
+
miniball.centerToPoint[i] = points.coord(k, i) - center[i];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let sqDist = 0;
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < dimension_count; ++i) {
|
|
42
|
+
sqDist += sqr(miniball.centerToPoint[i]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ball_error = Math.sqrt(sqDist) - miniball.radius();
|
|
46
|
+
|
|
47
|
+
if (ball_error > max_overlength) {
|
|
48
|
+
max_overlength = ball_error;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (support.isMember(k) && ball_error < min_underlength) {
|
|
52
|
+
min_underlength = ball_error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return new Quality(
|
|
57
|
+
qr_error,
|
|
58
|
+
min_lambda,
|
|
59
|
+
max_overlength / miniball.radius(),
|
|
60
|
+
Math.abs(min_underlength / miniball.radius()),
|
|
61
|
+
miniball.iteration,
|
|
62
|
+
support.size()
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kaiser Bessel Function of third kind
|
|
3
3
|
* NOTE: this is an approximation, if input value is sufficiently large - results will be way off
|
|
4
|
+
* This is a Tylor series approximation
|
|
4
5
|
* @see https://www.shadertoy.com/view/wlf3RH
|
|
5
6
|
* @returns {number}
|
|
6
7
|
* @param {number} x
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {randomUint8} from "./randomUint8.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Fill array with random byte values (0..255 integers)
|
|
5
5
|
* @param {Uint8Array} result
|
|
6
6
|
* @param {number} result_offset
|
|
7
7
|
* @param {function():number} random
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {assert} from "../../assert.js";
|
|
2
|
+
import {noop} from "../../function/Functions.js";
|
|
3
|
+
import {objectKeyByValue} from "../object/objectKeyByValue.js";
|
|
4
|
+
import {PortDirection} from "./node/PortDirection.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -10,25 +10,23 @@ import { PortDirection } from "./node/PortDirection.js";
|
|
|
10
10
|
let id_counter = 0;
|
|
11
11
|
|
|
12
12
|
export class Connection {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.target = null;
|
|
31
|
-
}
|
|
13
|
+
/**
|
|
14
|
+
* @readonly
|
|
15
|
+
* @type {number}
|
|
16
|
+
*/
|
|
17
|
+
id = id_counter++;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {NodeInstancePortReference}
|
|
22
|
+
*/
|
|
23
|
+
source = null;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {NodeInstancePortReference}
|
|
28
|
+
*/
|
|
29
|
+
target = null;
|
|
32
30
|
|
|
33
31
|
/**
|
|
34
32
|
*
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {assert} from "../../assert.js";
|
|
2
2
|
|
|
3
3
|
export class DataType {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Unique integer identifier
|
|
7
|
+
* @type {number}
|
|
8
|
+
*/
|
|
9
|
+
id = 0;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Name is not guaranteed to be unique, it is intended mainly for debug purposes
|
|
13
|
+
* @type {string}
|
|
14
|
+
*/
|
|
15
|
+
name = "";
|
|
17
16
|
|
|
18
17
|
toString() {
|
|
19
18
|
return `DataType{ id=${this.id}, name='${this.name}' }`;
|
|
@@ -37,10 +36,10 @@ export class DataType {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
toJSON() {
|
|
40
|
-
return {
|
|
39
|
+
return {...this};
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
fromJSON({
|
|
42
|
+
fromJSON({id, name}) {
|
|
44
43
|
assert.isNonNegativeInteger(id, 'id');
|
|
45
44
|
assert.isString(name, 'name');
|
|
46
45
|
|
|
@@ -53,7 +52,7 @@ export class DataType {
|
|
|
53
52
|
* @param {*} j
|
|
54
53
|
* @returns {DataType}
|
|
55
54
|
*/
|
|
56
|
-
static fromJSON(j){
|
|
55
|
+
static fromJSON(j) {
|
|
57
56
|
const r = new DataType();
|
|
58
57
|
|
|
59
58
|
r.fromJSON(j);
|