jsxgraph 1.14.0 → 1.14.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/CHANGELOG.md +33 -3
- package/distrib/docs/3d_linspace3d.js.html +16 -10
- package/distrib/docs/3d_point3d.js.html +0 -5
- package/distrib/docs/3d_sphere3d.js.html +92 -69
- package/distrib/docs/3d_view3d.js.html +24 -16
- package/distrib/docs/Angle.html +7 -7
- package/distrib/docs/CircumcircleSector.html +2 -2
- package/distrib/docs/Conic.html +1 -1
- package/distrib/docs/Ellipse.html +23 -1
- package/distrib/docs/Hyperbola.html +24 -1
- package/distrib/docs/JXG.Board.infobox.html +1 -1
- package/distrib/docs/JXG.Board_.html +130 -130
- package/distrib/docs/JXG.CanvasRenderer.html +10 -10
- package/distrib/docs/JXG.Composition.html +3 -3
- package/distrib/docs/JXG.GeometryElement.html +26 -26
- package/distrib/docs/JXG.Math.Numerics.html +45 -47
- package/distrib/docs/JXG.Math.Statistics.html +14 -15
- package/distrib/docs/JXG.Math.Tiling.html +3 -7
- package/distrib/docs/JXG.Math.html +101 -83
- package/distrib/docs/JXG.Point3D.html +2 -2
- package/distrib/docs/JXG.SVGRenderer.html +12 -12
- package/distrib/docs/JXG.Sphere3D.html +1255 -2
- package/distrib/docs/JXG.View3D.html +29 -29
- package/distrib/docs/JXG.html +20 -20
- package/distrib/docs/MajorSector.html +1 -1
- package/distrib/docs/MinorSector.html +1 -1
- package/distrib/docs/NonReflexAngle.html +1 -1
- package/distrib/docs/Parabola.html +1 -1
- package/distrib/docs/Point3D.html +1 -1
- package/distrib/docs/ReflexAngle.html +1 -1
- package/distrib/docs/Sector.html +12 -12
- package/distrib/docs/Sphere3D.html +17 -1
- package/distrib/docs/View3D.html +1 -1
- package/distrib/docs/base_board.js.html +63 -13
- package/distrib/docs/base_composition.js.html +3 -3
- package/distrib/docs/base_constants.js.html +1 -1
- package/distrib/docs/base_element.js.html +2 -1
- package/distrib/docs/base_text.js.html +2 -2
- package/distrib/docs/element_conic.js.html +35 -1
- package/distrib/docs/element_sector.js.html +6 -3
- package/distrib/docs/index.html +1 -1
- package/distrib/docs/math_math.js.html +64 -35
- package/distrib/docs/math_numerics.js.html +13 -12
- package/distrib/docs/math_statistics.js.html +19 -19
- package/distrib/docs/math_tiling.js.html +6 -288
- package/distrib/docs/parser_jessiecode.js.html +1 -1
- package/distrib/docs/renderer_canvas.js.html +7 -6
- package/distrib/docs/renderer_svg.js.html +15 -7
- package/distrib/docs/scripts/jsxgraphcore.js +2 -2
- package/distrib/docs/styles/jsxgraph.css +1 -1
- package/distrib/docs/utils_type.js.html +11 -4
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +11 -0
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraph.css +1 -1
- package/distrib/jsxgraphcore.js +2 -2
- package/distrib/jsxgraphcore.mjs +2 -2
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +380 -496
- package/distrib/jsxgraphsrc.mjs +380 -496
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/package.json +10 -12
- package/src/3d/linspace3d.js +16 -10
- package/src/3d/point3d.js +0 -5
- package/src/3d/sphere3d.js +92 -69
- package/src/3d/view3d.js +24 -16
- package/src/base/board.js +63 -13
- package/src/base/composition.js +3 -3
- package/src/base/constants.js +1 -1
- package/src/base/element.js +2 -1
- package/src/base/text.js +2 -2
- package/src/element/conic.js +35 -1
- package/src/element/sector.js +6 -3
- package/src/index.d.ts +11 -0
- package/src/math/math.js +64 -35
- package/src/math/numerics.js +13 -12
- package/src/math/statistics.js +19 -19
- package/src/math/tiling.js +6 -288
- package/src/parser/jessiecode.js +1 -1
- package/src/renderer/canvas.js +7 -6
- package/src/renderer/svg.js +15 -7
- package/src/utils/type.js +11 -4
- package/src/unused/bst.js +0 -475
- package/src/unused/heap.js +0 -135
- package/src/unused/locus.js +0 -162
- package/src/unused/server/JXG.py +0 -74
- package/src/unused/server/JXGServer.py +0 -94
- package/src/unused/server/JXGServerModule.py +0 -9
- package/src/unused/server/README.md +0 -63
- package/src/unused/server/RStats.py +0 -45
- package/src/unused/server/YahooFinance.py +0 -81
- package/src/unused/server/fft.py +0 -136
- package/src/unused/server/geoloci.py +0 -210
- package/src/unused/server/jxggroebner.py +0 -219
- package/src/unused/server/jxgtestplugin.py +0 -19
- package/src/unused/server/server.js +0 -280
- package/src/unused/sketch.js +0 -2895
- package/src/unused/symbolic.js +0 -416
package/distrib/jsxgraphsrc.js
CHANGED
|
@@ -60,7 +60,7 @@ return /******/ (function() { // webpackBootstrap
|
|
|
60
60
|
|
|
61
61
|
var major = 1,
|
|
62
62
|
minor = 14,
|
|
63
|
-
patch =
|
|
63
|
+
patch = 1,
|
|
64
64
|
add = '', // 'dev' 'beta1'
|
|
65
65
|
version = major + '.' + minor + '.' + patch + (add ? '-' + add : ''),
|
|
66
66
|
constants;
|
|
@@ -5519,7 +5519,8 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.extend(
|
|
|
5519
5519
|
} else if (this.elementClass === _constants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.OBJECT_CLASS_CIRCLE) {
|
|
5520
5520
|
x = this.center.X();
|
|
5521
5521
|
y = this.center.Y();
|
|
5522
|
-
|
|
5522
|
+
r = this.Radius(); // this.radius
|
|
5523
|
+
bb = [x - r, y + r, x + r, y - r];
|
|
5523
5524
|
} else if (this.elementClass === _constants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.OBJECT_CLASS_CURVE) {
|
|
5524
5525
|
le = this.points.length;
|
|
5525
5526
|
if (le === 0) {
|
|
@@ -7735,8 +7736,8 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.createHTMLSlider = func
|
|
|
7735
7736
|
}
|
|
7736
7737
|
|
|
7737
7738
|
// Backwards compatibility
|
|
7738
|
-
attr.anchor = attr.parent
|
|
7739
|
-
attr.fixed = attr.fixed
|
|
7739
|
+
attr.anchor = _utils_type_js__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A.def(attr.parent, attr.anchor);
|
|
7740
|
+
attr.fixed = _utils_type_js__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A.def(attr.fixed, true);
|
|
7740
7741
|
|
|
7741
7742
|
par = [
|
|
7742
7743
|
parents[0][0],
|
|
@@ -15697,10 +15698,10 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15697
15698
|
}),
|
|
15698
15699
|
|
|
15699
15700
|
/**
|
|
15700
|
-
* Calculates the cosine
|
|
15701
|
+
* Calculates the hyperbolic cosine of \\(x\\).
|
|
15701
15702
|
* @function
|
|
15702
15703
|
* @param {Number} x The number the cosine hyperbolicus will be calculated of.
|
|
15703
|
-
* @returns {Number}
|
|
15704
|
+
* @returns {Number} Hyperbolic cosine of the given value.
|
|
15704
15705
|
*/
|
|
15705
15706
|
cosh:
|
|
15706
15707
|
Math.cosh ||
|
|
@@ -15709,10 +15710,10 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15709
15710
|
},
|
|
15710
15711
|
|
|
15711
15712
|
/**
|
|
15712
|
-
*
|
|
15713
|
+
* Hyperbolic sine of \\(x\\).
|
|
15713
15714
|
* @function
|
|
15714
|
-
* @param {Number} x The number the sine
|
|
15715
|
-
* @returns {Number}
|
|
15715
|
+
* @param {Number} x The number the hyperbolic sine will be calculated of.
|
|
15716
|
+
* @returns {Number} Hyperbolic sine of the given value.
|
|
15716
15717
|
*/
|
|
15717
15718
|
sinh:
|
|
15718
15719
|
Math.sinh ||
|
|
@@ -15721,7 +15722,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15721
15722
|
},
|
|
15722
15723
|
|
|
15723
15724
|
/**
|
|
15724
|
-
*
|
|
15725
|
+
* Inverse hyperbolic cosine of a number.
|
|
15725
15726
|
* @function
|
|
15726
15727
|
* @param {Number} x
|
|
15727
15728
|
* @returns {Number}
|
|
@@ -15733,7 +15734,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15733
15734
|
},
|
|
15734
15735
|
|
|
15735
15736
|
/**
|
|
15736
|
-
*
|
|
15737
|
+
* Inverse hyperbolic sine of a number
|
|
15737
15738
|
* @function
|
|
15738
15739
|
* @param {Number} x
|
|
15739
15740
|
* @returns {Number}
|
|
@@ -15810,7 +15811,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15810
15811
|
},
|
|
15811
15812
|
|
|
15812
15813
|
/**
|
|
15813
|
-
* Computes cube root of real number
|
|
15814
|
+
* Computes cube root of real number.
|
|
15814
15815
|
* Polyfill for Math.cbrt().
|
|
15815
15816
|
*
|
|
15816
15817
|
* @function
|
|
@@ -15930,7 +15931,11 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15930
15931
|
},
|
|
15931
15932
|
|
|
15932
15933
|
/**
|
|
15933
|
-
* A square & multiply algorithm to compute base to the power of exponent
|
|
15934
|
+
* A square & multiply algorithm to compute `base` to the power of `exponent`.
|
|
15935
|
+
* That is, for base \\(b\\) and integer exponent \\(e\\) it is a fast method to compute
|
|
15936
|
+
* \\[ b^e .\\]
|
|
15937
|
+
* For non-integer values of `exponent`, JavaScript's `Math.pow` is used.
|
|
15938
|
+
*
|
|
15934
15939
|
* Implementated by Wolfgang Riedl.
|
|
15935
15940
|
*
|
|
15936
15941
|
* @param {Number} base
|
|
@@ -15965,16 +15970,17 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15965
15970
|
},
|
|
15966
15971
|
|
|
15967
15972
|
/**
|
|
15968
|
-
* Greatest common divisor (gcd) of two numbers.
|
|
15969
|
-
* See {@link
|
|
15973
|
+
* Greatest common divisor (gcd) of two finite, non-zero integer numbers.
|
|
15974
|
+
* See {@link https://rosettacode.org/wiki/Greatest_common_divisor#JavaScript rosettacode.org}.
|
|
15970
15975
|
*
|
|
15971
|
-
* @param {Number} a First number
|
|
15972
|
-
* @param {Number} b Second number
|
|
15973
|
-
* @returns {Number}
|
|
15976
|
+
* @param {Number} a First number, not zero, Infinity, or NaN
|
|
15977
|
+
* @param {Number} b Second number, not zero, Infinity, or NaN
|
|
15978
|
+
* @returns {Number} gcd(a, b) if a and b are finite, non-zero numbers, NaN else.
|
|
15979
|
+
* @see JXG.Math#lcm
|
|
15974
15980
|
*/
|
|
15975
15981
|
gcd: function (a, b) {
|
|
15976
15982
|
var tmp,
|
|
15977
|
-
endless =
|
|
15983
|
+
endless = 100000;
|
|
15978
15984
|
|
|
15979
15985
|
a = Math.abs(a);
|
|
15980
15986
|
b = Math.abs(b);
|
|
@@ -15982,13 +15988,24 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15982
15988
|
if (!(_utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(a) && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(b))) {
|
|
15983
15989
|
return NaN;
|
|
15984
15990
|
}
|
|
15991
|
+
if (isNaN(a) || isNaN(b) || a === Infinity || b === Infinity) {
|
|
15992
|
+
return NaN;
|
|
15993
|
+
}
|
|
15994
|
+
if (a === 0 || b === 0) {
|
|
15995
|
+
return NaN;
|
|
15996
|
+
}
|
|
15997
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
15998
|
+
_jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.warn('JSXGraph: JXG.Math.gcd requires integer parameters');
|
|
15999
|
+
return NaN;
|
|
16000
|
+
}
|
|
16001
|
+
|
|
15985
16002
|
if (b > a) {
|
|
15986
16003
|
tmp = a;
|
|
15987
16004
|
a = b;
|
|
15988
16005
|
b = tmp;
|
|
15989
16006
|
}
|
|
15990
16007
|
|
|
15991
|
-
while (endless) {
|
|
16008
|
+
while (endless > 0) {
|
|
15992
16009
|
a %= b;
|
|
15993
16010
|
if (a === 0) {
|
|
15994
16011
|
return b;
|
|
@@ -15997,15 +16014,18 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15997
16014
|
if (b === 0) {
|
|
15998
16015
|
return a;
|
|
15999
16016
|
}
|
|
16017
|
+
endless--;
|
|
16000
16018
|
}
|
|
16001
16019
|
},
|
|
16002
16020
|
|
|
16003
16021
|
/**
|
|
16004
|
-
* Least common multiple (lcm) of two numbers.
|
|
16022
|
+
* Least common multiple (lcm) of two finite integer numbers.
|
|
16023
|
+
* lcm(0, a) is defined as 0.
|
|
16005
16024
|
*
|
|
16006
16025
|
* @param {Number} a First number
|
|
16007
16026
|
* @param {Number} b Second number
|
|
16008
|
-
* @returns {Number}
|
|
16027
|
+
* @returns {Number} lcm(a, b) if a and b are finite integer numbers, NaN else.
|
|
16028
|
+
* @see JXG.Math#gcd
|
|
16009
16029
|
*/
|
|
16010
16030
|
lcm: function (a, b) {
|
|
16011
16031
|
var ret;
|
|
@@ -16013,6 +16033,16 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16013
16033
|
if (!(_utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(a) && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(b))) {
|
|
16014
16034
|
return NaN;
|
|
16015
16035
|
}
|
|
16036
|
+
if (isNaN(a) || isNaN(b) || Math.abs(a) === Infinity || Math.abs(b) === Infinity) {
|
|
16037
|
+
return NaN;
|
|
16038
|
+
}
|
|
16039
|
+
if (a === 0 || b === 0) {
|
|
16040
|
+
return 0;
|
|
16041
|
+
}
|
|
16042
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
16043
|
+
_jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.warn('JSXGraph: JXG.Math.gcd requires integer parameters');
|
|
16044
|
+
return NaN;
|
|
16045
|
+
}
|
|
16016
16046
|
|
|
16017
16047
|
ret = a * b;
|
|
16018
16048
|
if (ret !== 0) {
|
|
@@ -16198,7 +16228,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16198
16228
|
/* ******************** Comparisons and logical operators ************** */
|
|
16199
16229
|
|
|
16200
16230
|
/**
|
|
16201
|
-
* Logical test: a < b
|
|
16231
|
+
* Logical test: `a < b`?
|
|
16202
16232
|
*
|
|
16203
16233
|
* @param {Number} a
|
|
16204
16234
|
* @param {Number} b
|
|
@@ -16209,7 +16239,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16209
16239
|
},
|
|
16210
16240
|
|
|
16211
16241
|
/**
|
|
16212
|
-
* Logical test: a <= b
|
|
16242
|
+
* Logical test: `a <= b`?
|
|
16213
16243
|
*
|
|
16214
16244
|
* @param {Number} a
|
|
16215
16245
|
* @param {Number} b
|
|
@@ -16220,7 +16250,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16220
16250
|
},
|
|
16221
16251
|
|
|
16222
16252
|
/**
|
|
16223
|
-
* Logical test: a > b
|
|
16253
|
+
* Logical test: `a > b`?
|
|
16224
16254
|
*
|
|
16225
16255
|
* @param {Number} a
|
|
16226
16256
|
* @param {Number} b
|
|
@@ -16231,7 +16261,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16231
16261
|
},
|
|
16232
16262
|
|
|
16233
16263
|
/**
|
|
16234
|
-
* Logical test: a >= b
|
|
16264
|
+
* Logical test: `a >= b`?
|
|
16235
16265
|
*
|
|
16236
16266
|
* @param {Number} a
|
|
16237
16267
|
* @param {Number} b
|
|
@@ -16242,7 +16272,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16242
16272
|
},
|
|
16243
16273
|
|
|
16244
16274
|
/**
|
|
16245
|
-
* Logical test: a === b
|
|
16275
|
+
* Logical test: `a === b`?
|
|
16246
16276
|
*
|
|
16247
16277
|
* @param {Number} a
|
|
16248
16278
|
* @param {Number} b
|
|
@@ -16253,7 +16283,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16253
16283
|
},
|
|
16254
16284
|
|
|
16255
16285
|
/**
|
|
16256
|
-
* Logical test: a !== b
|
|
16286
|
+
* Logical test: `a !== b`?
|
|
16257
16287
|
*
|
|
16258
16288
|
* @param {Number} a
|
|
16259
16289
|
* @param {Number} b
|
|
@@ -16264,7 +16294,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16264
16294
|
},
|
|
16265
16295
|
|
|
16266
16296
|
/**
|
|
16267
|
-
* Logical operator: a && b
|
|
16297
|
+
* Logical operator: `a && b`?
|
|
16268
16298
|
*
|
|
16269
16299
|
* @param {Boolean} a
|
|
16270
16300
|
* @param {Boolean} b
|
|
@@ -16275,7 +16305,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16275
16305
|
},
|
|
16276
16306
|
|
|
16277
16307
|
/**
|
|
16278
|
-
* Logical operator:
|
|
16308
|
+
* Logical operator: `!a`?
|
|
16279
16309
|
*
|
|
16280
16310
|
* @param {Boolean} a
|
|
16281
16311
|
* @returns {Boolean}
|
|
@@ -16285,7 +16315,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16285
16315
|
},
|
|
16286
16316
|
|
|
16287
16317
|
/**
|
|
16288
|
-
* Logical operator: a || b
|
|
16318
|
+
* Logical operator: `a || b`?
|
|
16289
16319
|
*
|
|
16290
16320
|
* @param {Boolean} a
|
|
16291
16321
|
* @param {Boolean} b
|
|
@@ -16296,7 +16326,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16296
16326
|
},
|
|
16297
16327
|
|
|
16298
16328
|
/**
|
|
16299
|
-
* Logical operator: either a or b
|
|
16329
|
+
* Logical operator: either `a` or `b`?
|
|
16300
16330
|
*
|
|
16301
16331
|
* @param {Boolean} a
|
|
16302
16332
|
* @param {Boolean} b
|
|
@@ -16375,7 +16405,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16375
16405
|
/* *************************** Normalize *************************** */
|
|
16376
16406
|
|
|
16377
16407
|
/**
|
|
16378
|
-
* Normalize the standard form [c, b0, b1, a, k, r, q0, q1]
|
|
16408
|
+
* Normalize the standard form `[c, b0, b1, a, k, r, q0, q1]`.
|
|
16379
16409
|
* @private
|
|
16380
16410
|
* @param {Array} stdform The standard form to be normalized.
|
|
16381
16411
|
* @returns {Array} The normalized standard form.
|
|
@@ -16446,13 +16476,13 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16446
16476
|
},
|
|
16447
16477
|
|
|
16448
16478
|
/**
|
|
16449
|
-
* Theorem of Vieta: Given a set of simple zeroes x_0,
|
|
16450
|
-
* of a polynomial f, compute the coefficients s_k, (k=0
|
|
16451
|
-
* of the polynomial of the form
|
|
16479
|
+
* Theorem of Vieta: Given a set of simple zeroes \\(x_0, \ldots, x_n\\)
|
|
16480
|
+
* of a polynomial \\(f\\), compute the coefficients \\(s_k\\), \\(k=0, \ldots, n-1\\),
|
|
16481
|
+
* of the polynomial of the form
|
|
16482
|
+
* \\[ f(x) = (x-x_0)\cdots(x-x_n) = x^n + \sum_{k=1}^{n} (-1)^k s_{k-1} x^{n-k} \\]
|
|
16483
|
+
*
|
|
16484
|
+
* See {@link https://en.wikipedia.org/wiki/Vieta%27s_formulas}
|
|
16452
16485
|
*
|
|
16453
|
-
* f(x) = (x-x_0)*...*(x-x_n) =
|
|
16454
|
-
* x^n + sum_{k=1}^{n} (-1)^(k) s_{k-1} x^(n-k)
|
|
16455
|
-
* </p>
|
|
16456
16486
|
* @param {Array} x Simple zeroes of the polynomial.
|
|
16457
16487
|
* @returns {Array} Coefficients of the polynomial.
|
|
16458
16488
|
*
|
|
@@ -17001,22 +17031,20 @@ _math_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A.Numerics = {
|
|
|
17001
17031
|
* Calculates the integral of function f over interval using Romberg iteration.
|
|
17002
17032
|
* @param {Array} interval The integration interval, e.g. [0, 3].
|
|
17003
17033
|
* @param {function} f A function which takes one argument of type number and returns a number.
|
|
17004
|
-
* @param {Object} [config] The algorithm setup. Accepted properties are max_iterations of type number and precision eps
|
|
17034
|
+
* @param {Object} [config] The algorithm setup. Accepted properties are `max_iterations` of type number and precision `eps`.
|
|
17005
17035
|
* @param {Number} [config.max_iterations=20]
|
|
17006
17036
|
* @param {Number} [config.eps=0.0000001]
|
|
17007
17037
|
* @returns {Number} Integral value of f over interval
|
|
17008
17038
|
* @example
|
|
17009
|
-
*
|
|
17010
|
-
* return x*x;
|
|
17011
|
-
* }
|
|
17039
|
+
* var f = (x) => x * x;
|
|
17012
17040
|
*
|
|
17013
|
-
* //
|
|
17014
|
-
* var area1 = JXG.Math.Numerics.Romberg([0,
|
|
17041
|
+
* // Calculates integral of `f` from 0 to 3.
|
|
17042
|
+
* var area1 = JXG.Math.Numerics.Romberg([0, 3], f);
|
|
17015
17043
|
*
|
|
17016
|
-
* //
|
|
17017
|
-
* var area2 = JXG.Math.Numerics.Romberg([0,
|
|
17044
|
+
* // The same with an anonymous function
|
|
17045
|
+
* var area2 = JXG.Math.Numerics.Romberg([0, 3], function (x) { return x * x; });
|
|
17018
17046
|
*
|
|
17019
|
-
* //
|
|
17047
|
+
* // Use trapez rule with maximum of 16 iterations or stop if the precision 0.0001 has been reached.
|
|
17020
17048
|
* var area3 = JXG.Math.Numerics.Romberg([0, 2], f,
|
|
17021
17049
|
* {max_iterations: 16, eps: 0.0001});
|
|
17022
17050
|
* @memberof JXG.Math.Numerics
|
|
@@ -17033,8 +17061,11 @@ _math_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A.Numerics = {
|
|
|
17033
17061
|
p = [],
|
|
17034
17062
|
integral = 0.0,
|
|
17035
17063
|
last = Infinity,
|
|
17036
|
-
m
|
|
17037
|
-
|
|
17064
|
+
m, eps;
|
|
17065
|
+
|
|
17066
|
+
config = _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.def(config, {});
|
|
17067
|
+
m = config && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(config.max_iterations) ? config.max_iterations : 20;
|
|
17068
|
+
eps = config && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(config.eps) ? config.eps : (config.eps || 0.0000001);
|
|
17038
17069
|
|
|
17039
17070
|
a = interval[0];
|
|
17040
17071
|
b = interval[1];
|
|
@@ -17301,7 +17332,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A.Numerics = {
|
|
|
17301
17332
|
xm = 0.5 * (b - a);
|
|
17302
17333
|
xp = 0.5 * (b + a);
|
|
17303
17334
|
|
|
17304
|
-
if (n &
|
|
17335
|
+
if ((n & 1) === 1) {
|
|
17305
17336
|
// n odd
|
|
17306
17337
|
result = w[0] * f(xp);
|
|
17307
17338
|
for (i = 1; i < m; ++i) {
|
|
@@ -22184,12 +22215,12 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22184
22215
|
* The Theil-Sen estimator can be used to determine a more robust linear regression of a set of sample
|
|
22185
22216
|
* points than least squares regression in {@link JXG.Math.Numerics.regressionPolynomial}.
|
|
22186
22217
|
*
|
|
22187
|
-
* If the function should be applied to an array a of points
|
|
22188
|
-
* JavaScript array.map
|
|
22218
|
+
* If the function should be applied to an array `a` of *points*, a coords array can be generated with
|
|
22219
|
+
* JavaScript `array.map`:
|
|
22189
22220
|
*
|
|
22190
|
-
*
|
|
22221
|
+
* ```
|
|
22191
22222
|
* JXG.Math.Statistics.TheilSenRegression(a.map(el => el.coords));
|
|
22192
|
-
*
|
|
22223
|
+
* ```
|
|
22193
22224
|
*
|
|
22194
22225
|
* @param {Array} coords Array of {@link JXG.Coords}.
|
|
22195
22226
|
* @returns {Array} A stdform array of the regression line.
|
|
@@ -22197,10 +22228,10 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22197
22228
|
*
|
|
22198
22229
|
* @example
|
|
22199
22230
|
* var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-6,6,6,-6], axis : true });
|
|
22200
|
-
* var a=[];
|
|
22201
|
-
* a[0]=board.create('point', [0,0]);
|
|
22202
|
-
* a[1]=board.create('point', [3,0]);
|
|
22203
|
-
* a[2]=board.create('point', [0,3]);
|
|
22231
|
+
* var a = [];
|
|
22232
|
+
* a[0] = board.create('point', [0, 0]);
|
|
22233
|
+
* a[1] = board.create('point', [3, 0]);
|
|
22234
|
+
* a[2] = board.create('point', [0, 3]);
|
|
22204
22235
|
*
|
|
22205
22236
|
* board.create('line', [
|
|
22206
22237
|
* () => JXG.Math.Statistics.TheilSenRegression(a.map(el => el.coords))
|
|
@@ -22254,7 +22285,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22254
22285
|
|
|
22255
22286
|
/**
|
|
22256
22287
|
* Generate values of a standard normal random variable with the Marsaglia polar method, see
|
|
22257
|
-
*
|
|
22288
|
+
* {@link https://en.wikipedia.org/wiki/Marsaglia_polar_method}..
|
|
22258
22289
|
* See also D. E. Knuth, The art of computer programming, vol 2, p. 117.
|
|
22259
22290
|
*
|
|
22260
22291
|
* @param {Number} mean mean value of the normal distribution
|
|
@@ -22344,7 +22375,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22344
22375
|
},
|
|
22345
22376
|
|
|
22346
22377
|
/**
|
|
22347
|
-
* Generate value of a uniform distributed random variable in the interval [a, b]
|
|
22378
|
+
* Generate value of a uniform distributed random variable in the interval `[a, b]`.
|
|
22348
22379
|
* @param {Number} a
|
|
22349
22380
|
* @param {Number} b
|
|
22350
22381
|
* @returns Number
|
|
@@ -22356,7 +22387,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22356
22387
|
|
|
22357
22388
|
/**
|
|
22358
22389
|
* Generate value of a random variable with exponential distribution, i.e.
|
|
22359
|
-
* \\(f(x; \lambda) = \lambda
|
|
22390
|
+
* \\(f(x; \lambda) = \lambda \cdot e^{-\lambda x}\\) if \\(x \geq 0\\) and \\(f(x; \lambda) = 0\\) if \\(x < 0\\).
|
|
22360
22391
|
* See <a href="https://en.wikipedia.org/wiki/Exponential_distribution">https://en.wikipedia.org/wiki/Exponential_distribution</a>.
|
|
22361
22392
|
* Algorithm: D.E. Knuth, TAOCP 2, p. 128.
|
|
22362
22393
|
*
|
|
@@ -22425,7 +22456,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22425
22456
|
|
|
22426
22457
|
/**
|
|
22427
22458
|
* Generate value of a random variable with gamma distribution of order alpha.
|
|
22428
|
-
* See
|
|
22459
|
+
* See {@link https://en.wikipedia.org/wiki/Gamma_distribution}.
|
|
22429
22460
|
* Algorithm: D.E. Knuth, TAOCP 2, p. 129.
|
|
22430
22461
|
|
|
22431
22462
|
* @param {Number} a shape, \\( > 0\\)
|
|
@@ -22541,7 +22572,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22541
22572
|
|
|
22542
22573
|
/**
|
|
22543
22574
|
* Generate value of a random variable with beta distribution with shape parameters alpha and beta.
|
|
22544
|
-
* See
|
|
22575
|
+
* See {@link https://en.wikipedia.org/wiki/Beta_distribution}.
|
|
22545
22576
|
*
|
|
22546
22577
|
* @param {Number} alpha \\(< 0\\)
|
|
22547
22578
|
* @param {Number} beta \\(< 0\\)
|
|
@@ -22564,7 +22595,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22564
22595
|
|
|
22565
22596
|
/**
|
|
22566
22597
|
* Generate value of a random variable with chi-square distribution with k degrees of freedom.
|
|
22567
|
-
* See
|
|
22598
|
+
* See {@link https://en.wikipedia.org/wiki/Chi-squared_distribution}.
|
|
22568
22599
|
*
|
|
22569
22600
|
* @param {Number} k \\(>0\\)
|
|
22570
22601
|
* @returns Number
|
|
@@ -22582,7 +22613,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22582
22613
|
|
|
22583
22614
|
/**
|
|
22584
22615
|
* Generate value of a random variable with F-distribution with d<sub>1</sub> and d<sub>2</sub> degrees of freedom.
|
|
22585
|
-
* See
|
|
22616
|
+
* See {@link https://en.wikipedia.org/wiki/F-distribution}.
|
|
22586
22617
|
* @param {Number} d1 \\(>0\\)
|
|
22587
22618
|
* @param {Number} d2 \\(>0\\)
|
|
22588
22619
|
* @returns Number
|
|
@@ -22604,7 +22635,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22604
22635
|
|
|
22605
22636
|
/**
|
|
22606
22637
|
* Generate value of a random variable with Students-t-distribution with ν degrees of freedom.
|
|
22607
|
-
* See
|
|
22638
|
+
* See {@link https://en.wikipedia.org/wiki/Student%27s_t-distribution}.
|
|
22608
22639
|
* @param {Number} nu \\(>0\\)
|
|
22609
22640
|
* @returns Number
|
|
22610
22641
|
* @memberof JXG.Math.Statistics
|
|
@@ -22625,8 +22656,8 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22625
22656
|
|
|
22626
22657
|
/**
|
|
22627
22658
|
* Generate values for a random variable in binomial distribution with parameters \\(n\\) and \\(p\\).
|
|
22628
|
-
* See
|
|
22629
|
-
* It uses algorithm BG from
|
|
22659
|
+
* See {@link https://en.wikipedia.org/wiki/Binomial_distribution}.
|
|
22660
|
+
* It uses algorithm BG from {@link https://dl.acm.org/doi/pdf/10.1145/42372.42381}.
|
|
22630
22661
|
*
|
|
22631
22662
|
* @param {Number} n Number of trials (n >= 0)
|
|
22632
22663
|
* @param {Number} p Probability (0 <= p <= 1)
|
|
@@ -22750,7 +22781,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22750
22781
|
|
|
22751
22782
|
/**
|
|
22752
22783
|
* Generate values for a random variable in geometric distribution with probability \\(p\\).
|
|
22753
|
-
* See
|
|
22784
|
+
* See {@link https://en.wikipedia.org/wiki/Geometric_distribution}.
|
|
22754
22785
|
*
|
|
22755
22786
|
* @param {Number} p (0 <= p <= 1)
|
|
22756
22787
|
* @returns Number
|
|
@@ -38527,7 +38558,7 @@ upcomingInput:function () {
|
|
|
38527
38558
|
showPosition:function () {
|
|
38528
38559
|
var pre = this.pastInput();
|
|
38529
38560
|
var c = new Array(pre.length + 1).join("-");
|
|
38530
|
-
return pre + this.upcomingInput() + "\n" + c+"^";
|
|
38561
|
+
return _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.escapeHTML(pre + this.upcomingInput() + "\n" + c+"^");
|
|
38531
38562
|
},
|
|
38532
38563
|
next:function () {
|
|
38533
38564
|
if (this.done) {
|
|
@@ -42757,8 +42788,10 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.extend(
|
|
|
42757
42788
|
mergeAttr: function (attr, special, toLower, ignoreUndefinedSpecials) {
|
|
42758
42789
|
var e, e2, o;
|
|
42759
42790
|
|
|
42760
|
-
toLower = toLower || true;
|
|
42761
|
-
|
|
42791
|
+
// toLower = toLower || true;
|
|
42792
|
+
// ignoreUndefinedSpecials || false;
|
|
42793
|
+
toLower = this.def(toLower, true);
|
|
42794
|
+
ignoreUndefinedSpecials = this.def(ignoreUndefinedSpecials, false);
|
|
42762
42795
|
|
|
42763
42796
|
for (e in special) {
|
|
42764
42797
|
if (special.hasOwnProperty(e)) {
|
|
@@ -43231,8 +43264,13 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.extend(
|
|
|
43231
43264
|
* @returns {String}
|
|
43232
43265
|
*/
|
|
43233
43266
|
trimNumber: function (str) {
|
|
43234
|
-
str
|
|
43235
|
-
|
|
43267
|
+
if (str !== '0') {
|
|
43268
|
+
str = str.replace(/^0+/, "");
|
|
43269
|
+
}
|
|
43270
|
+
|
|
43271
|
+
if (str.indexOf('.') >= 0 || str.indexOf(',') >= 0) {
|
|
43272
|
+
str = str.replace(/0+$/, "");
|
|
43273
|
+
}
|
|
43236
43274
|
|
|
43237
43275
|
if (str[str.length - 1] === "." || str[str.length - 1] === ",") {
|
|
43238
43276
|
str = str.slice(0, -1);
|
|
@@ -54352,11 +54390,11 @@ jxg/* default */.A.Complex.C = jxg/* default */.A.C;
|
|
|
54352
54390
|
math/* default */.A.Tiling = {
|
|
54353
54391
|
/**
|
|
54354
54392
|
* Triangulate (partition it into triangles) a given two dimensional domain.
|
|
54355
|
-
* The number of triangles the original rectangle is divided into depends on the parameters stepsU and stepsV
|
|
54356
|
-
* Input are the ranges of u and v, as well as stepsU and stepsV which are static.
|
|
54357
|
-
* If the optional parameter stepsV is not given or is equal to 0, the rectangle is partitioned into
|
|
54393
|
+
* The number of triangles the original rectangle is divided into depends on the parameters` `stepsU` and `stepsV`.
|
|
54394
|
+
* Input are the ranges of \\(u\\) and \\(v\\), as well as `stepsU` and `stepsV` which are static.
|
|
54395
|
+
* If the optional parameter `stepsV` is not given or is equal to 0, the rectangle is partitioned into
|
|
54358
54396
|
* nearly equilateral triangles.
|
|
54359
|
-
* Otherwise, the shape of the triangles depends on the ratio of stepsU / stepsV
|
|
54397
|
+
* Otherwise, the shape of the triangles depends on the ratio of `stepsU / stepsV`.
|
|
54360
54398
|
*
|
|
54361
54399
|
* @param {JXG.ParametricSurface3D|JXG.Plane3D} el element which is displayed using a polyhedron3d.
|
|
54362
54400
|
* From this element its function F is used.
|
|
@@ -54512,8 +54550,8 @@ math/* default */.A.Tiling = {
|
|
|
54512
54550
|
|
|
54513
54551
|
/**
|
|
54514
54552
|
* Rectangulate (partition it into rectangles) a given two dimensional domain.
|
|
54515
|
-
* The number of rectangles the original rectangle is divided into depends on the parameters stepsU and stepsV
|
|
54516
|
-
* Input are the ranges of u and v, as well as stepsU and stepsV which are static.
|
|
54553
|
+
* The number of rectangles the original rectangle is divided into depends on the parameters `stepsU` and `stepsV`.
|
|
54554
|
+
* Input are the ranges of \\(u\\) and \\(v\\), as well as `stepsU` and `stepsV` which are static.
|
|
54517
54555
|
*
|
|
54518
54556
|
* @param {JXG.ParametricSurface3D|JXG.Plane3D} el element which is displayed using a polyhedron3d.
|
|
54519
54557
|
* From this element its function F is used.
|
|
@@ -54637,288 +54675,6 @@ math/* default */.A.Tiling = {
|
|
|
54637
54675
|
}
|
|
54638
54676
|
return [vertices, faces];
|
|
54639
54677
|
}
|
|
54640
|
-
|
|
54641
|
-
// triangulation_old: function (p1, p2, p3, p4, stepsU, stepsV) {
|
|
54642
|
-
// // Vectors used for checking if the given coordinates create a rectangle
|
|
54643
|
-
// var vec1 = [p2[0] - p1[0], p2[1] - p1[1]],
|
|
54644
|
-
// vec2 = [p3[0] - p2[0], p3[1] - p2[1]],
|
|
54645
|
-
// vec3 = [p4[0] - p3[0], p4[1] - p3[1]],
|
|
54646
|
-
// vec4 = [p1[0] - p4[0], p1[1] - p4[1]],
|
|
54647
|
-
|
|
54648
|
-
// coords = [],
|
|
54649
|
-
// faces = [],
|
|
54650
|
-
// width, height,
|
|
54651
|
-
// wSide, hSide,
|
|
54652
|
-
// triangleWidth, triangleHeight,
|
|
54653
|
-
// s1, s2,
|
|
54654
|
-
// i, j,
|
|
54655
|
-
// numRows,
|
|
54656
|
-
// widthX, widthY, heightX, heightY,
|
|
54657
|
-
// oddPoints,
|
|
54658
|
-
// evenPoints;
|
|
54659
|
-
|
|
54660
|
-
// // Check if the given coordinates create a rectangle, otherwise an exception is thrown
|
|
54661
|
-
// if (
|
|
54662
|
-
// vec1[0] * vec4[0] + vec1[1] * vec4[1] !== 0 ||
|
|
54663
|
-
// vec2[0] * vec1[0] + vec2[1] * vec1[1] !== 0 ||
|
|
54664
|
-
// vec3[0] * vec2[0] + vec3[1] * vec2[1] !== 0 ||
|
|
54665
|
-
// vec4[0] * vec3[0] + vec4[1] * vec3[1] !== 0
|
|
54666
|
-
// ) {
|
|
54667
|
-
// throw new Error(" the board created is not rectangle ");
|
|
54668
|
-
// }
|
|
54669
|
-
|
|
54670
|
-
// // Set initial values for wSide, hSide
|
|
54671
|
-
// wSide = [0, 0];
|
|
54672
|
-
// hSide = [0, 0];
|
|
54673
|
-
|
|
54674
|
-
// // Check for longer side of rectangle:
|
|
54675
|
-
// // longer side is appointed height, shorter side is appointed width
|
|
54676
|
-
// s1 = Math.sqrt((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]));
|
|
54677
|
-
// s2 = Math.sqrt((p3[0] - p2[0]) * (p3[0] - p2[0]) + (p3[1] - p2[1]) * (p3[1] - p2[1]));
|
|
54678
|
-
// if (s1 <= s2) {
|
|
54679
|
-
// width = s1;
|
|
54680
|
-
// height = s2;
|
|
54681
|
-
// // Determine start and end points of the width-side and height-side
|
|
54682
|
-
// wSide = [p1, p2];
|
|
54683
|
-
// hSide = [p2, p3];
|
|
54684
|
-
// } else {
|
|
54685
|
-
// width = s2;
|
|
54686
|
-
// height = s1;
|
|
54687
|
-
// // Determine start and end points of the width-side and height-side
|
|
54688
|
-
// wSide = [p2, p3];
|
|
54689
|
-
// hSide = [p1, p2];
|
|
54690
|
-
// }
|
|
54691
|
-
// // Calculate height and width of the triangles and number of rows
|
|
54692
|
-
// triangleWidth = width / stepsU;
|
|
54693
|
-
|
|
54694
|
-
// if (stepsV === undefined || stepsV === 0) {
|
|
54695
|
-
// // Equilateral triangles, depending on parameter "stepsU"
|
|
54696
|
-
// triangleHeight = (triangleWidth * Math.sqrt(3)) / 2;
|
|
54697
|
-
// numRows = Math.round(height / triangleHeight);
|
|
54698
|
-
// } else {
|
|
54699
|
-
// // Two parameters stepsU, stepsV
|
|
54700
|
-
// numRows = stepsV;
|
|
54701
|
-
// triangleHeight = height / numRows;
|
|
54702
|
-
// }
|
|
54703
|
-
|
|
54704
|
-
// // Calculate values of "shifting vectors"
|
|
54705
|
-
// widthX = (wSide[1][0] - wSide[0][0]) / stepsU;
|
|
54706
|
-
// widthY = (wSide[1][1] - wSide[0][1]) / stepsU;
|
|
54707
|
-
// heightX = (hSide[1][0] - hSide[0][0]) / numRows;
|
|
54708
|
-
// heightY = (hSide[1][1] - hSide[0][1]) / numRows;
|
|
54709
|
-
|
|
54710
|
-
// oddPoints = [];
|
|
54711
|
-
// evenPoints = [];
|
|
54712
|
-
|
|
54713
|
-
// // Push coordinates of the base point (p1)
|
|
54714
|
-
// coords.push([p1[0], p1[1]]);
|
|
54715
|
-
// evenPoints.push(coords.length - 1);
|
|
54716
|
-
|
|
54717
|
-
// // Calculate point coordinates of layer 0 and store indices in evenPoints
|
|
54718
|
-
// for (i = 1; i <= stepsU; i++) {
|
|
54719
|
-
// coords.push([p1[0] + i * widthX, p1[1] + i * widthY]); // Points first line
|
|
54720
|
-
// evenPoints.push(coords.length - 1);
|
|
54721
|
-
// }
|
|
54722
|
-
|
|
54723
|
-
// for (i = 1; i <= numRows; i++) {
|
|
54724
|
-
// if (i % 2 === 0) {
|
|
54725
|
-
// // Points and faces of layers with an even index
|
|
54726
|
-
|
|
54727
|
-
// evenPoints = [];
|
|
54728
|
-
// // Calculate first point coordinates within the layer
|
|
54729
|
-
// coords.push([
|
|
54730
|
-
// p1[0] + i * heightX,
|
|
54731
|
-
// p1[1] + i * heightY
|
|
54732
|
-
// ]);
|
|
54733
|
-
// // evenPoints stores index of the first point of the layer
|
|
54734
|
-
// evenPoints.push(coords.length - 1);
|
|
54735
|
-
// // Calculate all other point coordinates within the layer
|
|
54736
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54737
|
-
// coords.push([
|
|
54738
|
-
// coords[evenPoints[0]][0] + j * widthX,
|
|
54739
|
-
// coords[evenPoints[0]][1] + j * widthY
|
|
54740
|
-
// ]);
|
|
54741
|
-
// //evenPoints stores index of the most recently calculated point of the layer
|
|
54742
|
-
// evenPoints.push(coords.length - 1);
|
|
54743
|
-
// }
|
|
54744
|
-
// // Connect the faces of the row by grouping indices of points
|
|
54745
|
-
// faces.push([evenPoints[0], oddPoints[0], oddPoints[1]]);
|
|
54746
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54747
|
-
// faces.push([evenPoints[j - 1], oddPoints[j], evenPoints[j]]);
|
|
54748
|
-
// faces.push([evenPoints[j], oddPoints[j], oddPoints[j + 1]]);
|
|
54749
|
-
// }
|
|
54750
|
-
// } else {
|
|
54751
|
-
// // Points and faces of layers with an odd index
|
|
54752
|
-
|
|
54753
|
-
// oddPoints = [];
|
|
54754
|
-
// // Calculate first point coordinates within the layer
|
|
54755
|
-
// coords.push([
|
|
54756
|
-
// p1[0] + i * heightX,
|
|
54757
|
-
// p1[1] + i * heightY
|
|
54758
|
-
// ]);
|
|
54759
|
-
// // oddPoints stores index of the first point of the layer
|
|
54760
|
-
// oddPoints.push(coords.length - 1);
|
|
54761
|
-
// // Calculate all other point coordinates within the layer except for the last point
|
|
54762
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54763
|
-
// coords.push([
|
|
54764
|
-
// coords[oddPoints[0]][0] + j * widthX - widthX / 2,
|
|
54765
|
-
// coords[oddPoints[0]][1] + j * widthY - widthY / 2
|
|
54766
|
-
// ]);
|
|
54767
|
-
// // oddPoints stores index of the most recently calculated point of the layer
|
|
54768
|
-
// oddPoints.push(coords.length - 1);
|
|
54769
|
-
// }
|
|
54770
|
-
// // Calculate last point coordinates within the layer
|
|
54771
|
-
// coords.push([
|
|
54772
|
-
// coords[oddPoints[0]][0] + stepsU * widthX,
|
|
54773
|
-
// coords[oddPoints[0]][1] + stepsU * widthY
|
|
54774
|
-
// ]);
|
|
54775
|
-
// // oddPoints stores index of last point within the layer
|
|
54776
|
-
// oddPoints.push(coords.length - 1);
|
|
54777
|
-
// // Connect the faces of the row by grouping indices of points
|
|
54778
|
-
// faces.push([oddPoints[0], evenPoints[0], oddPoints[1]]);
|
|
54779
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54780
|
-
// faces.push([oddPoints[j], evenPoints[j - 1], evenPoints[j]]);
|
|
54781
|
-
// faces.push([oddPoints[j], evenPoints[j], oddPoints[j + 1]]);
|
|
54782
|
-
// }
|
|
54783
|
-
// }
|
|
54784
|
-
// }
|
|
54785
|
-
|
|
54786
|
-
// return [coords, faces];
|
|
54787
|
-
// },
|
|
54788
|
-
|
|
54789
|
-
// rectangulation_old: function (p1, p2, p3, p4, stepsU, stepsV) {
|
|
54790
|
-
// // Vectors used for checking if the given coordinates create a rectangle
|
|
54791
|
-
// var vec1 = [p2[0] - p1[0], p2[1] - p1[1]],
|
|
54792
|
-
// vec2 = [p3[0] - p2[0], p3[1] - p2[1]],
|
|
54793
|
-
// vec3 = [p4[0] - p3[0], p4[1] - p3[1]],
|
|
54794
|
-
// vec4 = [p1[0] - p4[0], p1[1] - p4[1]],
|
|
54795
|
-
|
|
54796
|
-
// coords = [],
|
|
54797
|
-
// faces = [],
|
|
54798
|
-
// wSide, hSide,
|
|
54799
|
-
// s1, s2,
|
|
54800
|
-
// i, j,
|
|
54801
|
-
// widthX, widthY,
|
|
54802
|
-
// heightX, heightY,
|
|
54803
|
-
// startPointLayer;
|
|
54804
|
-
|
|
54805
|
-
// // Check if the given coordinates create a rectangle, otherwise an exception is thrown
|
|
54806
|
-
// if (
|
|
54807
|
-
// vec1[0] * vec4[0] + vec1[1] * vec4[1] !== 0 ||
|
|
54808
|
-
// vec2[0] * vec1[0] + vec2[1] * vec1[1] !== 0 ||
|
|
54809
|
-
// vec3[0] * vec2[0] + vec3[1] * vec2[1] !== 0 ||
|
|
54810
|
-
// vec4[0] * vec3[0] + vec4[1] * vec3[1] !== 0
|
|
54811
|
-
// ) {
|
|
54812
|
-
// throw new Error("rectangulation_old: area is not rectangle ");
|
|
54813
|
-
// // console.log("rectangulation_old: area is not rectangle ");
|
|
54814
|
-
// }
|
|
54815
|
-
|
|
54816
|
-
// // Set initial values for wSide, hSide
|
|
54817
|
-
// wSide = [0, 0];
|
|
54818
|
-
// hSide = [0, 0];
|
|
54819
|
-
|
|
54820
|
-
// // Check for longer side of rectangle:
|
|
54821
|
-
// // longer side is appointed height, shorter side is appointed width
|
|
54822
|
-
// // s1 = Math.sqrt((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]));
|
|
54823
|
-
// // s2 = Math.sqrt((p3[0] - p2[0]) * (p3[0] - p2[0]) + (p3[1] - p2[1]) * (p3[1] - p2[1]));
|
|
54824
|
-
// s1 = Mat.hypot(vec1[0], vec1[1]);
|
|
54825
|
-
// s2 = Mat.hypot(vec2[0], vec2[1]);
|
|
54826
|
-
|
|
54827
|
-
// if (s1 <= s2) {
|
|
54828
|
-
// // Determine start and end points of the width-side and height-side
|
|
54829
|
-
// wSide = [p1, p2];
|
|
54830
|
-
// hSide = [p2, p3];
|
|
54831
|
-
// } else {
|
|
54832
|
-
// // Determine start and end points of the width-side and height-side
|
|
54833
|
-
// wSide = [p2, p3];
|
|
54834
|
-
// hSide = [p1, p2];
|
|
54835
|
-
// }
|
|
54836
|
-
|
|
54837
|
-
// // Calculate values of "shifting vectors"
|
|
54838
|
-
// widthX = (wSide[1][0] - wSide[0][0]) / stepsV;
|
|
54839
|
-
// widthY = (wSide[1][1] - wSide[0][1]) / stepsV;
|
|
54840
|
-
// heightX = (hSide[1][0] - hSide[0][0]) / stepsU;
|
|
54841
|
-
// heightY = (hSide[1][1] - hSide[0][1]) / stepsU;
|
|
54842
|
-
|
|
54843
|
-
// // Initialize startPointLayer that stores coordinates of the first point of the current layer
|
|
54844
|
-
// startPointLayer = [];
|
|
54845
|
-
|
|
54846
|
-
// // Push coordinates of base point (p1)
|
|
54847
|
-
// coords.push([p1[0], p1[1]]);
|
|
54848
|
-
// startPointLayer = coords[0];
|
|
54849
|
-
|
|
54850
|
-
// // Calculate point coordinates of layer 0
|
|
54851
|
-
// for (j = 1; j <= stepsV; j++) {
|
|
54852
|
-
// coords.push([startPointLayer[0] + j * widthX, startPointLayer[1] + j * widthY]);
|
|
54853
|
-
// }
|
|
54854
|
-
|
|
54855
|
-
// for (i = 1; i <= stepsU; i++) {
|
|
54856
|
-
// startPointLayer = [];
|
|
54857
|
-
|
|
54858
|
-
// // Calculate point coordinates of first point of layer
|
|
54859
|
-
// coords.push([
|
|
54860
|
-
// p1[0] + i * heightX,
|
|
54861
|
-
// p1[1] + i * heightY
|
|
54862
|
-
// ]);
|
|
54863
|
-
// startPointLayer = coords[coords.length - 1];
|
|
54864
|
-
|
|
54865
|
-
// // Calculating remaining point coordinates of layer
|
|
54866
|
-
// for (j = 1; j <= stepsV; j++) {
|
|
54867
|
-
// coords.push([
|
|
54868
|
-
// startPointLayer[0] + j * widthX,
|
|
54869
|
-
// startPointLayer[1] + j * widthY
|
|
54870
|
-
// ]);
|
|
54871
|
-
// }
|
|
54872
|
-
|
|
54873
|
-
// // Connect rectangles by grouping indices of points
|
|
54874
|
-
// for (
|
|
54875
|
-
// j = coords.length - stepsV - 1;
|
|
54876
|
-
// j < coords.length - 1;
|
|
54877
|
-
// j++
|
|
54878
|
-
// ) {
|
|
54879
|
-
// faces.push([j, j - stepsV - 1, j - stepsV, j + 1]);
|
|
54880
|
-
// }
|
|
54881
|
-
// }
|
|
54882
|
-
|
|
54883
|
-
// return [coords, faces];
|
|
54884
|
-
// },
|
|
54885
|
-
|
|
54886
|
-
// /**
|
|
54887
|
-
// * This function creates an array of dynamic 3-dimensional points
|
|
54888
|
-
// * based on an array of pairs of two coordinates.
|
|
54889
|
-
// * It uses a mathematical function to assign a third coordinate (the z-coordinate)
|
|
54890
|
-
// * to each pair of two coordinates.
|
|
54891
|
-
// * The 3-dimensional points are not stored directly.
|
|
54892
|
-
// * Instead the array stores JavaScript functions that utilize the mentioned mathematical function
|
|
54893
|
-
// * to return an array of three coordinates.
|
|
54894
|
-
// * This allows the recognition and proper visualization of changes to the underlying
|
|
54895
|
-
// * mathematical function.
|
|
54896
|
-
// * @name mapMeshTo3D
|
|
54897
|
-
// * @param {Array} surface
|
|
54898
|
-
// * @param {Parametricsurface3d} el
|
|
54899
|
-
// * @returns {Array} dynamicPoints array of [x, y, z] coordinates
|
|
54900
|
-
// *
|
|
54901
|
-
// * @private
|
|
54902
|
-
// * @memberof JXG.Math.Tiling
|
|
54903
|
-
// */
|
|
54904
|
-
// mapMeshTo3D: function (surface, el) {
|
|
54905
|
-
// var dynamicPoints = [], i;
|
|
54906
|
-
|
|
54907
|
-
// for (i = 0; i < surface[0].length; i++) {
|
|
54908
|
-
// dynamicPoints.push(
|
|
54909
|
-
// (function (u, v) {
|
|
54910
|
-
// return function(x, y) { return el.F(u, v); };
|
|
54911
|
-
// })(surface[0][i][0], surface[0][i][1])
|
|
54912
|
-
// ); // Capture values explicitly
|
|
54913
|
-
// // dynamicPoints.push(
|
|
54914
|
-
// // (function (u, v) {
|
|
54915
|
-
// // return function(x, y) { return el.F(Type.evaluate(u), Type.evaluate(v)); };
|
|
54916
|
-
// // })(surface[0][i][0], surface[0][i][1])
|
|
54917
|
-
// // ); // Capture values explicitly
|
|
54918
|
-
// }
|
|
54919
|
-
|
|
54920
|
-
// return dynamicPoints;
|
|
54921
|
-
// }
|
|
54922
54678
|
};
|
|
54923
54679
|
|
|
54924
54680
|
/* harmony default export */ var math_tiling = (math/* default */.A.Tiling);
|
|
@@ -58236,9 +57992,9 @@ jxg/* default */.A.extend(
|
|
|
58236
57992
|
/** @lends JXG.Composition.prototype */ {
|
|
58237
57993
|
/**
|
|
58238
57994
|
* Adds an element to the composition container.
|
|
58239
|
-
* @param {String} what Descriptive name for the element, e.g.
|
|
58240
|
-
* access the element later on. There are some reserved names:
|
|
58241
|
-
* updateRenderer
|
|
57995
|
+
* @param {String} what Descriptive name for the element, e.g. `startpoint` or `area`. This is used to
|
|
57996
|
+
* access the element later on. There are some reserved names: `elements`, `add`, `remove`, `update`, `prepareUpdate`,
|
|
57997
|
+
* `updateRenderer`, `highlight`, `noHighlight`, and all names that would form invalid object property names in
|
|
58242
57998
|
* JavaScript.
|
|
58243
57999
|
* @param {JXG.GeometryElement|JXG.Composition} element A reference to the element that is to be added. This can be
|
|
58244
58000
|
* another composition, too.
|
|
@@ -62762,6 +62518,9 @@ jxg/* default */.A.extend(
|
|
|
62762
62518
|
var w = width,
|
|
62763
62519
|
h = height,
|
|
62764
62520
|
// bb,
|
|
62521
|
+
bbox,
|
|
62522
|
+
offX = 0,
|
|
62523
|
+
offY = 0,
|
|
62765
62524
|
css,
|
|
62766
62525
|
width_adjustment, height_adjustment;
|
|
62767
62526
|
|
|
@@ -62798,7 +62557,38 @@ jxg/* default */.A.extend(
|
|
|
62798
62557
|
|
|
62799
62558
|
// If bounding box is not yet initialized, do it now.
|
|
62800
62559
|
if (isNaN(this.getBoundingBox()[0])) {
|
|
62801
|
-
|
|
62560
|
+
// This is not enough
|
|
62561
|
+
// this.setBoundingBox(this.attr.boundingbox, this.keepaspectratio, 'keep');
|
|
62562
|
+
// Instead, we do the same as in JXG.JSXGraphinitBoard():
|
|
62563
|
+
bbox = this.attr.boundingbox;
|
|
62564
|
+
if (utils_type/* default */.A.exists(bbox) && this.keepaspectratio) {
|
|
62565
|
+
/*
|
|
62566
|
+
* If the boundingbox attribute is given and the ratio of height and width of the
|
|
62567
|
+
* sides defined by the bounding box and the ratio of the dimensions of the div tag
|
|
62568
|
+
* which contains the board do not coincide, then the smaller side is chosen.
|
|
62569
|
+
*/
|
|
62570
|
+
this.unitX = w / (bbox[2] - bbox[0]);
|
|
62571
|
+
this.unitY = h / (bbox[1] - bbox[3]);
|
|
62572
|
+
|
|
62573
|
+
if (Math.abs(this.unitX) < Math.abs(this.unitY)) {
|
|
62574
|
+
this.unitY = (Math.abs(this.unitX) * this.unitY) / Math.abs(this.unitY);
|
|
62575
|
+
// Add the additional units in equal portions above and below
|
|
62576
|
+
offY = (h / this.unitY - (bbox[1] - bbox[3])) * 0.5;
|
|
62577
|
+
} else {
|
|
62578
|
+
this.unitX = (Math.abs(this.unitY) * this.unitX) / Math.abs(this.unitX);
|
|
62579
|
+
// Add the additional units in equal portions left and right
|
|
62580
|
+
offX = (w / this.unitX - (bbox[2] - bbox[0])) * 0.5;
|
|
62581
|
+
}
|
|
62582
|
+
} else {
|
|
62583
|
+
this.unitX = w / (bbox[2] - bbox[0]);
|
|
62584
|
+
this.unitY = h / (bbox[1] - bbox[3]);
|
|
62585
|
+
}
|
|
62586
|
+
this.origin.scrCoords = [1,
|
|
62587
|
+
-this.unitX * (bbox[0] - offX),
|
|
62588
|
+
this.unitY * (bbox[1] + offY)
|
|
62589
|
+
];
|
|
62590
|
+
this.canvasWidth = w;
|
|
62591
|
+
this.canvasHeight = h;
|
|
62802
62592
|
}
|
|
62803
62593
|
|
|
62804
62594
|
// Do nothing if the dimension did not change since being visible
|
|
@@ -62839,16 +62629,21 @@ jxg/* default */.A.extend(
|
|
|
62839
62629
|
}
|
|
62840
62630
|
|
|
62841
62631
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
62842
|
-
var bb;
|
|
62632
|
+
// var bb;
|
|
62633
|
+
|
|
62634
|
+
// Take the last observed size
|
|
62635
|
+
that._lastContentRect = entries[entries.length - 1].contentRect;
|
|
62843
62636
|
if (!that._isResizing) {
|
|
62844
62637
|
that._isResizing = true;
|
|
62845
|
-
bb = entries[0].contentRect;
|
|
62638
|
+
// bb = entries[0].contentRect;
|
|
62846
62639
|
window.setTimeout(function () {
|
|
62640
|
+
var bb = that._lastContentRect;
|
|
62847
62641
|
try {
|
|
62848
62642
|
that.updateContainerDims(bb.width, bb.height);
|
|
62849
62643
|
} catch (e) {
|
|
62850
|
-
|
|
62851
|
-
|
|
62644
|
+
// JXG.debug(e); // Used to log errors during board.update()
|
|
62645
|
+
console.error(e);
|
|
62646
|
+
// that.stopResizeObserver();
|
|
62852
62647
|
} finally {
|
|
62853
62648
|
that._isResizing = false;
|
|
62854
62649
|
}
|
|
@@ -63881,7 +63676,7 @@ jxg/* default */.A.extend(
|
|
|
63881
63676
|
* @private
|
|
63882
63677
|
*/
|
|
63883
63678
|
_removeObj: function (object, saveMethod) {
|
|
63884
|
-
var el,
|
|
63679
|
+
var el, i, pos;
|
|
63885
63680
|
|
|
63886
63681
|
if (utils_type/* default */.A.isArray(object)) {
|
|
63887
63682
|
for (i = 0; i < object.length; i++) {
|
|
@@ -63899,6 +63694,16 @@ jxg/* default */.A.extend(
|
|
|
63899
63694
|
return this;
|
|
63900
63695
|
}
|
|
63901
63696
|
|
|
63697
|
+
// Already removed (e.g. reached again through a parent's childElements
|
|
63698
|
+
// or View3D.removeObject). Removing it twice used to splice a live element.
|
|
63699
|
+
if (object._pos === -1 && this.objects[object.id] !== object) {
|
|
63700
|
+
return this;
|
|
63701
|
+
}
|
|
63702
|
+
|
|
63703
|
+
if (object.is3D && utils_type/* default */.A.exists(object.view.objects[object.id])) {
|
|
63704
|
+
jxg/* default */.A.warn("board.removeObject() of 3D object " + object.id + ". Use view3d.removeObject() instead.");
|
|
63705
|
+
}
|
|
63706
|
+
|
|
63902
63707
|
try {
|
|
63903
63708
|
// remove all children.
|
|
63904
63709
|
for (el in object.childElements) {
|
|
@@ -63948,15 +63753,16 @@ jxg/* default */.A.extend(
|
|
|
63948
63753
|
}
|
|
63949
63754
|
|
|
63950
63755
|
// remove the object itself from our control structures
|
|
63951
|
-
if
|
|
63952
|
-
|
|
63756
|
+
// Trust _pos only if it still points at the object, and reset it
|
|
63757
|
+
// afterwards, so a stale index can never splice another element.
|
|
63758
|
+
pos = this.objectsList[object._pos] === object ? object._pos : this.objectsList.indexOf(object);
|
|
63759
|
+
if (pos > -1) {
|
|
63760
|
+
this.objectsList.splice(pos, 1);
|
|
63953
63761
|
// Quadratic complexity for reindexing the positions:
|
|
63954
|
-
for (i =
|
|
63955
|
-
|
|
63956
|
-
if (o._pos > -1) {
|
|
63957
|
-
o._pos--;
|
|
63958
|
-
}
|
|
63762
|
+
for (i = pos; i < this.objectsList.length; i++) {
|
|
63763
|
+
this.objectsList[i]._pos = i;
|
|
63959
63764
|
}
|
|
63765
|
+
object._pos = -1;
|
|
63960
63766
|
} else if (object.type !== constants/* default */.A.OBJECT_TYPE_TURTLE) {
|
|
63961
63767
|
jxg/* default */.A.debug(
|
|
63962
63768
|
'Board.removeObject: object ' + object.id + ' not found in list.'
|
|
@@ -67102,7 +66908,7 @@ jxg/* default */.A.SVGRenderer = function (container, dim) {
|
|
|
67102
66908
|
var id = this.uniqName('ClipFull'),
|
|
67103
66909
|
node1 = this.container.ownerDocument.createElementNS(this.svgNamespace, 'clipPath'),
|
|
67104
66910
|
node2 = this.container.ownerDocument.createElementNS(this.svgNamespace, 'rect'),
|
|
67105
|
-
style,
|
|
66911
|
+
style, r;
|
|
67106
66912
|
node1.setAttributeNS(null, 'id', id);
|
|
67107
66913
|
|
|
67108
66914
|
node2.setAttributeNS(null, 'x', 0);
|
|
@@ -67112,10 +66918,9 @@ jxg/* default */.A.SVGRenderer = function (container, dim) {
|
|
|
67112
66918
|
|
|
67113
66919
|
// Inherit border-radius
|
|
67114
66920
|
style = getComputedStyle(this.container);
|
|
67115
|
-
|
|
67116
|
-
|
|
67117
|
-
node2.setAttributeNS(null, '
|
|
67118
|
-
node2.setAttributeNS(null, 'ry', ry);
|
|
66921
|
+
r = (utils_type/* default */.A.exists(style['border-radius']) && style['border-radius'] !== '') ? parseFloat(style['border-radius']) : 0;
|
|
66922
|
+
node2.setAttributeNS(null, 'rx', r);
|
|
66923
|
+
node2.setAttributeNS(null, 'ry', r);
|
|
67119
66924
|
|
|
67120
66925
|
node1.appendChild(node2);
|
|
67121
66926
|
return node1;
|
|
@@ -67803,7 +67608,7 @@ jxg/* default */.A.extend(
|
|
|
67803
67608
|
|
|
67804
67609
|
// Already documented in JXG.AbstractRenderer
|
|
67805
67610
|
setLayer: function (el, level) {
|
|
67806
|
-
var node;
|
|
67611
|
+
var node, elNode;
|
|
67807
67612
|
if (!utils_type/* default */.A.exists(level)) {
|
|
67808
67613
|
level = 0;
|
|
67809
67614
|
} else if (level >= src_options/* default */.A.layer.numlayers) {
|
|
@@ -67811,8 +67616,16 @@ jxg/* default */.A.extend(
|
|
|
67811
67616
|
}
|
|
67812
67617
|
|
|
67813
67618
|
node = this.layer[level];
|
|
67619
|
+
// if ('moveBefore' in Element.prototype) {
|
|
67814
67620
|
if (utils_type/* default */.A.exists(node.moveBefore)) {
|
|
67815
|
-
node.moveBefore(el.rendNode, null);
|
|
67621
|
+
// node.moveBefore(el.rendNode, null);
|
|
67622
|
+
elNode = el.rendNode;
|
|
67623
|
+
if (elNode.isConnected && node.isConnected &&
|
|
67624
|
+
(elNode.ownerDocument === node.ownerDocument)) {
|
|
67625
|
+
node.moveBefore(elNode, null);
|
|
67626
|
+
} else {
|
|
67627
|
+
node.insertBefore(elNode, null);
|
|
67628
|
+
}
|
|
67816
67629
|
} else {
|
|
67817
67630
|
node.appendChild(el.rendNode);
|
|
67818
67631
|
}
|
|
@@ -68099,6 +67912,7 @@ jxg/* default */.A.extend(
|
|
|
68099
67912
|
i = 0;
|
|
68100
67913
|
while (i < len) {
|
|
68101
67914
|
if (el.points[i] === undefined) {
|
|
67915
|
+
i++;
|
|
68102
67916
|
continue;
|
|
68103
67917
|
}
|
|
68104
67918
|
scr = el.points[i].scrCoords;
|
|
@@ -70932,7 +70746,7 @@ jxg/* default */.A.extend(
|
|
|
70932
70746
|
* Set the gradient angle for linear color gradients.
|
|
70933
70747
|
*
|
|
70934
70748
|
* @private
|
|
70935
|
-
* @param {JXG.GeometryElement}
|
|
70749
|
+
* @param {JXG.GeometryElement} el An arbitrary JSXGraph element, preferably one with an area.
|
|
70936
70750
|
* @param {Number} radians angle value in radians. 0 is horizontal from left to right, Pi/4 is vertical from top to bottom.
|
|
70937
70751
|
*/
|
|
70938
70752
|
updateGradientAngle: function (el, radians) {
|
|
@@ -70988,7 +70802,7 @@ jxg/* default */.A.extend(
|
|
|
70988
70802
|
* Set circles for radial color gradients.
|
|
70989
70803
|
*
|
|
70990
70804
|
* @private
|
|
70991
|
-
* @param {
|
|
70805
|
+
* @param {JXG.GeometryElement} el An arbitrary JSXGraph element, preferably one with an area.
|
|
70992
70806
|
* @param {Number} cx Canvas value x1 (but value between 0 and 1)
|
|
70993
70807
|
* @param {Number} cy Canvas value y1 (but value between 0 and 1)
|
|
70994
70808
|
* @param {Number} r Canvas value r1 (but value between 0 and 1)
|
|
@@ -71001,19 +70815,20 @@ jxg/* default */.A.extend(
|
|
|
71001
70815
|
c1, c2,
|
|
71002
70816
|
cxs, cys, rs,
|
|
71003
70817
|
fxs, fys, frs,
|
|
71004
|
-
dx, dy;
|
|
70818
|
+
dx, dy, d;
|
|
71005
70819
|
|
|
71006
70820
|
c1 = new base_coords/* default */.A(constants/* default */.A.COORDS_BY_USER, [bb[0], bb[1]], el.board);
|
|
71007
70821
|
c2 = new base_coords/* default */.A(constants/* default */.A.COORDS_BY_USER, [bb[2], bb[3]], el.board);
|
|
71008
70822
|
dx = c2.scrCoords[1] - c1.scrCoords[1];
|
|
71009
70823
|
dy = c1.scrCoords[2] - c2.scrCoords[2];
|
|
71010
|
-
|
|
71011
70824
|
cxs = c1.scrCoords[1] + dx * cx;
|
|
71012
70825
|
cys = c2.scrCoords[2] + dy * cy;
|
|
71013
70826
|
fxs = c1.scrCoords[1] + dx * fx;
|
|
71014
70827
|
fys = c2.scrCoords[2] + dy * fy;
|
|
71015
|
-
|
|
71016
|
-
|
|
70828
|
+
|
|
70829
|
+
d = Math.abs(dx) + Math.abs(dy);
|
|
70830
|
+
rs = Math.max(r * d * 0.5, 0);
|
|
70831
|
+
frs = Math.max(fr * d * 0.5, 0);
|
|
71017
70832
|
|
|
71018
70833
|
return this.context.createRadialGradient(fxs, fys, frs, cxs, cys, rs);
|
|
71019
70834
|
},
|
|
@@ -80354,13 +80169,30 @@ jxg/* default */.A.registerElement("circle", jxg/* default */.A.createCircle);
|
|
|
80354
80169
|
* @jsxgraphsignature Ellipse
|
|
80355
80170
|
* Parent elements can be two elements either of type {@link JXG.Point} or array of
|
|
80356
80171
|
* numbers describing the coordinates of a point.
|
|
80357
|
-
* The third parameter is a number/function which defines the length of the major axis
|
|
80172
|
+
* The third parameter is a number/function which defines the length of the major axis.
|
|
80358
80173
|
* @param {PointLike} point1
|
|
80359
80174
|
* @param {PointLike} point2
|
|
80360
80175
|
* @param {NumberLike} number
|
|
80361
80176
|
* @param {Number} [start=0] parameter of the curve start, default: 0.
|
|
80362
80177
|
* @param {Number} [end=2π] parameter for the curve end, default: 2π.
|
|
80363
80178
|
*
|
|
80179
|
+
* @example
|
|
80180
|
+
* var A = board.create('point', [1,0]);
|
|
80181
|
+
* var B = board.create('point', [-1,0]);
|
|
80182
|
+
* var el = board.create('ellipse',[A, B, 4]);
|
|
80183
|
+
*
|
|
80184
|
+
* </pre><div id="JXG7898d447-94dc-4dce-9ad3-60e3387be9f3" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
80185
|
+
* <script type="text/javascript">
|
|
80186
|
+
* (function() {
|
|
80187
|
+
* var board = JXG.JSXGraph.initBoard('JXG7898d447-94dc-4dce-9ad3-60e3387be9f3',
|
|
80188
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
80189
|
+
* var A = board.create('point', [1,0]);
|
|
80190
|
+
* var B = board.create('point', [-1,0]);
|
|
80191
|
+
* var el = board.create('ellipse',[A,B, 4]);
|
|
80192
|
+
* })();
|
|
80193
|
+
*
|
|
80194
|
+
* </script><pre>
|
|
80195
|
+
*
|
|
80364
80196
|
*/
|
|
80365
80197
|
jxg/* default */.A.createEllipse = function (board, parents, attributes) {
|
|
80366
80198
|
var polarForm,
|
|
@@ -80632,6 +80464,23 @@ jxg/* default */.A.createEllipse = function (board, parents, attributes) {
|
|
|
80632
80464
|
* @param {NumberLike} number
|
|
80633
80465
|
* @param {Number} [start=-π] parameter of the curve start, default: -π.
|
|
80634
80466
|
* @param {Number} [end=π] parameter for the curve end, default: π.
|
|
80467
|
+
* @example
|
|
80468
|
+
* var A = board.create('point', [1,0]);
|
|
80469
|
+
* var B = board.create('point', [-1,0]);
|
|
80470
|
+
* var el = board.create('hyperbola',[A, B, 1]);
|
|
80471
|
+
*
|
|
80472
|
+
* </pre><div id="JXGa4c0068b-41bc-4be4-b485-d0d0c7f2e10b" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
80473
|
+
* <script type="text/javascript">
|
|
80474
|
+
* (function() {
|
|
80475
|
+
* var board = JXG.JSXGraph.initBoard('JXGa4c0068b-41bc-4be4-b485-d0d0c7f2e10b',
|
|
80476
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
80477
|
+
* var A = board.create('point', [1,0]);
|
|
80478
|
+
* var B = board.create('point', [-1,0]);
|
|
80479
|
+
* var el = board.create('hyperbola',[A,B, 1]);
|
|
80480
|
+
*
|
|
80481
|
+
* })();
|
|
80482
|
+
*
|
|
80483
|
+
* </script><pre>
|
|
80635
80484
|
*/
|
|
80636
80485
|
jxg/* default */.A.createHyperbola = function (board, parents, attributes) {
|
|
80637
80486
|
var polarForm,
|
|
@@ -87856,11 +87705,11 @@ jxg/* default */.A.createSector = function (board, parents, attributes) {
|
|
|
87856
87705
|
s = el.line1.point1.coords;
|
|
87857
87706
|
} else if (
|
|
87858
87707
|
el.line1.point2.Dist(el.line2.point1) < eps ||
|
|
87859
|
-
el.line1.point2.Dist(el.line2.
|
|
87708
|
+
el.line1.point2.Dist(el.line2.point2) < eps
|
|
87860
87709
|
) {
|
|
87861
87710
|
s = el.line1.point2.coords;
|
|
87862
87711
|
} else {
|
|
87863
|
-
|
|
87712
|
+
jxg/* default */.A.warn(
|
|
87864
87713
|
"JSXGraph warning: Can't create Sector from parallel lines with no common defining point."
|
|
87865
87714
|
);
|
|
87866
87715
|
}
|
|
@@ -87941,10 +87790,13 @@ jxg/* default */.A.createSector = function (board, parents, attributes) {
|
|
|
87941
87790
|
B = l1.point1.coords.usrCoords;
|
|
87942
87791
|
} else if (
|
|
87943
87792
|
l1.point2.Dist(l2.point1) < eps ||
|
|
87944
|
-
l1.point2.Dist(l2.
|
|
87793
|
+
l1.point2.Dist(l2.point2) < eps
|
|
87945
87794
|
) {
|
|
87946
87795
|
B = l1.point2.coords.usrCoords;
|
|
87947
87796
|
} else {
|
|
87797
|
+
jxg/* default */.A.warn(
|
|
87798
|
+
"JSXGraph warning: sector from parallel lines with no common defining point."
|
|
87799
|
+
);
|
|
87948
87800
|
}
|
|
87949
87801
|
}
|
|
87950
87802
|
|
|
@@ -111916,7 +111768,7 @@ jxg/* default */.A.extend(
|
|
|
111916
111768
|
},
|
|
111917
111769
|
|
|
111918
111770
|
removeObject: function (object, saveMethod) {
|
|
111919
|
-
var i, el, le, o, fst, face;
|
|
111771
|
+
var i, el, le, o, fst, face, gone, list;
|
|
111920
111772
|
|
|
111921
111773
|
// this.board.removeObject(object, saveMethod);
|
|
111922
111774
|
if (utils_type/* default */.A.isArray(object)) {
|
|
@@ -111928,8 +111780,8 @@ jxg/* default */.A.extend(
|
|
|
111928
111780
|
|
|
111929
111781
|
object = this.select(object);
|
|
111930
111782
|
|
|
111931
|
-
//
|
|
111932
|
-
//
|
|
111783
|
+
// If the object which is about to be removed unknown or a string, do nothing.
|
|
111784
|
+
// it is a string if a string was given and could not be resolved to an element.
|
|
111933
111785
|
if (!utils_type/* default */.A.exists(object) || utils_type/* default */.A.isString(object)) {
|
|
111934
111786
|
return this;
|
|
111935
111787
|
}
|
|
@@ -111938,38 +111790,46 @@ jxg/* default */.A.extend(
|
|
|
111938
111790
|
// Remove all children.
|
|
111939
111791
|
for (el in object.childElements) {
|
|
111940
111792
|
if (object.childElements.hasOwnProperty(el)) {
|
|
111941
|
-
|
|
111793
|
+
o = object.childElements[el];
|
|
111794
|
+
if (!(object.is3D && object.element2D === o)) {
|
|
111795
|
+
this.removeObject(o);
|
|
111796
|
+
}
|
|
111942
111797
|
}
|
|
111943
111798
|
}
|
|
111944
111799
|
if (object.type === constants/* default */.A.OBJECT_TYPE_POLYHEDRON3D) {
|
|
111945
111800
|
// Special treatment for polyhedron3d.
|
|
111946
111801
|
// With this we can avoid the time consuming addChild() calls.
|
|
111802
|
+
// Mark faces and their 2D elements, then compact objectsList once.
|
|
111803
|
+
// Splicing face by face with stale _pos removed unrelated elements.
|
|
111804
|
+
gone = {};
|
|
111947
111805
|
le = object.faces.length;
|
|
111948
|
-
if (le > 0) {
|
|
111949
|
-
fst = object.faces[0]._pos;
|
|
111950
|
-
fst = (object.faces[0].element2D._pos < fst) ? object.faces[0].element2D._pos : fst;
|
|
111951
|
-
}
|
|
111952
111806
|
for (i = 0; i < le; i++) {
|
|
111953
111807
|
face = object.faces[i];
|
|
111954
111808
|
delete this.objects[face.id];
|
|
111955
111809
|
|
|
111956
|
-
// this.board.removeObject(face.element2D, saveMethod);
|
|
111957
111810
|
delete this.board.objects[face.element2D.id];
|
|
111958
111811
|
delete this.board.elementsByName[face.element2D.name];
|
|
111959
111812
|
face.element2D.remove();
|
|
111960
|
-
|
|
111813
|
+
gone[face.element2D.id] = true;
|
|
111814
|
+
face.element2D._pos = -1;
|
|
111961
111815
|
|
|
111962
111816
|
delete this.board.objects[face.id];
|
|
111963
111817
|
delete this.board.elementsByName[face.name];
|
|
111964
111818
|
face.remove();
|
|
111965
|
-
|
|
111819
|
+
gone[face.id] = true;
|
|
111820
|
+
face._pos = -1;
|
|
111966
111821
|
}
|
|
111967
|
-
|
|
111968
|
-
|
|
111969
|
-
for (i =
|
|
111970
|
-
o =
|
|
111971
|
-
if (o.
|
|
111822
|
+
list = this.board.objectsList;
|
|
111823
|
+
fst = 0;
|
|
111824
|
+
for (i = 0; i < list.length; i++) {
|
|
111825
|
+
o = list[i];
|
|
111826
|
+
if (!gone.hasOwnProperty(o.id)) {
|
|
111827
|
+
o._pos = fst;
|
|
111828
|
+
list[fst] = o;
|
|
111829
|
+
fst++;
|
|
111830
|
+
}
|
|
111972
111831
|
}
|
|
111832
|
+
list.length = fst;
|
|
111973
111833
|
object.faces = [];
|
|
111974
111834
|
}
|
|
111975
111835
|
|
|
@@ -115638,8 +115498,6 @@ jxg/* default */.A.extend(
|
|
|
115638
115498
|
}
|
|
115639
115499
|
},
|
|
115640
115500
|
|
|
115641
|
-
|
|
115642
|
-
|
|
115643
115501
|
/**
|
|
115644
115502
|
* Starts an animated point movement towards the given coordinates `where`.
|
|
115645
115503
|
* The animation is done after `time` milliseconds.
|
|
@@ -115861,9 +115719,6 @@ jxg/* default */.A.extend(
|
|
|
115861
115719
|
});
|
|
115862
115720
|
},
|
|
115863
115721
|
|
|
115864
|
-
|
|
115865
|
-
|
|
115866
|
-
|
|
115867
115722
|
// Not yet working
|
|
115868
115723
|
__evt__update3D: function (oc) { }
|
|
115869
115724
|
}
|
|
@@ -117481,8 +117336,8 @@ jxg/* default */.A.createLine3D = function (board, parents, attributes) {
|
|
|
117481
117336
|
* @private
|
|
117482
117337
|
*/
|
|
117483
117338
|
el.endpoints = endpoints;
|
|
117484
|
-
el.addChild(endpoints[0]);
|
|
117485
|
-
el.addChild(endpoints[1]);
|
|
117339
|
+
// el.addChild(endpoints[0]); // Is done below
|
|
117340
|
+
// el.addChild(endpoints[1]);
|
|
117486
117341
|
// el.setParents(endpoints);
|
|
117487
117342
|
el.addParents([point1, point2]);
|
|
117488
117343
|
|
|
@@ -118829,18 +118684,24 @@ jxg/* default */.A.createIntersectionLine3D = function (board, parents, attribut
|
|
|
118829
118684
|
var view = parents[0],
|
|
118830
118685
|
el1 = parents[1],
|
|
118831
118686
|
el2 = parents[2],
|
|
118832
|
-
ixnLine, i,//
|
|
118687
|
+
ixnLine, i,// f,
|
|
118833
118688
|
attr = utils_type/* default */.A.copyAttributes(attributes, board.options, 'intersectionline3d'),
|
|
118834
118689
|
pts = [];
|
|
118835
118690
|
|
|
118836
|
-
// func = Geometry.intersectionFunction3D(view, el1, el2);
|
|
118691
|
+
// var func = Geometry.intersectionFunction3D(view, el1, el2);
|
|
118837
118692
|
for (i = 0; i < 2; i++) {
|
|
118838
|
-
|
|
118839
|
-
|
|
118840
|
-
|
|
118841
|
-
|
|
118842
|
-
|
|
118843
|
-
|
|
118693
|
+
try {
|
|
118694
|
+
pts[i] = view.create('point3d', [
|
|
118695
|
+
// Use closures
|
|
118696
|
+
(function (ii) {
|
|
118697
|
+
return function () { return geometry/* default */.A.intersectionFunction3D(view, el1, el2)[ii]; };
|
|
118698
|
+
})(i)
|
|
118699
|
+
], attr['point' + (i + 1)]);
|
|
118700
|
+
} catch (err) {
|
|
118701
|
+
throw new Error(
|
|
118702
|
+
"JSXGraph: Can't create IntersectionLine3D from the intersection of these types. Please check the intersecting elements."
|
|
118703
|
+
);
|
|
118704
|
+
}
|
|
118844
118705
|
}
|
|
118845
118706
|
ixnLine = view.create('line3d', pts, attr);
|
|
118846
118707
|
|
|
@@ -121200,28 +121061,52 @@ jxg/* default */.A.extend(
|
|
|
121200
121061
|
jxg/* default */.A.Sphere3D.prototype,
|
|
121201
121062
|
/** @lends JXG.Sphere3D.prototype */ {
|
|
121202
121063
|
|
|
121064
|
+
/**
|
|
121065
|
+
* Returns the x-coordinate of the sphere given as parametric surface for parameters `u` and `v`.
|
|
121066
|
+
* @param {Number} u
|
|
121067
|
+
* @param {Number} v
|
|
121068
|
+
* @returns {Number} x-coordinate
|
|
121069
|
+
*/
|
|
121203
121070
|
X: function(u, v) {
|
|
121204
121071
|
var r = this.Radius();
|
|
121205
121072
|
return r * Math.sin(u) * Math.cos(v);
|
|
121206
121073
|
},
|
|
121207
121074
|
|
|
121075
|
+
/**
|
|
121076
|
+
* Returns the y-coordinate of the sphere given as parametric surface for parameters `u` and `v`.
|
|
121077
|
+
* @param {Number} u
|
|
121078
|
+
* @param {Number} v
|
|
121079
|
+
* @returns {Number} y-coordinate
|
|
121080
|
+
*/
|
|
121208
121081
|
Y: function(u, v) {
|
|
121209
121082
|
var r = this.Radius();
|
|
121210
121083
|
return r * Math.sin(u) * Math.sin(v);
|
|
121211
121084
|
},
|
|
121212
121085
|
|
|
121086
|
+
/**
|
|
121087
|
+
* Returns the z-coordinate of the sphere given as parametric surface for parameters `u` and `v`.
|
|
121088
|
+
* @param {Number} u
|
|
121089
|
+
* @param {Number} v
|
|
121090
|
+
* @returns {Number} z-coordinate
|
|
121091
|
+
*/
|
|
121213
121092
|
Z: function(u, v) {
|
|
121214
121093
|
var r = this.Radius();
|
|
121215
121094
|
return r * Math.cos(u);
|
|
121216
121095
|
},
|
|
121217
121096
|
|
|
121097
|
+
/**
|
|
121098
|
+
* The parameter range of `u`
|
|
121099
|
+
* @type {Array}
|
|
121100
|
+
*/
|
|
121218
121101
|
range_u: [0, 2 * Math.PI],
|
|
121102
|
+
|
|
121103
|
+
/**
|
|
121104
|
+
* The parameter range of `v`
|
|
121105
|
+
* @type {Array}
|
|
121106
|
+
*/
|
|
121219
121107
|
range_v: [0, Math.PI],
|
|
121220
121108
|
|
|
121221
121109
|
update: function () {
|
|
121222
|
-
if (this.projectionType !== this.view.projectionType) {
|
|
121223
|
-
this.rebuildProjection();
|
|
121224
|
-
}
|
|
121225
121110
|
return this;
|
|
121226
121111
|
},
|
|
121227
121112
|
|
|
@@ -121269,34 +121154,55 @@ jxg/* default */.A.extend(
|
|
|
121269
121154
|
return NaN;
|
|
121270
121155
|
},
|
|
121271
121156
|
|
|
121272
|
-
|
|
121273
|
-
|
|
121274
|
-
|
|
121275
|
-
|
|
121276
|
-
|
|
121277
|
-
|
|
121278
|
-
|
|
121279
|
-
|
|
121280
|
-
|
|
121281
|
-
|
|
121282
|
-
|
|
121283
|
-
|
|
121284
|
-
|
|
121157
|
+
/**
|
|
121158
|
+
* The central projection of a sphere is an ellipse. The front and back
|
|
121159
|
+
* points of the sphere -- that is, the points closest to and furthest
|
|
121160
|
+
* from the screen -- project to the foci of the ellipse.
|
|
121161
|
+
*
|
|
121162
|
+
* To see this, look at the cone tangent to the sphere whose tip is at
|
|
121163
|
+
* the camera. The image of the sphere is the ellipse where this cone
|
|
121164
|
+
* intersects the screen. By acting on the sphere with scalings centered
|
|
121165
|
+
* on the camera, you can send it to either of the Dandelin spheres that
|
|
121166
|
+
* touch the screen at the foci of the image ellipse.
|
|
121167
|
+
*
|
|
121168
|
+
* This factory method produces two functions, `focusFn(-1)` and
|
|
121169
|
+
* `focusFn(1)`, that evaluate to the projections of the front and back
|
|
121170
|
+
* points of the sphere, respectively.
|
|
121171
|
+
*
|
|
121172
|
+
* The parallel projection of a sphere is a cicle. We use an ellipse curve
|
|
121173
|
+
* for this projection, too. The two focii now coincide with the center of
|
|
121174
|
+
* the sphere. The 2D radius point is defined by the projection of the center
|
|
121175
|
+
* and the projected radius.
|
|
121176
|
+
* @param {Number} sgn Expecst -1 or 1 for the two focus points
|
|
121177
|
+
* @returns {Array} 2D coordinates of the projected focus point
|
|
121178
|
+
*
|
|
121179
|
+
*/
|
|
121285
121180
|
focusFn: function (sgn) {
|
|
121286
121181
|
var that = this;
|
|
121287
121182
|
|
|
121288
121183
|
return function () {
|
|
121289
|
-
var camDir
|
|
121184
|
+
var camDir,
|
|
121185
|
+
v = (that.view.projectionType === 'central') ? 1 : 0,
|
|
121290
121186
|
r = that.Radius();
|
|
121291
121187
|
|
|
121188
|
+
// Parallel projection: v === 0, the two focii coincide with the center
|
|
121189
|
+
// Central projection: v === 1
|
|
121190
|
+
camDir = (v === 0) ? [0, 0, 0, 0] : that.view.boxToCam[3];
|
|
121191
|
+
|
|
121292
121192
|
return that.view.project3DTo2D([
|
|
121293
|
-
that.center.X() + sgn * r * camDir[1],
|
|
121294
|
-
that.center.Y() + sgn * r * camDir[2],
|
|
121295
|
-
that.center.Z() + sgn * r * camDir[3]
|
|
121193
|
+
that.center.X() + v * sgn * r * camDir[1],
|
|
121194
|
+
that.center.Y() + v * sgn * r * camDir[2],
|
|
121195
|
+
that.center.Z() + v * sgn * r * camDir[3]
|
|
121296
121196
|
]).slice(1, 3);
|
|
121297
121197
|
};
|
|
121298
121198
|
},
|
|
121299
121199
|
|
|
121200
|
+
// Replace our 2D representation with a new one that's consistent with
|
|
121201
|
+
// the view's current projection type
|
|
121202
|
+
/**
|
|
121203
|
+
*
|
|
121204
|
+
* @returns {Array} 2D coordinates of the projected 3rd point that is on the ellipse.
|
|
121205
|
+
*/
|
|
121300
121206
|
innerVertexFn: function () {
|
|
121301
121207
|
var that = this;
|
|
121302
121208
|
|
|
@@ -121306,6 +121212,7 @@ jxg/* default */.A.extend(
|
|
|
121306
121212
|
distOffAxis = math/* default */.A.hypot(p[0], p[1]),
|
|
121307
121213
|
cam = view.boxToCam,
|
|
121308
121214
|
r = that.Radius(),
|
|
121215
|
+
c, bs,
|
|
121309
121216
|
angleOffAxis = Math.atan(-distOffAxis / p[2]),
|
|
121310
121217
|
steepness = Math.acos(r / math/* default */.A.norm(p)),
|
|
121311
121218
|
lean = angleOffAxis + steepness,
|
|
@@ -121313,6 +121220,22 @@ jxg/* default */.A.extend(
|
|
|
121313
121220
|
sin_lean = Math.sin(lean),
|
|
121314
121221
|
inward;
|
|
121315
121222
|
|
|
121223
|
+
// Do parallel projection
|
|
121224
|
+
if (that.view.projectionType !== 'central') {
|
|
121225
|
+
bs = view.bbox3D[0][1] - view.bbox3D[0][0];
|
|
121226
|
+
r *= view.size[0] / bs;
|
|
121227
|
+
|
|
121228
|
+
c = view.project3DTo2D([
|
|
121229
|
+
that.center.X(),
|
|
121230
|
+
that.center.Y(),
|
|
121231
|
+
that.center.Z()
|
|
121232
|
+
]);
|
|
121233
|
+
c[1] += r;
|
|
121234
|
+
|
|
121235
|
+
return c;
|
|
121236
|
+
}
|
|
121237
|
+
|
|
121238
|
+
// Do central projection
|
|
121316
121239
|
if (distOffAxis > 1e-8) {
|
|
121317
121240
|
// if the center of the sphere isn't too close to the camera
|
|
121318
121241
|
// axis, find the direction in plane of the screen that
|
|
@@ -121337,7 +121260,15 @@ jxg/* default */.A.extend(
|
|
|
121337
121260
|
};
|
|
121338
121261
|
},
|
|
121339
121262
|
|
|
121340
|
-
|
|
121263
|
+
/**
|
|
121264
|
+
* Create 2D helper points and an ellipse to visualize the `sphere3d`.
|
|
121265
|
+
* Handles central and parallel projection simultaneously.
|
|
121266
|
+
*
|
|
121267
|
+
* This is done only once at creation time.
|
|
121268
|
+
*
|
|
121269
|
+
* @param {object} attr Attributes for the sphere objects
|
|
121270
|
+
*/
|
|
121271
|
+
buildProjection: function (attr) {
|
|
121341
121272
|
var view = this.view,
|
|
121342
121273
|
auxStyle = { visible: false, withLabel: false },
|
|
121343
121274
|
frontFocus = view.create('point', this.focusFn(-1), auxStyle),
|
|
@@ -121346,53 +121277,6 @@ jxg/* default */.A.extend(
|
|
|
121346
121277
|
|
|
121347
121278
|
this.aux2D = [frontFocus, backFocus, innerVertex];
|
|
121348
121279
|
this.element2D = view.create('ellipse', this.aux2D, attr === undefined ? this.visProp : attr);
|
|
121349
|
-
},
|
|
121350
|
-
|
|
121351
|
-
buildParallelProjection: function (attr) {
|
|
121352
|
-
// The parallel projection of a sphere is a circle
|
|
121353
|
-
var that = this,
|
|
121354
|
-
// center2d = function () {
|
|
121355
|
-
// var c3d = [1, that.center.X(), that.center.Y(), that.center.Z()];
|
|
121356
|
-
// return that.view.project3DTo2D(c3d);
|
|
121357
|
-
// },
|
|
121358
|
-
radius2d = function () {
|
|
121359
|
-
var boxSize = that.view.bbox3D[0][1] - that.view.bbox3D[0][0];
|
|
121360
|
-
return that.Radius() * that.view.size[0] / boxSize;
|
|
121361
|
-
};
|
|
121362
|
-
|
|
121363
|
-
this.aux2D = [];
|
|
121364
|
-
this.element2D = this.view.create(
|
|
121365
|
-
'circle',
|
|
121366
|
-
// [center2d, radius2d],
|
|
121367
|
-
[that.center.element2D, radius2d],
|
|
121368
|
-
attr === undefined ? this.visProp : attr
|
|
121369
|
-
);
|
|
121370
|
-
},
|
|
121371
|
-
|
|
121372
|
-
// replace our 2D representation with a new one that's consistent with
|
|
121373
|
-
// the view's current projection type
|
|
121374
|
-
rebuildProjection: function (attr) {
|
|
121375
|
-
var i;
|
|
121376
|
-
|
|
121377
|
-
// remove the old 2D representation from the scene tree
|
|
121378
|
-
if (this.element2D) {
|
|
121379
|
-
this.view.board.removeObject(this.element2D);
|
|
121380
|
-
for (i in this.aux2D) {
|
|
121381
|
-
if (this.aux2D.hasOwnProperty(i)) {
|
|
121382
|
-
this.view.board.removeObject(this.aux2D[i]);
|
|
121383
|
-
}
|
|
121384
|
-
}
|
|
121385
|
-
}
|
|
121386
|
-
|
|
121387
|
-
// build a new 2D representation. the representation is stored in
|
|
121388
|
-
// `this.element2D`, and any auxiliary elements are stored in
|
|
121389
|
-
// `this.aux2D`
|
|
121390
|
-
this.projectionType = this.view.projectionType;
|
|
121391
|
-
if (this.projectionType === 'central') {
|
|
121392
|
-
this.buildCentralProjection(attr);
|
|
121393
|
-
} else {
|
|
121394
|
-
this.buildParallelProjection(attr);
|
|
121395
|
-
}
|
|
121396
121280
|
|
|
121397
121281
|
// attach the new 2D representation to the scene tree
|
|
121398
121282
|
this.addChild(this.element2D);
|
|
@@ -121686,7 +121570,7 @@ jxg/* default */.A.createSphere3D = function (board, parents, attributes) {
|
|
|
121686
121570
|
// to the correct initial state
|
|
121687
121571
|
// Here, element2D is created.
|
|
121688
121572
|
attr = el.setAttr2D(attr);
|
|
121689
|
-
el.
|
|
121573
|
+
el.buildProjection(attr);
|
|
121690
121574
|
|
|
121691
121575
|
el.element2D.prepareUpdate().update();
|
|
121692
121576
|
if (!board.isSuspendedUpdate) {
|