@woosh/meep-engine 2.78.0 → 2.78.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/build/meep.cjs CHANGED
@@ -70585,10 +70585,19 @@ class Edge {
70585
70585
  return this.first === node || this.second === node;
70586
70586
  }
70587
70587
 
70588
+ /**
70589
+ *
70590
+ * @param {N} source
70591
+ * @param {N} target
70592
+ * @returns {boolean} True iff the edge contains both source and target and allows transition from source to target
70593
+ */
70588
70594
  validateTransition(source, target) {
70589
70595
  const a = this.first;
70590
70596
  const b = this.second;
70591
- return (a === source && b === target && this.traversableForward()) || (b === source && a === target && this.traversableBackward());
70597
+
70598
+ return (a === source && b === target && this.traversableForward())
70599
+ || (b === source && a === target && this.traversableBackward())
70600
+ ;
70592
70601
  }
70593
70602
 
70594
70603
  /**
@@ -70636,16 +70645,6 @@ class Edge {
70636
70645
  || (this.second === node && this.direction === EdgeDirectionType.Backward)
70637
70646
  }
70638
70647
 
70639
- /**
70640
- * @deprecated
70641
- * @returns {number}
70642
- */
70643
- angle() {
70644
-
70645
- const delta = this.second.clone().sub(this.first);
70646
- return Math.atan2(delta.y, delta.x);
70647
- }
70648
-
70649
70648
  /**
70650
70649
  *
70651
70650
  * @returns {N[]}
@@ -70654,15 +70653,6 @@ class Edge {
70654
70653
  return [this.first, this.second];
70655
70654
  }
70656
70655
 
70657
-
70658
- /**
70659
- * @deprecated
70660
- * @returns {number}
70661
- */
70662
- get length() {
70663
-
70664
- return this.first.distanceTo(this.second);
70665
- }
70666
70656
  }
70667
70657
 
70668
70658
  /**
@@ -70693,6 +70683,7 @@ class NodeContainer {
70693
70683
  /**
70694
70684
  *
70695
70685
  * @type {Map<N,number>}
70686
+ * Maps neighbour node to number of edges to that node from this one
70696
70687
  * @private
70697
70688
  */
70698
70689
  __neighbors = new Map();
@@ -71086,6 +71077,7 @@ class Graph {
71086
71077
  /**
71087
71078
  *
71088
71079
  * @param {N} node
71080
+ * @returns {boolean}
71089
71081
  */
71090
71082
  removeNode(node) {
71091
71083
 
@@ -71159,7 +71151,7 @@ class Graph {
71159
71151
  }
71160
71152
 
71161
71153
  /**
71162
- *
71154
+ * Node degree is the number of attached edges
71163
71155
  * @param {N} node
71164
71156
  * @return {number}
71165
71157
  */
@@ -71201,13 +71193,18 @@ class Graph {
71201
71193
  *
71202
71194
  * @param {N} source
71203
71195
  * @param {N} target
71204
- * @param {EdgeDirectionType} [type] Undirected by default
71196
+ * @param {EdgeDirectionType} [direction] Undirected by default
71205
71197
  * @returns {Edge<N>}
71206
71198
  */
71207
- createEdge(source, target, type = EdgeDirectionType.Undirected) {
71199
+ createEdge(
71200
+ source,
71201
+ target,
71202
+ direction = EdgeDirectionType.Undirected
71203
+ ) {
71204
+
71208
71205
  const edge = new Edge(source, target);
71209
71206
 
71210
- edge.direction = type;
71207
+ edge.direction = direction;
71211
71208
 
71212
71209
  this.addEdge(edge);
71213
71210
 
@@ -71215,9 +71212,10 @@ class Graph {
71215
71212
  }
71216
71213
 
71217
71214
  /**
71218
- *
71215
+ * Both nodes that the edge is attached to must be present
71219
71216
  * @param {Edge<N>} edge
71220
- * @returns {boolean}
71217
+ * @returns {boolean} true if edge was added, false if edge was already present
71218
+ * @throws if one or both nodes are not contained in the graph
71221
71219
  */
71222
71220
  addEdge(edge) {
71223
71221
  if (this.hasEdge(edge)) {
@@ -71419,10 +71417,10 @@ class Graph {
71419
71417
  }
71420
71418
 
71421
71419
  /**
71422
- *
71420
+ * Find a path through the graph
71423
71421
  * @param {N} start
71424
71422
  * @param {N} goal
71425
- * @returns {null|N[]}
71423
+ * @returns {null|N[]} null if no path exists
71426
71424
  */
71427
71425
  findPath(start, goal) {
71428
71426
  const start_node_container = this.__nodes.get(start);
@@ -71462,6 +71460,7 @@ class Graph {
71462
71460
  const b = edge.second;
71463
71461
 
71464
71462
  let other = null;
71463
+
71465
71464
  if (a === current_node && (edge.direction === EdgeDirectionType.Forward || edge.direction === EdgeDirectionType.Undirected)) {
71466
71465
  other = b;
71467
71466
  } else if (b === current_node && (edge.direction === EdgeDirectionType.Backward || edge.direction === EdgeDirectionType.Undirected)) {
@@ -71490,6 +71489,9 @@ class Graph {
71490
71489
  return null;
71491
71490
  }
71492
71491
 
71492
+ /**
71493
+ * Remove all data from the graph, resetting it to empty state
71494
+ */
71493
71495
  clear() {
71494
71496
  this.__nodes.clear();
71495
71497
  this.__edges.clear();