@woosh/meep-engine 2.120.0 → 2.120.1
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/README.md +1 -1
- package/package.json +1 -1
- package/src/core/binary/FLOAT32_MAX.d.ts +2 -0
- package/src/core/binary/FLOAT32_MAX.d.ts.map +1 -0
- package/src/core/binary/FLOAT32_MAX.js +1 -0
- package/src/core/collection/RingBuffer.d.ts +2 -3
- package/src/core/collection/RingBuffer.d.ts.map +1 -1
- package/src/core/collection/RingBuffer.js +9 -4
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +15 -1
- package/src/core/geom/Vector4.d.ts.map +1 -1
- package/src/core/geom/Vector4.js +32 -0
- package/src/core/geom/mat2/M2_IDENTITY.d.ts +6 -0
- package/src/core/geom/mat2/M2_IDENTITY.d.ts.map +1 -0
- package/src/core/geom/mat2/M2_IDENTITY.js +8 -0
- package/src/core/geom/mat2/m2_is_diagonal.d.ts +8 -0
- package/src/core/geom/mat2/m2_is_diagonal.d.ts.map +1 -0
- package/src/core/geom/mat2/m2_is_diagonal.js +9 -0
- package/src/core/geom/mat2/m2_is_orthogonal.d.ts +8 -0
- package/src/core/geom/mat2/m2_is_orthogonal.d.ts.map +1 -0
- package/src/core/geom/mat2/m2_is_orthogonal.js +23 -0
- package/src/core/geom/mat2/m2_transpose.d.ts +9 -0
- package/src/core/geom/mat2/m2_transpose.d.ts.map +1 -0
- package/src/core/geom/mat2/m2_transpose.js +17 -0
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts +7 -5
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_adjacency_matrix.js +11 -5
- package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -1
- package/src/core/graph/graph_compute_distance_matrix.js +30 -56
- package/src/core/graph/graph_compute_laplacian_matrix.d.ts +6 -6
- package/src/core/graph/graph_compute_laplacian_matrix.js +6 -6
- package/src/core/json/abstractJSONDeserializer.d.ts.map +1 -1
- package/src/core/json/abstractJSONDeserializer.js +7 -1
- package/src/core/math/bell_membership_function.d.ts.map +1 -1
- package/src/core/math/bell_membership_function.js +6 -1
- package/src/core/math/linalg/m2/m2_polar_decomp.d.ts +19 -0
- package/src/core/math/linalg/m2/m2_polar_decomp.d.ts.map +1 -0
- package/src/core/math/linalg/m2/m2_polar_decomp.js +27 -0
- package/src/core/math/linalg/m2/m2_polar_decomp_noS.d.ts +15 -0
- package/src/core/math/linalg/m2/m2_polar_decomp_noS.d.ts.map +1 -0
- package/src/core/math/linalg/m2/m2_polar_decomp_noS.js +32 -0
- package/src/core/math/linalg/m2/m2_svd.d.ts +19 -0
- package/src/core/math/linalg/m2/m2_svd.d.ts.map +1 -0
- package/src/core/math/linalg/m2/m2_svd.js +96 -0
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +1 -1
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +1 -1
- package/src/core/model/node-graph/node/NodeDescription.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeDescription.js +14 -0
- package/src/core/model/node-graph/type/DataType.d.ts.map +1 -1
- package/src/core/model/node-graph/type/DataType.js +4 -0
- package/src/core/process/WatchDog.d.ts +41 -12
- package/src/core/process/WatchDog.d.ts.map +1 -1
- package/src/core/process/WatchDog.js +47 -16
- package/src/engine/development/performance/RingBufferMetric.d.ts +1 -1
- package/src/engine/development/performance/RingBufferMetric.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationAdapter.js +3 -3
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationUpgrader_0_1.d.ts +4 -0
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSerializationUpgrader_0_1.js +24 -0
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +3 -9
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.d.ts.map +1 -1
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +14 -8
- package/src/engine/ecs/transform/Transform.d.ts +5 -1
- package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
- package/src/engine/ecs/transform/Transform.js +5 -1
- package/src/engine/intelligence/blackboard/BlackboardStack.d.ts +1 -1
- package/src/engine/intelligence/blackboard/BlackboardStack.js +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.d.ts.map +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationAdapter.js +3 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_2_3.d.ts.map +1 -1
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_2_3.js +3 -7
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.d.ts +5 -0
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.d.ts.map +1 -0
- package/src/engine/navigation/ecs/path_following/PathFollowerSerializationUpgrader_3_4.js +19 -0
- package/src/engine/physics/mls-mpm/MLS_MPM.d.ts +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.js +9 -114
- package/src/engine/physics/mls-mpm/README.md +5 -0
- package/src/engine/physics/ammo/Body.js +0 -103
- package/src/engine/physics/ammo/PhysicsWorker.d.ts +0 -72
- package/src/engine/physics/ammo/PhysicsWorker.d.ts.map +0 -1
- package/src/engine/physics/ammo/PhysicsWorker.js +0 -437
- package/src/engine/physics/ammo/World.d.ts +0 -68
- package/src/engine/physics/ammo/World.d.ts.map +0 -1
- package/src/engine/physics/ammo/World.js +0 -336
- package/src/engine/physics/ammo/shapes/BoxShape.d.ts +0 -10
- package/src/engine/physics/ammo/shapes/BoxShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/BoxShape.js +0 -11
- package/src/engine/physics/ammo/shapes/CapsuleShape.d.ts +0 -9
- package/src/engine/physics/ammo/shapes/CapsuleShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/CapsuleShape.js +0 -10
- package/src/engine/physics/ammo/shapes/MeshShape.d.ts +0 -8
- package/src/engine/physics/ammo/shapes/MeshShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/MeshShape.js +0 -9
- package/src/engine/physics/ammo/shapes/PlaneShape.d.ts +0 -11
- package/src/engine/physics/ammo/shapes/PlaneShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/PlaneShape.js +0 -14
- package/src/engine/physics/ammo/shapes/Shape.d.ts +0 -7
- package/src/engine/physics/ammo/shapes/Shape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/Shape.js +0 -9
- package/src/engine/physics/ammo/shapes/SphereShape.d.ts +0 -8
- package/src/engine/physics/ammo/shapes/SphereShape.d.ts.map +0 -1
- package/src/engine/physics/ammo/shapes/SphereShape.js +0 -9
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.d.ts +0 -15
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.d.ts.map +0 -1
- package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +0 -196
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ To help get you started, various samples are provided under `/samples` folder. F
|
|
|
13
13
|
|
|
14
14
|
## Quality
|
|
15
15
|
|
|
16
|
-
Meep is covered by 2,
|
|
16
|
+
Meep is covered by 2,458 unit tests
|
|
17
17
|
|
|
18
18
|
The aim is not to have 100% coverage, [but to ensure quality](https://about.codecov.io/blog/the-case-against-100-code-coverage/). As a result, the tests are written to cover complex code first and to exhaustively validate critical algorithms.
|
|
19
19
|
Most of the test code is significantly larger than the code that is being tested.
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FLOAT32_MAX.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/FLOAT32_MAX.js"],"names":[],"mappings":"AAAA,0BAA2B,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FLOAT32_MAX = 3.4028234663852886e+38;
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* Fixed-sized container structure, where ends are connected into a circle/ring
|
|
3
3
|
* This is a FIFO structure (first in, first out)
|
|
4
4
|
* @see https://en.wikipedia.org/wiki/Circular_buffer
|
|
5
|
+
* @template V
|
|
5
6
|
*/
|
|
6
|
-
export class RingBuffer {
|
|
7
|
+
export class RingBuffer<V> {
|
|
7
8
|
/**
|
|
8
|
-
* @template V
|
|
9
9
|
* @param {number} size
|
|
10
|
-
* @constructor
|
|
11
10
|
*/
|
|
12
11
|
constructor(size: number);
|
|
13
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RingBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/collection/RingBuffer.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"RingBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/collection/RingBuffer.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAFa,CAAC;IAGV;;OAEG;IACH,kBAFW,MAAM,EAoChB;IA7BG;;;OAGG;IACH,MAFU,MAAM,CAEA;IAEhB;;;OAGG;IACH,MAFU,MAAM,CAEH;IAEb;;;OAGG;IACH,MAFU,MAAM,CAEH;IAEb;;;OAGG;IACH,OAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,MAFU,CAAC,EAAE,CAEc;IAG/B;;;OAGG;IACH,iBAFW,MAAM,QAsBhB;IAED;;;OAGG;IACH,WAFY,CAAC,CAIZ;IAED;;;;OAIG;IACH,oBAHW,MAAM,GACJ,CAAC,CAUb;IAED,cAIC;IAED;;;OAGG;IACH,cAFW,CAAC,QAuBX;IAED;;;OAGG;IACH,SAFa,CAAC,GAAC,SAAS,CAcvB;IAED;;;OAGG;IACH,4BAFW,MAAM,QA8BhB;IAED;;;;;OAKG;IACH,oBAJW,CAAS,IAAC,EAAD,CAAC,KAAE,OAAO,YACnB,GAAC,GACC,CAAC,GAAC,SAAS,CAoBvB;IAED;;;;OAIG;IACH,iBAHW,CAAS,IAAC,EAAD,CAAC,QAAC,YACX,GAAC,QAgBX;IAED;;;;OAIG;IACH,gBAHW,CAAC,GACC,OAAO,CAInB;CACJ"}
|
|
@@ -5,12 +5,11 @@ import { min2 } from "../math/min2.js";
|
|
|
5
5
|
* Fixed-sized container structure, where ends are connected into a circle/ring
|
|
6
6
|
* This is a FIFO structure (first in, first out)
|
|
7
7
|
* @see https://en.wikipedia.org/wiki/Circular_buffer
|
|
8
|
+
* @template V
|
|
8
9
|
*/
|
|
9
10
|
export class RingBuffer {
|
|
10
11
|
/**
|
|
11
|
-
* @template V
|
|
12
12
|
* @param {number} size
|
|
13
|
-
* @constructor
|
|
14
13
|
*/
|
|
15
14
|
constructor(size) {
|
|
16
15
|
assert.isNumber(size, 'size');
|
|
@@ -59,6 +58,10 @@ export class RingBuffer {
|
|
|
59
58
|
return;
|
|
60
59
|
}
|
|
61
60
|
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @type {V[]}
|
|
64
|
+
*/
|
|
62
65
|
const array = new Array(new_size);
|
|
63
66
|
|
|
64
67
|
this.data = array;
|
|
@@ -158,17 +161,19 @@ export class RingBuffer {
|
|
|
158
161
|
const tail = this.tail;
|
|
159
162
|
const count = this.count;
|
|
160
163
|
|
|
164
|
+
const data = this.data;
|
|
165
|
+
|
|
161
166
|
for (let i = index; i < count; i++) {
|
|
162
167
|
const p = tail + i;
|
|
163
168
|
|
|
164
169
|
const j = (p) % size;
|
|
165
170
|
const k = (p + 1) % size;
|
|
166
171
|
|
|
167
|
-
|
|
172
|
+
data[j] = data[k];
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
// Clear the last element (important for GC if holding objects)
|
|
171
|
-
|
|
176
|
+
data[(tail + count - 1) % size] = undefined;
|
|
172
177
|
|
|
173
178
|
// update head and handle underflow
|
|
174
179
|
this.head = (this.head - 1 + size) % size;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../../src/core/color/Color.js"],"names":[],"mappings":"AAmBA;;;GAGG;AACH;
|
|
1
|
+
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../../src/core/color/Color.js"],"names":[],"mappings":"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"}
|
package/src/core/color/Color.js
CHANGED
|
@@ -63,7 +63,7 @@ export class Color {
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* @readonly
|
|
66
|
-
* @type {Signal<number,number,number,number,number,number,number,number>}
|
|
66
|
+
* @type {Signal<number,number,number,number, number,number,number,number>}
|
|
67
67
|
*/
|
|
68
68
|
this.onChanged = new Signal();
|
|
69
69
|
}
|
|
@@ -575,6 +575,20 @@ export class Color {
|
|
|
575
575
|
this.set(r, g, b, a);
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
/**
|
|
579
|
+
*
|
|
580
|
+
* @param {number[]|Float32Array} source
|
|
581
|
+
* @param {number} [offset]
|
|
582
|
+
* @returns {Color}
|
|
583
|
+
*/
|
|
584
|
+
static fromArray(source, offset){
|
|
585
|
+
const r = new Color();
|
|
586
|
+
|
|
587
|
+
r.fromArray(source,offset);
|
|
588
|
+
|
|
589
|
+
return r;
|
|
590
|
+
}
|
|
591
|
+
|
|
578
592
|
|
|
579
593
|
/**
|
|
580
594
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vector4.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector4.js"],"names":[],"mappings":";AAMA;
|
|
1
|
+
{"version":3,"file":"Vector4.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Vector4.js"],"names":[],"mappings":";AAMA;IA2YI;;;;;;OAMG;IACH,gBALW,OAAO,MACP,OAAO,qBAEP,OAAO,QASjB;IAxZD;;;;;;;;OAQG;IACH,4DAOC;IANG,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IAEV,eAA6B;IAOjC;;;OAGG;IACH,SAFW,MAAM,EAIhB;IAVD,SAMW,MAAM,CAJhB;IAcD;;;OAGG;IACH,SAFW,MAAM,EAIhB;IAVD,SAMW,MAAM,CAJhB;IAcD;;;OAGG;IACH,SAFW,MAAM,EAIhB;IAVD,SAMW,MAAM,CAJhB;IAcD;;;OAGG;IACH,SAFW,MAAM,EAIhB;IAVD,SAMW,MAAM,CAJhB;IAUD;;;;OAIG;IACH,qBAHW,MAAM,EAAE,WACR,MAAM,QAShB;IAED;;;;OAIG;IACH,oBAHW,MAAM,EAAE,WACR,MAAM,QAOhB;IAED;;;;;;;OAOG;IACH,iDAFa,OAAO,CAkCnB;IAED;;;OAGG;IACH,oBAFW,OAAO,QAQjB;IAED;;;;OAIG;IACH,+BAFa,OAAO,CAOnB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,kBAlBW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAoBnB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,MAAM,CAIlB;IAED;;;;OAIG;IACH,SAHW,OAAO,GAAC,OAAO,GACb,OAAO,CASnB;IAED;;;;OAIG;IACH,qBAHW,OAAO,GACL,OAAO,CAUnB;IAED;;;;OAIG;IACH,WAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,SAFa,OAAO,CAQnB;IAED;;;OAGG;IACH,mBAFW,UAAU,QAyBpB;IAED;;;;OAIG;IACH,aAHW,OAAO,GACL,OAAO,CAInB;IAED;;;OAGG;IACH,QAFY,MAAM,CASjB;IAED;;;;OAIG;IACH,gBAJW,OAAO,MACP,OAAO,mBAKjB;IAED;;;OAGG;IACH,gBAFW,MAAM,EAAE,QAOlB;IAED;;OAEG;IACH,WAFa,MAAM,EAAE,CAQpB;IAED;;;;OAIG;IACH,mBAHW,MAAM,EAAE,UACR,MAAM,QAIhB;IAED;;;;;MAOC;IAED,0BAEC;IAED;;;OAGG;IACH,uBAFW,YAAY,QAOtB;IAED;;;OAGG;IACH,yBAFW,YAAY,QAStB;IAED,sDAOC;CAiBJ"}
|
package/src/core/geom/Vector4.js
CHANGED
|
@@ -27,18 +27,50 @@ class Vector4 {
|
|
|
27
27
|
return this.x;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {number} v
|
|
33
|
+
*/
|
|
34
|
+
set 0(v) {
|
|
35
|
+
this.x = v;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
get 1() {
|
|
31
39
|
return this.y;
|
|
32
40
|
}
|
|
33
41
|
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param {number} v
|
|
45
|
+
*/
|
|
46
|
+
set 1(v) {
|
|
47
|
+
this.y = v;
|
|
48
|
+
}
|
|
49
|
+
|
|
34
50
|
get 2() {
|
|
35
51
|
return this.z;
|
|
36
52
|
}
|
|
37
53
|
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param {number} v
|
|
57
|
+
*/
|
|
58
|
+
set 2(v) {
|
|
59
|
+
this.z = v;
|
|
60
|
+
}
|
|
61
|
+
|
|
38
62
|
get 3() {
|
|
39
63
|
return this.w;
|
|
40
64
|
}
|
|
41
65
|
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {number} v
|
|
69
|
+
*/
|
|
70
|
+
set 3(v) {
|
|
71
|
+
this.w = v;
|
|
72
|
+
}
|
|
73
|
+
|
|
42
74
|
/**
|
|
43
75
|
*
|
|
44
76
|
* @param {number[]} array
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"M2_IDENTITY.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/mat2/M2_IDENTITY.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,0BAFU,QAAQ,CAAC,MAAM,EAAE,CAAC,CAKzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m2_is_diagonal.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/mat2/m2_is_diagonal.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,kCAJW,MAAM,EAAE,cACR,MAAM,GACJ,OAAO,CAInB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if m * m^T is close to the identity matrix.
|
|
3
|
+
* @param {number[]} m
|
|
4
|
+
* @param {number} [tolerance]
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export function m2_is_orthogonal(m: number[], tolerance?: number): boolean;
|
|
8
|
+
//# sourceMappingURL=m2_is_orthogonal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m2_is_orthogonal.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/mat2/m2_is_orthogonal.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,oCAJW,MAAM,EAAE,cACR,MAAM,GACJ,OAAO,CAenB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { m2_multiply } from "./m2_multiply.js";
|
|
2
|
+
import { m2_transpose } from "./m2_transpose.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Check if m * m^T is close to the identity matrix.
|
|
6
|
+
* @param {number[]} m
|
|
7
|
+
* @param {number} [tolerance]
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function m2_is_orthogonal(m, tolerance = 1e-6) {
|
|
11
|
+
|
|
12
|
+
const mt = m2_transpose([], m);
|
|
13
|
+
const m_mt = [];
|
|
14
|
+
|
|
15
|
+
m2_multiply(m_mt, m, mt);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
Math.abs(m_mt[0] - 1) < tolerance &&
|
|
19
|
+
Math.abs(m_mt[1]) < tolerance &&
|
|
20
|
+
Math.abs(m_mt[2]) < tolerance &&
|
|
21
|
+
Math.abs(m_mt[3] - 1) < tolerance
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transposes a 2x2 matrix, stored in a flattened array.
|
|
3
|
+
*
|
|
4
|
+
* @param {number[]} out Output: The transposed matrix. Can be the same array as `m`.
|
|
5
|
+
* @param {number[]} m Input: The 2x2 matrix to transpose, stored as a flattened array [a, b, c, d], representing [[a, c], [b, d]].
|
|
6
|
+
* @returns {number[]} The `out` parameter.
|
|
7
|
+
*/
|
|
8
|
+
export function m2_transpose(out: number[], m: number[]): number[];
|
|
9
|
+
//# sourceMappingURL=m2_transpose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m2_transpose.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/mat2/m2_transpose.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,kCAJW,MAAM,EAAE,KACR,MAAM,EAAE,GACN,MAAM,EAAE,CAWpB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transposes a 2x2 matrix, stored in a flattened array.
|
|
3
|
+
*
|
|
4
|
+
* @param {number[]} out Output: The transposed matrix. Can be the same array as `m`.
|
|
5
|
+
* @param {number[]} m Input: The 2x2 matrix to transpose, stored as a flattened array [a, b, c, d], representing [[a, c], [b, d]].
|
|
6
|
+
* @returns {number[]} The `out` parameter.
|
|
7
|
+
*/
|
|
8
|
+
export function m2_transpose(out, m) {
|
|
9
|
+
const b = m[1]; // Cache m[1] (which becomes m[2] after the swap)
|
|
10
|
+
|
|
11
|
+
out[0] = m[0];
|
|
12
|
+
out[1] = m[2];
|
|
13
|
+
out[2] = b; // Use the cached value
|
|
14
|
+
out[3] = m[3];
|
|
15
|
+
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @param {
|
|
2
|
+
* Computes the adjacency matrix of a graph.
|
|
3
|
+
* Writes 1 to matrix elements where nodes are connected, leaves existing values where there are no connections.
|
|
4
|
+
* Does NOT zero-fill the matrix before writing.
|
|
5
|
+
* @template T Type of the graph's nodes.
|
|
6
|
+
* @param {Graph<T>} graph Input graph.
|
|
7
|
+
* @param {SquareMatrix} result Output: Adjacency matrix (modified in-place).
|
|
8
|
+
* @param {Map<T,number>} node_indices Map from graph nodes to matrix indices.
|
|
7
9
|
*/
|
|
8
10
|
export function graph_compute_adjacency_matrix<T>(graph: Graph<T>, result: SquareMatrix, node_indices: Map<T, number>): void;
|
|
9
11
|
//# sourceMappingURL=graph_compute_adjacency_matrix.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph_compute_adjacency_matrix.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/graph_compute_adjacency_matrix.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph_compute_adjacency_matrix.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/graph_compute_adjacency_matrix.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,+CALa,CAAC,SACH,KAAK,CAAC,CAAC,CAAC,UACR,YAAY,gBACZ,GAAG,CAAC,CAAC,EAAC,MAAM,CAAC,QAevB"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { assert } from "../assert.js";
|
|
1
2
|
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @param {
|
|
5
|
+
* Computes the adjacency matrix of a graph.
|
|
6
|
+
* Writes 1 to matrix elements where nodes are connected, leaves existing values where there are no connections.
|
|
7
|
+
* Does NOT zero-fill the matrix before writing.
|
|
8
|
+
* @template T Type of the graph's nodes.
|
|
9
|
+
* @param {Graph<T>} graph Input graph.
|
|
10
|
+
* @param {SquareMatrix} result Output: Adjacency matrix (modified in-place).
|
|
11
|
+
* @param {Map<T,number>} node_indices Map from graph nodes to matrix indices.
|
|
9
12
|
*/
|
|
10
13
|
export function graph_compute_adjacency_matrix(graph, result, node_indices) {
|
|
11
14
|
const edges = graph.getEdges();
|
|
@@ -14,6 +17,9 @@ export function graph_compute_adjacency_matrix(graph, result, node_indices) {
|
|
|
14
17
|
const a = node_indices.get(edge.first);
|
|
15
18
|
const b = node_indices.get(edge.second);
|
|
16
19
|
|
|
20
|
+
assert.isNonNegativeInteger(a, 'a');
|
|
21
|
+
assert.isNonNegativeInteger(b, 'b');
|
|
22
|
+
|
|
17
23
|
result.setCellValue(a, b, 1);
|
|
18
24
|
result.setCellValue(b, a, 1);
|
|
19
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph_compute_distance_matrix.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/graph_compute_distance_matrix.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph_compute_distance_matrix.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/graph_compute_distance_matrix.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,8CAPa,CAAC,SACH,KAAK,CAAC,CAAC,CAAC,cACR,CAAC,EAAE,WACH,MAAM,EAAE,kBACR,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,GACZ,YAAY,CAgExB;6BA1E4B,gCAAgC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BitSet } from "../binary/BitSet.js";
|
|
2
1
|
import { BinaryDataType } from "../binary/type/BinaryDataType.js";
|
|
3
|
-
import
|
|
2
|
+
import { Deque } from "../collection/queue/Deque.js";
|
|
4
3
|
import { SquareMatrix } from "../math/matrix/SquareMatrix.js";
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -18,86 +17,61 @@ export function graph_compute_distance_matrix(graph, node_array, targets, node_i
|
|
|
18
17
|
|
|
19
18
|
const m_distances = new SquareMatrix(node_count, BinaryDataType.Float32);
|
|
20
19
|
|
|
21
|
-
const flags = BitSet.fixedSize(node_count);
|
|
22
|
-
|
|
23
20
|
// initialize distances
|
|
24
21
|
m_distances.fill(Number.POSITIVE_INFINITY);
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
// fill diagonal
|
|
24
|
+
for (let i = 0; i < node_count; i++) {
|
|
25
|
+
// Distance to self is 0
|
|
26
|
+
m_distances.setCellValue(i, i, 0);
|
|
27
|
+
}
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
*
|
|
30
|
-
* @
|
|
31
|
-
* @returns {number}
|
|
31
|
+
* @type {Deque<number>}
|
|
32
32
|
*/
|
|
33
|
-
|
|
34
|
-
return m_distances.getCellValue(source_node, other_node);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
for (let i = 0; i < targets.length; i++) {
|
|
38
|
-
source_node = targets[i];
|
|
39
|
-
|
|
40
|
-
// distance to self is always 0
|
|
41
|
-
m_distances.setCellValue(source_node, source_node, 0);
|
|
33
|
+
const queue = new Deque();
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
heap.push(source_node);
|
|
35
|
+
for (const target_index of targets) {
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
const t = heap.pop();
|
|
37
|
+
queue.addLast(target_index);
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (let v = 0; v < node_count; v++) {
|
|
53
|
-
const shortcut_distance = distance_to_this_node + m_distances.getCellValue(t, v);
|
|
39
|
+
while (!queue.isEmpty()) {
|
|
40
|
+
const index_1 = queue.removeFirst();
|
|
41
|
+
const node_1 = node_array[index_1];
|
|
54
42
|
|
|
55
|
-
|
|
56
|
-
m_distances.setCellValue(source_node, v, shortcut_distance)
|
|
57
|
-
}
|
|
43
|
+
const node_1_container = graph.getNodeContainer(node_1);
|
|
58
44
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// not visited yet
|
|
62
|
-
const t_node = node_array[t];
|
|
63
|
-
|
|
64
|
-
const t_node_container = graph.getNodeContainer(t_node);
|
|
45
|
+
const edges = node_1_container.getEdges();
|
|
46
|
+
const edge_count = edges.length;
|
|
65
47
|
|
|
66
|
-
|
|
67
|
-
const node_edge_count = node_edges.length;
|
|
48
|
+
for (let i = 0; i < edge_count; i++) {
|
|
68
49
|
|
|
69
|
-
|
|
50
|
+
const edge = edges[i];
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
* @type {WeightedEdge<N>}
|
|
74
|
-
*/
|
|
75
|
-
const node_edge = node_edges[i1];
|
|
52
|
+
const node_0 = edge.other(node_1);
|
|
76
53
|
|
|
77
|
-
|
|
54
|
+
if (!edge.validateTransition(node_0, node_1)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
78
57
|
|
|
79
|
-
|
|
58
|
+
const index_0 = node_index_map.get(node_0);
|
|
80
59
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
60
|
+
// If we haven't visited this neighbor yet, its distance is the current distance + 1
|
|
61
|
+
if (m_distances.getCellValue(index_0, target_index) === Number.POSITIVE_INFINITY) {
|
|
85
62
|
|
|
86
|
-
const transition_cost =
|
|
63
|
+
const transition_cost = edge.weight;
|
|
87
64
|
|
|
88
|
-
const
|
|
65
|
+
const new_distance = m_distances.getCellValue(index_1, target_index) + transition_cost;
|
|
89
66
|
|
|
90
|
-
|
|
91
|
-
m_distances.setCellValue(source_node, neighbour_node_index, distance_to_neighbour);
|
|
67
|
+
m_distances.setCellValue(index_0, target_index, new_distance);
|
|
92
68
|
|
|
93
|
-
|
|
94
|
-
}
|
|
69
|
+
queue.addLast(index_0);
|
|
95
70
|
}
|
|
96
71
|
}
|
|
97
72
|
}
|
|
98
|
-
|
|
99
|
-
flags.set(source_node, true);
|
|
100
73
|
}
|
|
101
74
|
|
|
75
|
+
|
|
102
76
|
return m_distances;
|
|
103
77
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Laplacian matrix
|
|
3
|
-
*
|
|
4
|
-
* @template T
|
|
5
|
-
* @param {Graph<T>} graph
|
|
6
|
-
* @param {SquareMatrix} result
|
|
7
|
-
* @param {Map<T,number>} node_indices
|
|
2
|
+
* Computes the Laplacian matrix of a graph.
|
|
3
|
+
* Does NOT clear the matrix before writing.
|
|
4
|
+
* @template T Type of graph nodes.
|
|
5
|
+
* @param {Graph<T>} graph Input graph.
|
|
6
|
+
* @param {SquareMatrix} result Output: Laplacian matrix (modified in-place).
|
|
7
|
+
* @param {Map<T,number>} node_indices Map from graph nodes to matrix indices.
|
|
8
8
|
*/
|
|
9
9
|
export function graph_compute_laplacian_matrix<T>(graph: Graph<T>, result: SquareMatrix, node_indices: Map<T, number>): void;
|
|
10
10
|
import { SquareMatrix } from "../math/matrix/SquareMatrix.js";
|
|
@@ -4,12 +4,12 @@ import { graph_compute_adjacency_matrix } from "./graph_compute_adjacency_matrix
|
|
|
4
4
|
import { graph_compute_degree_matrix } from "./graph_compute_degree_matrix.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Laplacian matrix
|
|
8
|
-
*
|
|
9
|
-
* @template T
|
|
10
|
-
* @param {Graph<T>} graph
|
|
11
|
-
* @param {SquareMatrix} result
|
|
12
|
-
* @param {Map<T,number>} node_indices
|
|
7
|
+
* Computes the Laplacian matrix of a graph.
|
|
8
|
+
* Does NOT clear the matrix before writing.
|
|
9
|
+
* @template T Type of graph nodes.
|
|
10
|
+
* @param {Graph<T>} graph Input graph.
|
|
11
|
+
* @param {SquareMatrix} result Output: Laplacian matrix (modified in-place).
|
|
12
|
+
* @param {Map<T,number>} node_indices Map from graph nodes to matrix indices.
|
|
13
13
|
*/
|
|
14
14
|
export function graph_compute_laplacian_matrix(graph, result, node_indices) {
|
|
15
15
|
const degree = new SquareMatrix(result.size, BinaryDataType.Uint8);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractJSONDeserializer.d.ts","sourceRoot":"","sources":["../../../../src/core/json/abstractJSONDeserializer.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yCAJa,CAAC,QACH,CAAC,iBACD,GAAG,CAAC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"abstractJSONDeserializer.d.ts","sourceRoot":"","sources":["../../../../src/core/json/abstractJSONDeserializer.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yCAJa,CAAC,QACH,CAAC,iBACD,GAAG,CAAC,MAAM,WAAW,OA2B/B"}
|
|
@@ -21,5 +21,11 @@ export function abstractJSONDeserializer(json, deserializers) {
|
|
|
21
21
|
throw new Error(`No deserializer found for type '${typeName}'`);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
const payload = json.data;
|
|
25
|
+
|
|
26
|
+
if (payload === undefined) {
|
|
27
|
+
console.warn(`No serialized payload for type '${typeName}'`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return deserializer(payload);
|
|
25
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bell_membership_function.d.ts","sourceRoot":"","sources":["../../../../src/core/math/bell_membership_function.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"bell_membership_function.d.ts","sourceRoot":"","sources":["../../../../src/core/math/bell_membership_function.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,GACJ,MAAM,CAclB"}
|
|
@@ -10,8 +10,13 @@
|
|
|
10
10
|
* @returns {number}
|
|
11
11
|
*/
|
|
12
12
|
export function bell_membership_function(v, a, b, c) {
|
|
13
|
+
if(a === 0){
|
|
14
|
+
// avoid division by 0
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
13
17
|
|
|
14
|
-
const
|
|
18
|
+
const vc = v - c;
|
|
19
|
+
const N = vc / a;
|
|
15
20
|
|
|
16
21
|
const d = 1 + Math.pow(N, b * 2);
|
|
17
22
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a polar decomposition of a 2x2 matrix.
|
|
3
|
+
* This function decomposes a 2x2 matrix `m` into two matrices, `R` and `S`,
|
|
4
|
+
* such that m = S * R, where:
|
|
5
|
+
* - R is a 2x2 orthogonal matrix (representing a rotation).
|
|
6
|
+
* - S is a 2x2 symmetric positive semi-definite matrix.
|
|
7
|
+
* The input matrix `m` and output matrices `R` and `S` are stored in a flattened,
|
|
8
|
+
* transposed format (consistent with the Taichi programming language convention).
|
|
9
|
+
*
|
|
10
|
+
* @param {number[]} R Output: 2x2 orthogonal matrix (rotation), stored as a flattened
|
|
11
|
+
* array [c, s, -s, c], where 'c' is the cosine and 's' is the sine of the rotation
|
|
12
|
+
* angle. Modified in-place.
|
|
13
|
+
* @param {number[]} S Output: 2x2 symmetric positive semi-definite matrix,
|
|
14
|
+
* stored as a flattened array. Modified in-place.
|
|
15
|
+
* @param {number[]} m Input: 2x2 matrix, stored as a flattened, *transposed* array [a, b, c, d],
|
|
16
|
+
* representing the matrix [[a, c], [b, d]]. Will be read from, but NOT modified.
|
|
17
|
+
*/
|
|
18
|
+
export function m2_polar_decomp(R: number[], S: number[], m: number[]): void;
|
|
19
|
+
//# sourceMappingURL=m2_polar_decomp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"m2_polar_decomp.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/m2/m2_polar_decomp.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,mCARW,MAAM,EAAE,KAGR,MAAM,EAAE,KAER,MAAM,EAAE,QASlB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { m2_multiply } from "../../../geom/mat2/m2_multiply.js";
|
|
2
|
+
import { m2_polar_decomp_noS } from "./m2_polar_decomp_noS.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Performs a polar decomposition of a 2x2 matrix.
|
|
6
|
+
* This function decomposes a 2x2 matrix `m` into two matrices, `R` and `S`,
|
|
7
|
+
* such that m = S * R, where:
|
|
8
|
+
* - R is a 2x2 orthogonal matrix (representing a rotation).
|
|
9
|
+
* - S is a 2x2 symmetric positive semi-definite matrix.
|
|
10
|
+
* The input matrix `m` and output matrices `R` and `S` are stored in a flattened,
|
|
11
|
+
* transposed format (consistent with the Taichi programming language convention).
|
|
12
|
+
*
|
|
13
|
+
* @param {number[]} R Output: 2x2 orthogonal matrix (rotation), stored as a flattened
|
|
14
|
+
* array [c, s, -s, c], where 'c' is the cosine and 's' is the sine of the rotation
|
|
15
|
+
* angle. Modified in-place.
|
|
16
|
+
* @param {number[]} S Output: 2x2 symmetric positive semi-definite matrix,
|
|
17
|
+
* stored as a flattened array. Modified in-place.
|
|
18
|
+
* @param {number[]} m Input: 2x2 matrix, stored as a flattened, *transposed* array [a, b, c, d],
|
|
19
|
+
* representing the matrix [[a, c], [b, d]]. Will be read from, but NOT modified.
|
|
20
|
+
*/
|
|
21
|
+
export function m2_polar_decomp(R, S, m) {
|
|
22
|
+
// transposed as in taichi
|
|
23
|
+
|
|
24
|
+
m2_polar_decomp_noS(R, m);
|
|
25
|
+
|
|
26
|
+
m2_multiply(S, m, R);
|
|
27
|
+
}
|