@woosh/meep-engine 2.118.5 → 2.118.7

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.
Files changed (141) hide show
  1. package/build/meep.cjs +533 -485
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +533 -485
  4. package/package.json +4 -4
  5. package/src/core/binary/BitSet.d.ts +0 -5
  6. package/src/core/binary/BitSet.d.ts.map +1 -1
  7. package/src/core/binary/BitSet.js +2 -10
  8. package/src/core/binary/base64/Base64.d.ts.map +1 -0
  9. package/src/core/binary/largest_common_alignment_uint32.d.ts.map +1 -0
  10. package/src/core/{collection/array/typed → binary}/largest_common_alignment_uint32.js +1 -1
  11. package/src/core/collection/CuckooFilter.d.ts +34 -8
  12. package/src/core/collection/CuckooFilter.d.ts.map +1 -1
  13. package/src/core/collection/CuckooFilter.js +29 -1
  14. package/src/core/collection/array/typed/array_buffer_copy.d.ts.map +1 -1
  15. package/src/core/collection/array/typed/array_buffer_copy.js +3 -1
  16. package/src/core/collection/array/typed/is_array_buffer_equals.js +1 -1
  17. package/src/core/collection/array/typed/is_typed_array_equals.js +1 -1
  18. package/src/core/collection/map/HashMap.js +7 -7
  19. package/src/core/color/Color.d.ts.map +1 -1
  20. package/src/core/color/Color.js +12 -5
  21. package/src/core/color/operations/color_desaturate.d.ts +7 -0
  22. package/src/core/color/operations/color_desaturate.d.ts.map +1 -0
  23. package/src/core/color/operations/color_desaturate.js +16 -0
  24. package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
  25. package/src/core/geom/2d/aabb/AABB2.js +43 -22
  26. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.d.ts.map +1 -1
  27. package/src/core/geom/2d/aabb/aabb2_compute_center_from_multiple.js +6 -1
  28. package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts +3 -5
  29. package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts.map +1 -1
  30. package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +9 -19
  31. package/src/core/geom/2d/rectangle_to_aabb.d.ts +8 -0
  32. package/src/core/geom/2d/rectangle_to_aabb.d.ts.map +1 -0
  33. package/src/core/geom/2d/rectangle_to_aabb.js +29 -0
  34. package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +1 -1
  35. package/src/core/graph/graph_compute_distance_matrix.d.ts +1 -1
  36. package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -1
  37. package/src/core/graph/graph_compute_distance_matrix.js +1 -1
  38. package/src/core/graph/graph_compute_laplacian_matrix.d.ts +1 -1
  39. package/src/core/graph/graph_compute_laplacian_matrix.d.ts.map +1 -1
  40. package/src/core/graph/graph_compute_laplacian_matrix.js +1 -1
  41. package/src/core/graph/layout/CircleLayout.js +2 -2
  42. package/src/core/graph/layout/box/BoxLayouter.d.ts.map +1 -1
  43. package/src/core/graph/layout/box/BoxLayouter.js +11 -5
  44. package/src/core/graph/layout/box/aabb2_force_into_container.d.ts +7 -0
  45. package/src/core/graph/layout/box/aabb2_force_into_container.d.ts.map +1 -0
  46. package/src/core/graph/layout/box/aabb2_force_into_container.js +56 -0
  47. package/src/core/graph/layout/box/applyCentralGravityAABB2.d.ts.map +1 -1
  48. package/src/core/graph/layout/box/applyCentralGravityAABB2.js +2 -8
  49. package/src/core/graph/layout/box/forceIntoBox.d.ts +4 -2
  50. package/src/core/graph/layout/box/forceIntoBox.d.ts.map +1 -1
  51. package/src/core/graph/layout/box/forceIntoBox.js +5 -31
  52. package/src/core/graph/layout/box/position_box_next_to_box.d.ts +10 -0
  53. package/src/core/graph/layout/box/position_box_next_to_box.d.ts.map +1 -0
  54. package/src/core/graph/layout/box/position_box_next_to_box.js +218 -0
  55. package/src/core/graph/layout/box/pullBoxTowardsPoint.d.ts.map +1 -1
  56. package/src/core/graph/layout/box/pullBoxTowardsPoint.js +8 -3
  57. package/src/core/graph/layout/box/resolveAABB2Overlap.d.ts +2 -2
  58. package/src/core/graph/layout/box/resolveAABB2Overlap.d.ts.map +1 -1
  59. package/src/core/graph/layout/box/resolveAABB2Overlap.js +12 -4
  60. package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.d.ts +1 -0
  61. package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.d.ts.map +1 -1
  62. package/src/core/graph/layout/box/resolveBoxOverlapUsingForce.js +1 -0
  63. package/src/core/math/matrix/SquareMatrix.d.ts.map +1 -0
  64. package/src/core/{graph → math/matrix}/SquareMatrix.js +3 -3
  65. package/src/core/math/spline/cubicCurve.d.ts +3 -8
  66. package/src/core/math/spline/cubicCurve.d.ts.map +1 -1
  67. package/src/core/math/spline/cubicCurve.js +4 -32
  68. package/src/core/model/reactive/js/compileReactiveToJS.d.ts.map +1 -1
  69. package/src/core/model/reactive/js/compileReactiveToJS.js +56 -1
  70. package/src/core/model/reactive/model/terminal/ReactiveReference.d.ts.map +1 -1
  71. package/src/core/model/reactive/model/terminal/ReactiveReference.js +2 -2
  72. package/src/core/model/reactive/trigger/ReactiveTrigger.d.ts +2 -2
  73. package/src/core/model/reactive/trigger/ReactiveTrigger.d.ts.map +1 -1
  74. package/src/core/model/reactive/trigger/ReactiveTrigger.js +1 -1
  75. package/src/core/process/BaseProcess.d.ts.map +1 -1
  76. package/src/core/process/BaseProcess.js +8 -7
  77. package/src/core/process/SimpleLifecycle.d.ts +5 -0
  78. package/src/core/process/SimpleLifecycle.d.ts.map +1 -1
  79. package/src/core/process/SimpleLifecycle.js +8 -0
  80. package/src/core/process/task/Task.js +1 -1
  81. package/src/engine/animation/clip/AnimationClip.d.ts.map +1 -1
  82. package/src/engine/animation/clip/AnimationClip.js +50 -8
  83. package/src/engine/animation/clip/AnimationClipBinding.js +1 -1
  84. package/src/engine/animation/clip/AnimationTrack.d.ts +11 -1
  85. package/src/engine/animation/clip/AnimationTrack.d.ts.map +1 -1
  86. package/src/engine/animation/clip/AnimationTrack.js +50 -7
  87. package/src/engine/animation/curve/binding/BoundPlainNumericPropertyWriter.d.ts +8 -0
  88. package/src/engine/animation/curve/binding/BoundPlainNumericPropertyWriter.d.ts.map +1 -0
  89. package/src/engine/animation/curve/binding/BoundPlainNumericPropertyWriter.js +16 -0
  90. package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
  91. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.d.ts.map +1 -1
  92. package/src/engine/ecs/terrain/ecs/splat/SplatMapping.js +6 -6
  93. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  94. package/src/engine/graphics/texture/sampler/Sampler2D.js +1 -1
  95. package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.d.ts +3 -3
  96. package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.d.ts.map +1 -1
  97. package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +6 -6
  98. package/src/generation/grid/generation/discrete/GridTaskCellularAutomata.d.ts.map +1 -1
  99. package/src/generation/grid/generation/discrete/GridTaskCellularAutomata.js +35 -31
  100. package/src/generation/grid/generation/grid/GridTaskAddNodesFixed.d.ts.map +1 -1
  101. package/src/generation/grid/generation/grid/GridTaskAddNodesFixed.js +8 -11
  102. package/src/generation/grid/generation/road/RoadConnectionNetwork.d.ts +6 -2
  103. package/src/generation/grid/generation/road/RoadConnectionNetwork.d.ts.map +1 -1
  104. package/src/generation/grid/generation/road/RoadConnectionNetwork.js +36 -30
  105. package/src/generation/placement/action/GridCellAction.js +1 -1
  106. package/src/generation/theme/AreaTheme.d.ts.map +1 -1
  107. package/src/generation/theme/AreaTheme.js +0 -1
  108. package/src/generation/theme/TerrainLayerRule.d.ts.map +1 -1
  109. package/src/generation/theme/TerrainLayerRule.js +2 -1
  110. package/src/generation/theme/TerrainLayerRuleAggregator.d.ts +5 -1
  111. package/src/generation/theme/TerrainLayerRuleAggregator.d.ts.map +1 -1
  112. package/src/generation/theme/TerrainLayerRuleAggregator.js +7 -2
  113. package/src/generation/theme/ThemeEngine.d.ts +2 -2
  114. package/src/generation/theme/ThemeEngine.d.ts.map +1 -1
  115. package/src/generation/theme/ThemeEngine.js +1 -4
  116. package/src/generation/theme/cell/CellProcessingRule.d.ts.map +1 -1
  117. package/src/generation/theme/cell/CellProcessingRule.js +10 -13
  118. package/src/generation/theme/cell/CellProcessingRuleSet.d.ts.map +1 -1
  119. package/src/generation/theme/cell/CellProcessingRuleSet.js +6 -7
  120. package/src/view/SVG.d.ts.map +1 -1
  121. package/src/view/SVG.js +0 -15
  122. package/src/view/html_element_to_aabb.d.ts +8 -0
  123. package/src/view/html_element_to_aabb.d.ts.map +1 -0
  124. package/src/view/html_element_to_aabb.js +29 -0
  125. package/src/view/tooltip/TooltipManager.d.ts.map +1 -1
  126. package/src/view/tooltip/TooltipManager.js +7 -9
  127. package/src/view/tooltip/TooltipView.d.ts +0 -1
  128. package/src/view/tooltip/TooltipView.d.ts.map +1 -1
  129. package/src/view/tooltip/TooltipView.js +10 -280
  130. package/src/view/tooltip/gml/TooltipParser.d.ts.map +1 -1
  131. package/src/view/tooltip/gml/TooltipParser.js +1 -13
  132. package/src/core/binary/Base64.d.ts.map +0 -1
  133. package/src/core/collection/array/typed/largest_common_alignment_uint32.d.ts.map +0 -1
  134. package/src/core/graph/SquareMatrix.d.ts.map +0 -1
  135. package/src/engine/simulation/DormandPrince.d.ts +0 -19
  136. package/src/engine/simulation/DormandPrince.d.ts.map +0 -1
  137. package/src/engine/simulation/DormandPrince.js +0 -242
  138. /package/src/core/binary/{Base64.d.ts → base64/Base64.d.ts} +0 -0
  139. /package/src/core/binary/{Base64.js → base64/Base64.js} +0 -0
  140. /package/src/core/{collection/array/typed → binary}/largest_common_alignment_uint32.d.ts +0 -0
  141. /package/src/core/{graph → math/matrix}/SquareMatrix.d.ts +0 -0
@@ -1,12 +1,10 @@
1
- import View from "../View.js";
1
+ import { rectangle_to_aabb } from "../../core/geom/2d/rectangle_to_aabb.js";
2
2
  import Vector2 from "../../core/geom/Vector2.js";
3
- import AABB2 from "../../core/geom/2d/aabb/AABB2.js";
3
+ import { position_box_next_to_box } from "../../core/graph/layout/box/position_box_next_to_box.js";
4
4
  import { CompassArrowView } from "../elements/CompassArrowView.js";
5
5
  import EmptyView from "../elements/EmptyView.js";
6
- import { forceIntoBox } from "../../core/graph/layout/box/forceIntoBox.js";
7
- import { pullBoxTowardsPoint } from "../../core/graph/layout/box/pullBoxTowardsPoint.js";
8
- import { resolveAABB2Overlap } from "../../core/graph/layout/box/resolveAABB2Overlap.js";
9
- import { EPSILON } from "../../core/math/EPSILON.js";
6
+ import { html_element_to_aabb } from "../html_element_to_aabb.js";
7
+ import View from "../View.js";
10
8
 
11
9
 
12
10
  class TooltipView extends View {
@@ -51,7 +49,7 @@ class TooltipView extends View {
51
49
  * @param {AABB2} bounds
52
50
  */
53
51
  layout(bounds) {
54
- const tipBox = element2aabb(this.contentView.el);
52
+ const tipBox = html_element_to_aabb(this.contentView.el);
55
53
 
56
54
  const SPACING = 16;
57
55
 
@@ -65,17 +63,17 @@ class TooltipView extends View {
65
63
 
66
64
  const tipTarget = tip.target;
67
65
 
68
- const target = rectangle2aabb(tipTarget);
66
+ const target = rectangle_to_aabb(tipTarget);
69
67
 
70
- const box = positionBoxNextToBox(tipBox, target, bounds);
68
+ const box = position_box_next_to_box(tipBox, target, bounds);
71
69
 
72
70
  box.shrink(SPACING);
73
71
 
74
72
  const compass = this.compass;
75
73
 
76
- function setCompas() {
74
+ function setCompass() {
77
75
 
78
- const targetCenter = new Vector2(target.midX(), target.midY());
76
+ const targetCenter = target.getCenter();
79
77
 
80
78
  const tipPoint = new Vector2();
81
79
 
@@ -86,279 +84,11 @@ class TooltipView extends View {
86
84
  compass.position.copy(tipPoint)._add(-box.x0, -box.y0);
87
85
  }
88
86
 
89
- setCompas();
87
+ setCompass();
90
88
 
91
89
  this.position.set(box.x0, box.y0)
92
90
  }
93
91
  }
94
92
 
95
93
 
96
- /**
97
- *
98
- * @param {Element} el
99
- * @returns {AABB2}
100
- */
101
- function element2aabb(el) {
102
- const clientRect = el.getBoundingClientRect();
103
-
104
- let x0 = clientRect.left;
105
- let y0 = clientRect.top;
106
- let x1 = clientRect.right;
107
- let y1 = clientRect.bottom;
108
-
109
- // sanitize bounds
110
-
111
- if (Number.isNaN(x1)) {
112
- x1 = x0;
113
- }
114
-
115
- if (Number.isNaN(y1)) {
116
- y1 = y0;
117
- }
118
-
119
- // write bounds
120
-
121
- return new AABB2(x0, y0, x1, y1);
122
- }
123
-
124
- /**
125
- *
126
- * @param {Rectangle} rect
127
- * @returns {AABB2}
128
- */
129
- function rectangle2aabb(rect) {
130
- const position = rect.position;
131
-
132
- const x0 = position.x;
133
- const y0 = position.y;
134
-
135
- const size = rect.size;
136
-
137
- let x1 = x0;
138
- let y1 = y0;
139
-
140
- // sanitize bounds
141
- if (size.x > 0) {
142
- x1 += size.x;
143
- }
144
-
145
- if (size.y > 0) {
146
- y1 += size.y;
147
- }
148
-
149
- return new AABB2(x0, y0, x1, y1);
150
- }
151
-
152
- /**
153
- *
154
- * @param {AABB2} box
155
- * @param {AABB2} target
156
- * @param {AABB2} bounds
157
- * @returns {Vector2}
158
- */
159
- function computeInitialPlacement(box, target, bounds) {
160
- /**
161
- * list of preferred directions, ordered. First direction is higher priority than the next, last is lowest priority
162
- * @type {Vector2[]}
163
- */
164
- const preferredDirections = [
165
- Vector2.up,
166
- Vector2.right,
167
- Vector2.down,
168
- Vector2.left
169
- ];
170
-
171
- const targetCenter = new Vector2(target.midX(), target.midY());
172
-
173
- const targetH = target.getHeight();
174
- const targetW = target.getWidth();
175
-
176
- const targetDiagonal = Math.sqrt(targetH * targetH + targetW * targetW);
177
-
178
- const boxWidth = box.getWidth();
179
- const boxHeight = box.getHeight();
180
-
181
- const boxWidth_2 = boxWidth / 2;
182
- const boxHeight_2 = boxHeight / 2;
183
-
184
- const intersectionPoint = new Vector2();
185
-
186
- const placements = preferredDirections.map(function (direction) {
187
- //invert Y axis, screen-space direction is Down(+) and Up(-)
188
- const viewportDirection = direction.clone()._multiply(1, -1);
189
-
190
- const pointOutside = viewportDirection.clone();
191
- //scale vector to be larger than the box diagonal so it would intersect the boundary when placed in the middle
192
- pointOutside.multiplyScalar(targetDiagonal + 1);
193
- //move vector to the middle od the box
194
- pointOutside.add(targetCenter);
195
-
196
- target.lineIntersectionPoint(targetCenter, pointOutside, intersectionPoint);
197
-
198
- //align placement to the opposite edge of the box
199
- const offset = new Vector2(boxWidth_2, boxHeight_2);
200
-
201
- offset.multiply(viewportDirection);
202
-
203
- offset._sub(boxWidth_2, boxHeight_2);
204
-
205
- offset.add(intersectionPoint);
206
-
207
- return offset;
208
- });
209
-
210
- /**
211
- *
212
- * @param {Vector2} placement
213
- * @returns {number}
214
- */
215
- function computePlacementScore(placement) {
216
- //find space for the tip between bounds and the target
217
- const availableSpace = new AABB2();
218
-
219
- const px0 = placement.x;
220
- const px1 = px0 + boxWidth;
221
- const py0 = placement.y;
222
- const py1 = py0 + boxHeight;
223
-
224
- if (px1 <= target.x0) {
225
- //left
226
- availableSpace.set(
227
- bounds.x0,
228
- bounds.y0,
229
- target.x0,
230
- bounds.y1
231
- );
232
- } else if (px0 >= target.x1) {
233
- //right
234
- availableSpace.set(
235
- target.x1,
236
- bounds.y0,
237
- bounds.x1,
238
- bounds.y1
239
- );
240
- } else if (py1 <= target.y0) {
241
- //up
242
- availableSpace.set(
243
- bounds.x0,
244
- bounds.y0,
245
- bounds.x1,
246
- target.y0
247
- );
248
- } else if (py0 >= target.y1) {
249
- //bottom
250
- availableSpace.set(
251
- bounds.x0,
252
- target.y1,
253
- bounds.x1,
254
- bounds.y1
255
- );
256
- } else {
257
- //tip is inside, no arbitration
258
- }
259
-
260
- let score = 0;
261
-
262
- const availableWidth = availableSpace.getWidth();
263
- const availableHeight = availableSpace.getHeight();
264
-
265
- const spareWidth = availableWidth - boxWidth;
266
- const spareHeight = availableHeight - boxHeight;
267
-
268
- if (spareHeight < 0) {
269
- score--;
270
- }
271
-
272
- if (spareWidth < 0) {
273
- score--;
274
- }
275
-
276
- return score;
277
- }
278
-
279
- //score placements
280
- const scores = placements.map(computePlacementScore);
281
-
282
- //find best placement
283
- let bestIndex = 0;
284
- let bestScore = scores[0];
285
-
286
- for (let i = 1; i < scores.length; i++) {
287
- const score = scores[i];
288
-
289
- if (score > bestScore + EPSILON) {
290
- bestScore = score;
291
- bestIndex = i;
292
- }
293
- }
294
-
295
- return placements[bestIndex];
296
- }
297
-
298
-
299
- /**
300
- *
301
- * @param {AABB2} box
302
- * @param {AABB2} target
303
- * @param {AABB2} bounds
304
- */
305
- function positionBoxNextToBox(box, target, bounds) {
306
- const b = box.clone();
307
- const t = target.clone();
308
-
309
- //center box inside the bounds
310
- const y0 = (bounds.getHeight() + b.getHeight()) / 2;
311
- const x0 = (bounds.getWidth() + b.getWidth()) / 2;
312
- b.set(x0, y0, x0 + b.getWidth(), y0 + b.getHeight());
313
-
314
-
315
- const targetCenter = new Vector2(t.midX(), t.midY());
316
-
317
- t.locked = true;
318
-
319
- function touch() {
320
-
321
- const bC = new Vector2(b.midX(), b.midY());
322
-
323
- const bE = new Vector2();
324
- const tE = new Vector2();
325
-
326
-
327
- t.lineIntersectionPoint(bC, targetCenter, tE);
328
- const delta = new Vector2();
329
-
330
- if (b.lineIntersectionPoint(bC, targetCenter, bE)) {
331
- delta.copy(tE).sub(bE);
332
- } else {
333
- delta.copy(tE).sub(bC);
334
- }
335
-
336
- b.move(delta.x, delta.y);
337
- }
338
-
339
-
340
- const initialPosition = computeInitialPlacement(b, t, bounds);
341
- //set bounds to initial position
342
- b.set(initialPosition.x, initialPosition.y, initialPosition.x + b.getWidth(), initialPosition.y + b.getHeight());
343
-
344
- // touch();
345
-
346
- function step() {
347
- //pull
348
- pullBoxTowardsPoint(b, initialPosition.x + b.getWidth() / 2, initialPosition.y + b.getHeight() / 2, 0.1);
349
-
350
- resolveAABB2Overlap([b, t], 10);
351
-
352
- forceIntoBox(bounds, [b]);
353
- }
354
-
355
- for (let i = 0; i < 5; i++) {
356
- step();
357
- }
358
-
359
- box.copy(b);
360
-
361
- return box;
362
- }
363
-
364
94
  export default TooltipView;
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipParser.d.ts","sourceRoot":"","sources":["../../../../../src/view/tooltip/gml/TooltipParser.js"],"names":[],"mappings":"AAOA;IAkBI;;;;OAIG;IACH,YAHW,MAAM,GACJ,OAAO,CAkBnB;;CACJ"}
1
+ {"version":3,"file":"TooltipParser.d.ts","sourceRoot":"","sources":["../../../../../src/view/tooltip/gml/TooltipParser.js"],"names":[],"mappings":"AAOA;IAkBI;;;;OAIG;IACH,YAHW,MAAM,GACJ,OAAO,CAMnB;;CACJ"}
@@ -30,19 +30,7 @@ export class TooltipParser {
30
30
  */
31
31
  parse(code) {
32
32
 
33
- const existing = this.#cache.get(code);
33
+ return this.#cache.getOrCompute(code, parseTooltipString);
34
34
 
35
- if (existing !== null) {
36
- // result is cached, reuse
37
- return existing;
38
- }
39
-
40
- // no cached result, parse
41
- const tokens = parseTooltipString(code);
42
-
43
- // cache result
44
- this.#cache.put(code, tokens);
45
-
46
- return tokens;
47
35
  }
48
36
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Base64.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/Base64.js"],"names":[],"mappings":"AAgOA;IACI;;;;OAIG;IACH,qBAHW,WAAW,GACT,MAAM,CAOlB;IAED;;;;OAIG;IACH,qBAHW,MAAM,GACJ,WAAW,CAUvB;CACJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"largest_common_alignment_uint32.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/largest_common_alignment_uint32.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,0DALW,MAAM,YACN,MAAM,eACN,MAAM,GACJ,MAAM,CAoBlB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SquareMatrix.d.ts","sourceRoot":"","sources":["../../../../src/core/graph/SquareMatrix.js"],"names":[],"mappings":"AAIA;IACI;;;;OAIG;IACH,kBAHW,MAAM,QACN,iBAAe,MAAM,EA2B/B;IAhBG;;;OAGG;IACH,MAFU,MAAM,CAEA;IAEhB;;;OAGG;IACH,qBAAgB;IAEhB;;OAEG;IACH,MAFU,MAAM,EAAE,CAEqB;IAG3C,gBAEC;IAED,qBAEC;IAED,oBAEC;IAED,mBAEC;IAED;;;OAGG;IACH,gBAFW,YAAY,QAItB;IAED;;;;OAIG;IACH,oBAHW,YAAY,KACZ,YAAY,QAiBtB;IAED;;OAEG;IACH,eAMC;IAED;;OAEG;IACH,cAEC;IAED;;OAEG;IACH,YAMC;IAED;;;OAGG;IACH,YAFW,YAAY,QAMtB;IAED;;;OAGG;IACH,SAFY,YAAY,CAQvB;IAED;;OAEG;IACH,kBAcC;IAED;;;OAGG;IACH,eAFW,MAAM,EAAE,QAIlB;IAED;;;;OAIG;IACH,sBAHW,MAAM,EAAE,WACR,MAAM,YAMhB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,gBACN,MAAM,SACN,MAAM,QAYhB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,gBACN,MAAM,GACL,MAAM,CAWjB;IAED;;;OAGG;IACH,qBAFW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAU5C;CACJ"}
@@ -1,19 +0,0 @@
1
- export class StepResult {
2
- step: number;
3
- yDelta: number;
4
- error: number;
5
- iterations: number;
6
- }
7
- /**
8
- *
9
- * @param {function(x:number, y:number):number} fxy derivative function
10
- * @param {number} x value of X
11
- * @param {number} y value of Y
12
- * @param {number} suggestedStepSize Suggested step size
13
- * @param {number} tolerance tolerable error size
14
- * @param {number} maxIterations maximum number of iterations allowed to find step
15
- * @param {StepResult} result
16
- * @returns {boolean} true if result is found, false otherwise
17
- */
18
- export function computeStepSize(fxy: any, x: number, y: number, suggestedStepSize: number, tolerance: number, maxIterations: number, result: StepResult): boolean;
19
- //# sourceMappingURL=DormandPrince.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DormandPrince.d.ts","sourceRoot":"","sources":["../../../../src/engine/simulation/DormandPrince.js"],"names":[],"mappings":"AAoGA;IACQ,aAAS;IACT,eAAW;IACX,cAAU;IACV,mBAAe;CACtB;AAED;;;;;;;;;;GAUG;AACH,6CARW,MAAM,KACN,MAAM,qBACN,MAAM,aACN,MAAM,iBACN,MAAM,UACN,UAAU,GACR,OAAO,CAwCnB"}
@@ -1,242 +0,0 @@
1
- import { clamp } from "../../core/math/clamp.js";
2
-
3
- /*
4
- File odedopri.py
5
-
6
- Synopsis
7
- double odedopri(double (*fxy)(double x, double y),
8
- double x0, double y0, double x1, double tol,
9
- double hmax, double hmin, int maxiter)
10
-
11
- Parameters
12
- fxy Input: derivative function y' = f(x, y)
13
- y is the dependent variable, x is the independent
14
- variable
15
- x0, y0 Input: initial points, x0 <= x <= x1 y(x0) = y0
16
- x1 Input: final value of x
17
- tol Input: tolerance
18
- hmax Input: maximum step size
19
- hmin Input: minimum step size
20
- maxiter Input: maximum number of iterations
21
- flag Input: return flag
22
- 0 no errors
23
- 1 hmin exceeded
24
- 2 maximum iterations exceeded
25
-
26
- Return value
27
- value of y at last step x
28
-
29
- Description
30
- The routine odedopri() implements the Dormand-Prince method of
31
- solving an ordinary differential equation of the first order
32
- y' = f(x,y).
33
-
34
- Reference
35
- The coefficients were obtained from
36
-
37
- E.Hairer, S.P.Norsett and G.Wanner[1991],
38
- "Solving Differential Equations I, Nonstiff Problems",
39
- 2e, Springer-Verlag, p. 178
40
-
41
- WARNING
42
- Check the flag after calling this routine!
43
-
44
- Revisions
45
- 1998.05.02 first version
46
- 2018.05.04 Javascript port from python
47
- @source https://web.archive.org/web/20150907215914/http://adorio-research.org/wordpress/?p=6565
48
- @author ? [original author]
49
- @author Alex Goldring
50
- */
51
-
52
- // we trust that the compiler is smart enough to pre-evaluate the
53
- // value of the constants.
54
-
55
- const a21 = (1.0 / 5.0),
56
- a31 = (3.0 / 40.0),
57
- a32 = (9.0 / 40.0),
58
- a41 = (44.0 / 45.0),
59
- a42 = (-56.0 / 15.0),
60
- a43 = (32.0 / 9.0),
61
- a51 = (19372.0 / 6561.0),
62
- a52 = (-25360.0 / 2187.0),
63
- a53 = (64448.0 / 6561.0),
64
- a54 = (-212.0 / 729.0),
65
- a61 = (9017.0 / 3168.0),
66
- a62 = (-355.0 / 33.0),
67
- a63 = (46732.0 / 5247.0),
68
- a64 = (49.0 / 176.0),
69
- a65 = (-5103.0 / 18656.0),
70
- a71 = (35.0 / 384.0),
71
- a72 = (0.0),
72
- a73 = (500.0 / 1113.0),
73
- a74 = (125.0 / 192.0),
74
- a75 = (-2187.0 / 6784.0),
75
- a76 = (11.0 / 84.0),
76
-
77
- c2 = (1.0 / 5.0),
78
- c3 = (3.0 / 10.0),
79
- c4 = (4.0 / 5.0),
80
- c5 = (8.0 / 9.0),
81
- c6 = (1.0),
82
- c7 = (1.0),
83
-
84
- b1 = (35.0 / 384.0),
85
- b2 = (0.0),
86
- b3 = (500.0 / 1113.0),
87
- b4 = (125.0 / 192.0),
88
- b5 = (-2187.0 / 6784.0),
89
- b6 = (11.0 / 84.0),
90
- b7 = (0.0),
91
-
92
- b1p = (5179.0 / 57600.0),
93
- b2p = (0.0),
94
- b3p = (7571.0 / 16695.0),
95
- b4p = (393.0 / 640.0),
96
- b5p = (-92097.0 / 339200.0),
97
- b6p = (187.0 / 2100.0),
98
- b7p = (1.0 / 40.0);
99
-
100
-
101
- export class StepResult {
102
- step = 0;
103
- yDelta = 0;
104
- error = 0;
105
- iterations = 0;
106
- }
107
-
108
- /**
109
- *
110
- * @param {function(x:number, y:number):number} fxy derivative function
111
- * @param {number} x value of X
112
- * @param {number} y value of Y
113
- * @param {number} suggestedStepSize Suggested step size
114
- * @param {number} tolerance tolerable error size
115
- * @param {number} maxIterations maximum number of iterations allowed to find step
116
- * @param {StepResult} result
117
- * @returns {boolean} true if result is found, false otherwise
118
- */
119
- function computeStepSize(fxy, x, y, suggestedStepSize, tolerance, maxIterations, result) {
120
- let i;
121
-
122
- let h = suggestedStepSize;
123
-
124
- for (i = 0; i < maxIterations; i++) {
125
- /* Compute the function values */
126
- const K1 = fxy(x, y);
127
- const K2 = fxy(x + c2 * h, y + h * (a21 * K1));
128
- const K3 = fxy(x + c3 * h, y + h * (a31 * K1 + a32 * K2));
129
- const K4 = fxy(x + c4 * h, y + h * (a41 * K1 + a42 * K2 + a43 * K3));
130
- const K5 = fxy(x + c5 * h, y + h * (a51 * K1 + a52 * K2 + a53 * K3 + a54 * K4));
131
- const K6 = fxy(x + h, y + h * (a61 * K1 + a62 * K2 + a63 * K3 + a64 * K4 + a65 * K5));
132
- const K7 = fxy(x + h, y + h * (a71 * K1 + a72 * K2 + a73 * K3 + a74 * K4 + a75 * K5 + a76 * K6));
133
-
134
- const error = Math.abs((b1 - b1p) * K1 + (b3 - b3p) * K3 + (b4 - b4p) * K4 + (b5 - b5p) * K5 + (b6 - b6p) * K6 + (b7 - b7p) * K7);
135
-
136
- // error control
137
- const delta = 0.84 * Math.pow(tolerance / error, (1.0 / 5.0));
138
-
139
- if (error < tolerance) {
140
- // error within tolerance
141
-
142
- result.step = h;
143
- result.error = error;
144
- result.iterations = i + 1;
145
- result.yDelta = h * (b1 * K1 + b3 * K3 + b4 * K4 + b5 * K5 + b6 * K6);
146
-
147
- return true;
148
- }
149
-
150
- const clamped_delta = clamp(delta, 0.1, 4.0);
151
-
152
- h = clamped_delta * h;
153
- }
154
-
155
- //failed to compute step
156
- return false;
157
- }
158
-
159
- /**
160
- *
161
- * @param {function(x:number, y:number):number} fxy derivative function
162
- * @param {number} x0 starting X value
163
- * @param {number} y0 starting Y value
164
- * @param {number} x1 end X value
165
- * @param {number} tol tolerance
166
- * @param {number} hmax max step size
167
- * @param {number} hmin min step size
168
- * @param {number} max_iteration maximum number of iterations
169
- * @returns {Array.<number>}
170
- */
171
- function odedopri(fxy, x0, y0, x1, tol, hmax, hmin, max_iteration) {
172
-
173
-
174
- let x = x0;
175
- let y = y0;
176
- //step size
177
- let h = hmax;
178
-
179
- let flag;
180
- const stepResult = new StepResult();
181
-
182
- let iterations_remaining = max_iteration;
183
-
184
- while (iterations_remaining > 0) {
185
-
186
- iterations_remaining--;
187
-
188
- if (computeStepSize(fxy, x, y, h, tol, 100, stepResult)) {
189
- h = stepResult.step;
190
- x += h;
191
- y += stepResult.yDelta;
192
- } else {
193
- //failed to find a good step, take a conservative smallest possible step
194
- h = hmin;
195
- }
196
-
197
- if (h > hmax) {
198
- h = hmax;
199
- }
200
-
201
-
202
- if (x >= x1) {
203
- flag = 0;
204
- break;
205
- } else if (x + h > x1) {
206
- h = x1 - x;
207
- } else if (h < hmin) {
208
- h = hmin;
209
- }
210
- }
211
-
212
- if (iterations_remaining <= 0) {
213
- flag = 2;
214
- }
215
-
216
- return [y, x, flag, iterations_remaining];
217
- }
218
-
219
- function main() {
220
- function fxy(x, y) {
221
- return Math.abs(Math.sin(x));
222
- }
223
-
224
- const x0 = 0,
225
- y0 = 1.24,
226
- x1 = 1000.0,
227
- tol = 1.0e-5,
228
- hmax = 1.0,
229
- hmin = 0.001,
230
- maxiter = 1000000;
231
-
232
- console.log(odedopri(fxy, x0, y0, x1, tol, hmax, hmin, maxiter));
233
- }
234
-
235
- console.time('solver');
236
- main();
237
- console.timeEnd('solver');
238
-
239
- export {
240
- StepResult,
241
- computeStepSize
242
- };
File without changes