jsxgraph 1.9.0 → 1.9.2

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 (113) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/distrib/docs.zip +0 -0
  3. package/distrib/geogebra.min.js +2 -2
  4. package/distrib/geonext.min.js +3 -3
  5. package/distrib/index.d.ts +1 -1
  6. package/distrib/intergeo.min.js +2 -2
  7. package/distrib/jsxgraph.css +1 -1
  8. package/distrib/jsxgraph.zip +0 -0
  9. package/distrib/jsxgraphcore.js +3 -3
  10. package/distrib/jsxgraphcore.mjs +3 -3
  11. package/distrib/jsxgraphcore.mjs.map +1 -1
  12. package/distrib/jsxgraphsrc.js +7680 -6865
  13. package/distrib/jsxgraphsrc.mjs +7964 -7150
  14. package/distrib/jsxgraphsrc.mjs.map +1 -1
  15. package/distrib/sketch.min.js +3 -3
  16. package/distrib/themes/mono_thin.js +1 -1
  17. package/package.json +4 -4
  18. package/src/3d/box3d.js +6 -3
  19. package/src/3d/circle3d.js +11 -10
  20. package/src/3d/curve3d.js +3 -1
  21. package/src/3d/element3d.js +1 -1
  22. package/src/3d/linspace3d.js +20 -57
  23. package/src/3d/point3d.js +7 -1
  24. package/src/3d/polygon3d.js +2 -1
  25. package/src/3d/sphere3d.js +48 -44
  26. package/src/3d/surface3d.js +2 -1
  27. package/src/3d/view3d.js +1505 -1068
  28. package/src/base/board.js +177 -56
  29. package/src/base/chart.js +5 -6
  30. package/src/base/circle.js +4 -2
  31. package/src/base/composition.js +1 -1
  32. package/src/base/constants.js +2 -2
  33. package/src/base/coords.js +1 -1
  34. package/src/base/coordselement.js +1 -1
  35. package/src/base/curve.js +2 -1
  36. package/src/base/element.js +39 -31
  37. package/src/base/foreignobject.js +1 -1
  38. package/src/base/group.js +1 -1
  39. package/src/base/image.js +1 -1
  40. package/src/base/line.js +94 -106
  41. package/src/base/point.js +1 -1
  42. package/src/base/polygon.js +2 -2
  43. package/src/base/text.js +6 -2
  44. package/src/base/ticks.js +1 -1
  45. package/src/base/transformation.js +1 -1
  46. package/src/base/turtle.js +1 -1
  47. package/src/element/arc.js +1 -1
  48. package/src/element/button.js +63 -13
  49. package/src/element/checkbox.js +7 -3
  50. package/src/element/comb.js +1 -1
  51. package/src/element/composition.js +1 -1
  52. package/src/element/conic.js +1 -1
  53. package/src/element/grid.js +7 -7
  54. package/src/element/input.js +10 -7
  55. package/src/element/locus.js +1 -1
  56. package/src/element/measure.js +1 -1
  57. package/src/element/sector.js +1 -1
  58. package/src/element/slider.js +43 -40
  59. package/src/element/slopetriangle.js +1 -1
  60. package/src/element/smartlabel.js +1 -1
  61. package/src/element/vectorfield.js +1 -1
  62. package/src/index.d.ts +1 -1
  63. package/src/jsxgraph.js +6 -4
  64. package/src/jxg.js +1 -1
  65. package/src/math/bqdt.js +1 -1
  66. package/src/math/clip.js +1 -1
  67. package/src/math/complex.js +1 -1
  68. package/src/math/extrapolate.js +1 -1
  69. package/src/math/geometry.js +87 -65
  70. package/src/math/ia.js +12 -12
  71. package/src/math/implicitplot.js +1 -1
  72. package/src/math/math.js +48 -6
  73. package/src/math/metapost.js +1 -1
  74. package/src/math/nlp.js +1 -1
  75. package/src/math/numerics.js +1 -1
  76. package/src/math/plot.js +25 -26
  77. package/src/math/poly.js +1 -1
  78. package/src/math/probfuncs.js +1 -1
  79. package/src/math/qdt.js +1 -1
  80. package/src/math/statistics.js +1 -1
  81. package/src/math/symbolic.js +1 -1
  82. package/src/options.js +49 -4
  83. package/src/options3d.js +82 -5
  84. package/src/parser/datasource.js +1 -1
  85. package/src/parser/geonext.js +1 -1
  86. package/src/parser/jessiecode.js +12 -11
  87. package/src/parser/jessiescript.js +1 -1
  88. package/src/parser/prefix.js +9 -2
  89. package/src/reader/cinderella.js +1 -1
  90. package/src/reader/file.js +1 -1
  91. package/src/reader/geogebra.js +1 -1
  92. package/src/reader/geonext.js +1 -1
  93. package/src/reader/graph.js +1 -1
  94. package/src/reader/intergeo.js +1 -1
  95. package/src/reader/sketch.js +107 -1
  96. package/src/renderer/abstract.js +1 -1
  97. package/src/renderer/canvas.js +1 -1
  98. package/src/renderer/no.js +1 -1
  99. package/src/renderer/svg.js +17 -7
  100. package/src/renderer/vml.js +1 -1
  101. package/src/server/server.js +1 -1
  102. package/src/themes/mono_thin.js +1 -1
  103. package/src/unused/bst.js +1 -1
  104. package/src/unused/heap.js +1 -1
  105. package/src/utils/base64.js +1 -1
  106. package/src/utils/color.js +1 -1
  107. package/src/utils/dump.js +1 -1
  108. package/src/utils/env.js +3 -3
  109. package/src/utils/event.js +1 -1
  110. package/src/utils/expect.js +1 -1
  111. package/src/utils/type.js +30 -18
  112. package/src/utils/xml.js +1 -1
  113. package/src/utils/zip.js +1 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -254,7 +254,7 @@ JXG.createSlider = function (board, parents, attributes) {
254
254
  p3.Value = function () {
255
255
  var d = this._smax - this._smin,
256
256
  ev_sw = Type.evaluate(this.visProp.snapwidth);
257
- // snapValues, i, v;
257
+ // snapValues, i, v;
258
258
 
259
259
  // snapValues = Type.evaluate(this.visProp.snapvalues);
260
260
  // if (Type.isArray(snapValues)) {
@@ -354,48 +354,48 @@ JXG.createSlider = function (board, parents, attributes) {
354
354
  if (withText) {
355
355
  // attr = Type.copyAttributes(attributes, board.options, 'slider', 'label');
356
356
  t = board.create('text', [
357
- function () {
358
- return (p2.X() - p1.X()) * 0.05 + p2.X();
359
- },
360
- function () {
361
- return (p2.Y() - p1.Y()) * 0.05 + p2.Y();
362
- },
363
- function () {
364
- var n,
365
- d = Type.evaluate(p3.visProp.digits),
366
- sl = Type.evaluate(p3.visProp.suffixlabel),
367
- ul = Type.evaluate(p3.visProp.unitlabel),
368
- pl = Type.evaluate(p3.visProp.postlabel);
369
-
370
- if (d === 2 && Type.evaluate(p3.visProp.precision) !== 2) {
371
- // Backwards compatibility
372
- d = Type.evaluate(p3.visProp.precision);
373
- }
374
-
375
- if (sl !== null) {
376
- n = sl;
377
- } else if (p3.name && p3.name !== "") {
378
- n = p3.name + " = ";
379
- } else {
380
- n = "";
381
- }
357
+ function () {
358
+ return (p2.X() - p1.X()) * 0.05 + p2.X();
359
+ },
360
+ function () {
361
+ return (p2.Y() - p1.Y()) * 0.05 + p2.Y();
362
+ },
363
+ function () {
364
+ var n,
365
+ d = Type.evaluate(p3.visProp.digits),
366
+ sl = Type.evaluate(p3.visProp.suffixlabel),
367
+ ul = Type.evaluate(p3.visProp.unitlabel),
368
+ pl = Type.evaluate(p3.visProp.postlabel);
369
+
370
+ if (d === 2 && Type.evaluate(p3.visProp.precision) !== 2) {
371
+ // Backwards compatibility
372
+ d = Type.evaluate(p3.visProp.precision);
373
+ }
382
374
 
383
- if (p3.useLocale()) {
384
- n += p3.formatNumberLocale(p3.Value(), d);
385
- } else {
386
- n += Type.toFixed(p3.Value(), d);
387
- }
375
+ if (sl !== null) {
376
+ n = sl;
377
+ } else if (p3.name && p3.name !== "") {
378
+ n = p3.name + " = ";
379
+ } else {
380
+ n = "";
381
+ }
388
382
 
389
- if (ul !== null) {
390
- n += ul;
391
- }
392
- if (pl !== null) {
393
- n += pl;
394
- }
383
+ if (p3.useLocale()) {
384
+ n += p3.formatNumberLocale(p3.Value(), d);
385
+ } else {
386
+ n += Type.toFixed(p3.Value(), d);
387
+ }
395
388
 
396
- return n;
389
+ if (ul !== null) {
390
+ n += ul;
397
391
  }
398
- ],
392
+ if (pl !== null) {
393
+ n += pl;
394
+ }
395
+
396
+ return n;
397
+ }
398
+ ],
399
399
  attr.label
400
400
  );
401
401
 
@@ -527,6 +527,9 @@ JXG.createSlider = function (board, parents, attributes) {
527
527
  highLine: l2
528
528
  };
529
529
  p3.inherits.push(p1, p2, l1, l2);
530
+ // Remove inherits to avoid circular inherits.
531
+ l1.inherits = [];
532
+ l2.inherits = [];
530
533
 
531
534
  if (withTicks) {
532
535
  ti.dump = false;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Carsten Miller,
5
5
  Alfred Wassermann
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Carsten Miller,
5
5
  Alfred Wassermann
package/src/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  // Definitions by: David Holmes https://github.com/geometryzen
10
10
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
11
11
  //
12
- // Copyright 2015-2023 David Holmes, https://github.com/geometryzen
12
+ // Copyright 2015-2024 David Holmes, https://github.com/geometryzen
13
13
  //
14
14
 
15
15
  /**
package/src/jsxgraph.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -42,7 +42,7 @@
42
42
  import JXG from "./jxg.js";
43
43
  import Env from "./utils/env.js";
44
44
  import Type from "./utils/type.js";
45
- import Mat from "./math/math.js";
45
+ // import Mat from "./math/math.js";
46
46
  import Board from "./base/board.js";
47
47
  import FileReader from "./reader/file.js";
48
48
  import Options from "./options.js";
@@ -350,8 +350,10 @@ JXG.JSXGraph = {
350
350
  // Size of HTML div.
351
351
  // If zero, the size is set to a small value to avoid
352
352
  // division by zero.
353
- w = Math.max(parseInt(dimensions.width, 10), Mat.eps);
354
- h = Math.max(parseInt(dimensions.height, 10), Mat.eps);
353
+ // w = Math.max(parseInt(dimensions.width, 10), Mat.eps);
354
+ // h = Math.max(parseInt(dimensions.height, 10), Mat.eps);
355
+ w = parseInt(dimensions.width, 10);
356
+ h = parseInt(dimensions.height, 10);
355
357
 
356
358
  if (Type.exists(bbox) && attr.keepaspectratio) {
357
359
  /*
package/src/jxg.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
package/src/math/bqdt.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
package/src/math/clip.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1569,7 +1569,7 @@ JXG.extend(
1569
1569
  return func;
1570
1570
  },
1571
1571
 
1572
- otherIntersectionFunction: function(input, others, alwaysintersect, precision) {
1572
+ otherIntersectionFunction: function (input, others, alwaysintersect, precision) {
1573
1573
  var func, board,
1574
1574
  el1, el2,
1575
1575
  that = this;
@@ -1577,22 +1577,22 @@ JXG.extend(
1577
1577
  el1 = input[0];
1578
1578
  el2 = input[1];
1579
1579
  board = el1.board;
1580
- func = function() {
1580
+ func = function () {
1581
1581
  var i, k, c, d,
1582
1582
  isClose,
1583
1583
  le = others.length,
1584
1584
  eps = Type.evaluate(precision);
1585
1585
 
1586
1586
  for (i = le; i >= 0; i--) {
1587
- if (el1.elementClass === Const.OBJECT_CLASS_CIRCLE &&
1587
+ if (el1.elementClass === Const.OBJECT_CLASS_CIRCLE &&
1588
1588
  [Const.OBJECT_CLASS_CIRCLE, Const.OBJECT_CLASS_LINE].indexOf(el2.elementClass) >= 0) {
1589
1589
  // circle, circle|line
1590
1590
  c = that.meet(el1.stdform, el2.stdform, i, board);
1591
- } else if (el1.elementClass === Const.OBJECT_CLASS_CURVE &&
1591
+ } else if (el1.elementClass === Const.OBJECT_CLASS_CURVE &&
1592
1592
  [Const.OBJECT_CLASS_CURVE, Const.OBJECT_CLASS_CIRCLE].indexOf(el2.elementClass) >= 0) {
1593
1593
  // curve, circle|curve
1594
1594
  c = that.meetCurveCurve(el1, el2, i, 0, board, 'segment');
1595
- } else if (el1.elementClass === Const.OBJECT_CLASS_CURVE && el2.elementClass === Const.OBJECT_CLASS_LINE) {
1595
+ } else if (el1.elementClass === Const.OBJECT_CLASS_CURVE && el2.elementClass === Const.OBJECT_CLASS_LINE) {
1596
1596
  // curve, line
1597
1597
  if (Type.exists(el1.dataX)) {
1598
1598
  c = JXG.Math.Geometry.meetCurveLine(el1, el2, i, el1.board, Type.evaluate(alwaysintersect));
@@ -1608,7 +1608,7 @@ JXG.extend(
1608
1608
  d = c.distance(JXG.COORDS_BY_USER, others[k].coords);
1609
1609
  if (d < eps) {
1610
1610
  isClose = true;
1611
- }
1611
+ }
1612
1612
  }
1613
1613
  if (!isClose) {
1614
1614
  // We are done, the intersection is away from any other
@@ -2375,7 +2375,7 @@ JXG.extend(
2375
2375
  meetPlaneSphere: function (el1, el2) {
2376
2376
  var dis = function () {
2377
2377
  return (
2378
- el1.normal[0] * el2.center.X()
2378
+ el1.normal[0] * el2.center.X()
2379
2379
  + el1.normal[1] * el2.center.Y()
2380
2380
  + el1.normal[2] * el2.center.Z()
2381
2381
  - el1.d
@@ -2385,13 +2385,13 @@ JXG.extend(
2385
2385
  [
2386
2386
  // Center
2387
2387
  function () {
2388
- return el2.center.X() - dis()*el1.normal[0];
2388
+ return el2.center.X() - dis() * el1.normal[0];
2389
2389
  },
2390
2390
  function () {
2391
- return el2.center.Y() - dis()*el1.normal[1];
2391
+ return el2.center.Y() - dis() * el1.normal[1];
2392
2392
  },
2393
2393
  function () {
2394
- return el2.center.Z() - dis()*el1.normal[2];
2394
+ return el2.center.Z() - dis() * el1.normal[2];
2395
2395
  }
2396
2396
  ],
2397
2397
  [
@@ -2402,34 +2402,34 @@ JXG.extend(
2402
2402
  ],
2403
2403
  function () {
2404
2404
  // Radius (returns NaN if spheres don't touch)
2405
- let r = el2.Radius(),
2405
+ var r = el2.Radius(),
2406
2406
  s = dis();
2407
- return Math.sqrt(r*r - s*s);
2407
+ return Math.sqrt(r * r - s * s);
2408
2408
  }
2409
2409
  ];
2410
2410
  },
2411
2411
 
2412
2412
  meetSphereSphere: function (el1, el2) {
2413
2413
  var skew = function () {
2414
- let dist = el1.center.distance(el2.center),
2414
+ var dist = el1.center.distance(el2.center),
2415
2415
  r1 = el1.Radius(),
2416
2416
  r2 = el2.Radius();
2417
- return (r1 - r2)*(r1 + r2) / (dist*dist);
2417
+ return (r1 - r2) * (r1 + r2) / (dist * dist);
2418
2418
  };
2419
2419
  return [
2420
2420
  [
2421
2421
  // Center
2422
2422
  function () {
2423
- let s = skew();
2424
- return 0.5*((1-s)*el1.center.X() + (1+s)*el2.center.X());
2423
+ var s = skew();
2424
+ return 0.5 * ((1 - s) * el1.center.X() + (1 + s) * el2.center.X());
2425
2425
  },
2426
2426
  function () {
2427
- let s = skew();
2428
- return 0.5*((1-s)*el1.center.Y() + (1+s)*el2.center.Y());
2427
+ var s = skew();
2428
+ return 0.5 * ((1 - s) * el1.center.Y() + (1 + s) * el2.center.Y());
2429
2429
  },
2430
2430
  function () {
2431
- let s = skew();
2432
- return 0.5*((1-s)*el1.center.Z() + (1+s)*el2.center.Z());
2431
+ var s = skew();
2432
+ return 0.5 * ((1 - s) * el1.center.Z() + (1 + s) * el2.center.Z());
2433
2433
  }
2434
2434
  ],
2435
2435
  [
@@ -2440,11 +2440,11 @@ JXG.extend(
2440
2440
  ],
2441
2441
  function () {
2442
2442
  // Radius (returns NaN if spheres don't touch)
2443
- let dist = el1.center.distance(el2.center),
2443
+ var dist = el1.center.distance(el2.center),
2444
2444
  r1 = el1.Radius(),
2445
2445
  r2 = el2.Radius(),
2446
2446
  s = skew(),
2447
- rIxnSq = 0.5*(r1*r1 + r2*r2 - 0.5*dist*dist*(1 + s*s));
2447
+ rIxnSq = 0.5 * (r1 * r1 + r2 * r2 - 0.5 * dist * dist * (1 + s * s));
2448
2448
  return Math.sqrt(rIxnSq);
2449
2449
  }
2450
2450
  ];
@@ -2854,28 +2854,19 @@ JXG.extend(
2854
2854
  * @param {Number} sgn Wither 1 or -1. Needed for minor and major arcs. In case of doubt, use 1.
2855
2855
  */
2856
2856
  bezierArc: function (A, B, C, withLegs, sgn) {
2857
- var p1,
2858
- p2,
2859
- p3,
2860
- p4,
2857
+ var p1, p2, p3, p4,
2861
2858
  r,
2862
- phi,
2863
- beta,
2864
- PI2 = Math.PI * 0.5,
2859
+ phi, beta, delta,
2860
+ // PI2 = Math.PI * 0.5,
2865
2861
  x = B[1],
2866
2862
  y = B[2],
2867
2863
  z = B[0],
2868
2864
  dataX = [],
2869
2865
  dataY = [],
2870
- co,
2871
- si,
2872
- ax,
2873
- ay,
2874
- bx,
2875
- by,
2876
- k,
2877
- v,
2878
- d,
2866
+ co, si,
2867
+ ax, ay,
2868
+ bx, by,
2869
+ k, v, d,
2879
2870
  matrix;
2880
2871
 
2881
2872
  r = this.distance(B, A);
@@ -2889,6 +2880,12 @@ JXG.extend(
2889
2880
  phi = 2 * Math.PI - phi;
2890
2881
  }
2891
2882
 
2883
+ // Always divide the arc into four Bezier arcs.
2884
+ // Otherwise, the position of gliders on this arc
2885
+ // will be wrong.
2886
+ delta = phi / 4;
2887
+
2888
+
2892
2889
  p1 = A;
2893
2890
  p1[1] /= p1[0];
2894
2891
  p1[2] /= p1[0];
@@ -2905,9 +2902,16 @@ JXG.extend(
2905
2902
  }
2906
2903
 
2907
2904
  while (phi > Mat.eps) {
2908
- if (phi > PI2) {
2909
- beta = PI2;
2910
- phi -= PI2;
2905
+ // if (phi > PI2) {
2906
+ // beta = PI2;
2907
+ // phi -= PI2;
2908
+ // } else {
2909
+ // beta = phi;
2910
+ // phi = 0;
2911
+ // }
2912
+ if (phi > delta) {
2913
+ beta = delta;
2914
+ phi -= delta;
2911
2915
  } else {
2912
2916
  beta = phi;
2913
2917
  phi = 0;
@@ -3112,8 +3116,13 @@ JXG.extend(
3112
3116
 
3113
3117
  var x = point.X(),
3114
3118
  y = point.Y(),
3115
- t = point.position || 0.0,
3116
- result = this.projectCoordsToCurve(x, y, t, curve, board);
3119
+ t = point.position,
3120
+ result;
3121
+
3122
+ if (!Type.exists(t)) {
3123
+ t = Type.evaluate(curve.visProp.curvetype) === 'functiongraph' ? x : 0.0;
3124
+ }
3125
+ result = this.projectCoordsToCurve(x, y, t, curve, board);
3117
3126
 
3118
3127
  // point.position = result[1];
3119
3128
 
@@ -3202,6 +3211,21 @@ JXG.extend(
3202
3211
  newCoordsObj = new Coords(Const.COORDS_BY_USER, newCoords, board);
3203
3212
  } else {
3204
3213
  // 'parameter', 'polar', 'functiongraph'
3214
+
3215
+ if (Type.evaluate(curve.visProp.curvetype) === 'functiongraph') {
3216
+ let dy = Math.abs(y - curve.Y(x));
3217
+ if (!isNaN(dy)) {
3218
+ minX = x - dy;
3219
+ maxX = x + dy;
3220
+ } else {
3221
+ minX = curve.minX();
3222
+ maxX = curve.maxX();
3223
+ }
3224
+ } else {
3225
+ minX = curve.minX();
3226
+ maxX = curve.maxX();
3227
+ }
3228
+
3205
3229
  /** @ignore */
3206
3230
  minfunc = function (t) {
3207
3231
  var dx, dy;
@@ -3215,8 +3239,6 @@ JXG.extend(
3215
3239
 
3216
3240
  f_old = minfunc(t);
3217
3241
  steps = 50;
3218
- minX = curve.minX();
3219
- maxX = curve.maxX();
3220
3242
 
3221
3243
  delta = (maxX - minX) / steps;
3222
3244
  t_new = minX;
@@ -3454,9 +3476,9 @@ JXG.extend(
3454
3476
 
3455
3477
  // adapt simplex size to parameter range
3456
3478
  if (dim === 1) {
3457
- rhobeg = 0.1*(target.range[1] - target.range[0]);
3479
+ rhobeg = 0.1 * (target.range[1] - target.range[0]);
3458
3480
  } else if (dim === 2) {
3459
- rhobeg = 0.1*Math.min(
3481
+ rhobeg = 0.1 * Math.min(
3460
3482
  target.range_u[1] - target.range_u[0],
3461
3483
  target.range_v[1] - target.range_v[0]
3462
3484
  );
@@ -3473,17 +3495,17 @@ JXG.extend(
3473
3495
  zDiff = p[2] - target.Z.apply(null, w);
3474
3496
 
3475
3497
  if (n === 1) {
3476
- con[0] = w[0] - target.range[0];
3498
+ con[0] = w[0] - target.range[0];
3477
3499
  con[1] = -w[0] + target.range[1];
3478
3500
  } else if (n === 2) {
3479
- con[0] = w[0] - target.range_u[0];
3501
+ con[0] = w[0] - target.range_u[0];
3480
3502
  con[1] = -w[0] + target.range_u[1];
3481
- con[2] = w[1] - target.range_v[0];
3503
+ con[2] = w[1] - target.range_v[0];
3482
3504
  con[3] = -w[1] + target.range_v[1];
3483
3505
  }
3484
- return xDiff*xDiff + yDiff*yDiff + zDiff*zDiff;
3506
+ return xDiff * xDiff + yDiff * yDiff + zDiff * zDiff;
3485
3507
  };
3486
- Mat.Nlp.FindMinimum(_minFunc, dim, 2*dim, params, rhobeg, rhoend, iprint, maxfun);
3508
+ Mat.Nlp.FindMinimum(_minFunc, dim, 2 * dim, params, rhobeg, rhoend, iprint, maxfun);
3487
3509
 
3488
3510
  // return [1, target.X(...params), target.Y(...params), target.Z(...params)];
3489
3511
  return [1, target.X.apply(null, params), target.Y.apply(null, params), target.Z.apply(null, params)];
@@ -3511,9 +3533,9 @@ JXG.extend(
3511
3533
 
3512
3534
  // adapt simplex size to parameter range
3513
3535
  if (dim === 1) {
3514
- rhobeg = 0.1*(target.range[1] - target.range[0]);
3536
+ rhobeg = 0.1 * (target.range[1] - target.range[0]);
3515
3537
  } else if (dim === 2) {
3516
- rhobeg = 0.1*Math.min(
3538
+ rhobeg = 0.1 * Math.min(
3517
3539
  target.range_u[1] - target.range_u[0],
3518
3540
  target.range_v[1] - target.range_v[0]
3519
3541
  );
@@ -3529,27 +3551,27 @@ JXG.extend(
3529
3551
  // target.Z(...w)
3530
3552
  // ],
3531
3553
  var c3d = [
3532
- 1,
3533
- target.X.apply(null, w),
3534
- target.Y.apply(null, w),
3535
- target.Z.apply(null, w)
3536
- ],
3554
+ 1,
3555
+ target.X.apply(null, w),
3556
+ target.Y.apply(null, w),
3557
+ target.Z.apply(null, w)
3558
+ ],
3537
3559
  c2d = target.view.project3DTo2D(c3d),
3538
3560
  xDiff = pScr[0] - c2d[1],
3539
3561
  yDiff = pScr[1] - c2d[2];
3540
3562
 
3541
3563
  if (n === 1) {
3542
- con[0] = w[0] - target.range[0];
3564
+ con[0] = w[0] - target.range[0];
3543
3565
  con[1] = -w[0] + target.range[1];
3544
3566
  } else if (n === 2) {
3545
- con[0] = w[0] - target.range_u[0];
3567
+ con[0] = w[0] - target.range_u[0];
3546
3568
  con[1] = -w[0] + target.range_u[1];
3547
- con[2] = w[1] - target.range_v[0];
3569
+ con[2] = w[1] - target.range_v[0];
3548
3570
  con[3] = -w[1] + target.range_v[1];
3549
3571
  }
3550
- return xDiff*xDiff + yDiff*yDiff;
3572
+ return xDiff * xDiff + yDiff * yDiff;
3551
3573
  };
3552
- Mat.Nlp.FindMinimum(_minFunc, dim, 2*dim, params, rhobeg, rhoend, iprint, maxfun);
3574
+ Mat.Nlp.FindMinimum(_minFunc, dim, 2 * dim, params, rhobeg, rhoend, iprint, maxfun);
3553
3575
 
3554
3576
  // return [1, target.X(...params), target.Y(...params), target.Z(...params)];
3555
3577
  return [1, target.X.apply(null, params), target.Y.apply(null, params), target.Z.apply(null, params)];
package/src/math/ia.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -35,25 +35,25 @@ import Mat from "./math.js";
35
35
  import Type from "../utils/type.js";
36
36
 
37
37
  JXG.Math.DoubleBits = function () {
38
- var hasTypedArrays = false,
39
- DOUBLE_VIEW = new Float64Array(1),
38
+ var DOUBLE_VIEW = new Float64Array(1),
40
39
  UINT_VIEW = new Uint32Array(DOUBLE_VIEW.buffer),
41
40
  doubleBitsLE,
42
41
  toDoubleLE,
43
42
  lowUintLE,
44
43
  highUintLE,
44
+ // doubleBits,
45
+ // toDouble,
46
+ // lowUint,
47
+ // highUint,
48
+ // hasTypedArrays = false,
45
49
  doubleBitsBE,
46
50
  toDoubleBE,
47
51
  lowUintBE,
48
- highUintBE,
49
- doubleBits,
50
- toDouble,
51
- lowUint,
52
- highUint;
52
+ highUintBE;
53
53
 
54
54
  if (Float64Array !== undefined) {
55
55
  DOUBLE_VIEW[0] = 1.0;
56
- hasTypedArrays = true;
56
+ // hasTypedArrays = true;
57
57
  if (UINT_VIEW[1] === 0x3ff00000) {
58
58
  // Use little endian
59
59
  doubleBitsLE = function (n) {
@@ -81,7 +81,7 @@ JXG.Math.DoubleBits = function () {
81
81
  this.lo = lowUintLE;
82
82
  this.hi = highUintLE;
83
83
  } else if (UINT_VIEW[0] === 0x3ff00000) {
84
- //Use big endian
84
+ // Use big endian
85
85
  doubleBitsBE = function (n) {
86
86
  DOUBLE_VIEW[0] = n;
87
87
  return [UINT_VIEW[1], UINT_VIEW[0]];
@@ -107,8 +107,8 @@ JXG.Math.DoubleBits = function () {
107
107
  this.pack = toDoubleBE;
108
108
  this.lo = lowUintBE;
109
109
  this.hi = highUintBE;
110
- } else {
111
- hasTypedArrays = false;
110
+ // } else {
111
+ // hasTypedArrays = false;
112
112
  }
113
113
  }
114
114
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2023
2
+ Copyright 2008-2024
3
3
  Matthias Ehmann,
4
4
  Carsten Miller,
5
5
  Alfred Wassermann