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.mjs
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
var major = 1,
|
|
45
45
|
minor = 14,
|
|
46
|
-
patch =
|
|
46
|
+
patch = 1,
|
|
47
47
|
add = '', // 'dev' 'beta1'
|
|
48
48
|
version = major + '.' + minor + '.' + patch + (add ? '-' + add : ''),
|
|
49
49
|
constants;
|
|
@@ -5511,7 +5511,8 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.extend(
|
|
|
5511
5511
|
} else if (this.elementClass === _constants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.OBJECT_CLASS_CIRCLE) {
|
|
5512
5512
|
x = this.center.X();
|
|
5513
5513
|
y = this.center.Y();
|
|
5514
|
-
|
|
5514
|
+
r = this.Radius(); // this.radius
|
|
5515
|
+
bb = [x - r, y + r, x + r, y - r];
|
|
5515
5516
|
} else if (this.elementClass === _constants_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.OBJECT_CLASS_CURVE) {
|
|
5516
5517
|
le = this.points.length;
|
|
5517
5518
|
if (le === 0) {
|
|
@@ -7730,8 +7731,8 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.createHTMLSlider = func
|
|
|
7730
7731
|
}
|
|
7731
7732
|
|
|
7732
7733
|
// Backwards compatibility
|
|
7733
|
-
attr.anchor = attr.parent
|
|
7734
|
-
attr.fixed = attr.fixed
|
|
7734
|
+
attr.anchor = _utils_type_js__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A.def(attr.parent, attr.anchor);
|
|
7735
|
+
attr.fixed = _utils_type_js__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A.def(attr.fixed, true);
|
|
7735
7736
|
|
|
7736
7737
|
par = [
|
|
7737
7738
|
parents[0][0],
|
|
@@ -15707,10 +15708,10 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15707
15708
|
}),
|
|
15708
15709
|
|
|
15709
15710
|
/**
|
|
15710
|
-
* Calculates the cosine
|
|
15711
|
+
* Calculates the hyperbolic cosine of \\(x\\).
|
|
15711
15712
|
* @function
|
|
15712
15713
|
* @param {Number} x The number the cosine hyperbolicus will be calculated of.
|
|
15713
|
-
* @returns {Number}
|
|
15714
|
+
* @returns {Number} Hyperbolic cosine of the given value.
|
|
15714
15715
|
*/
|
|
15715
15716
|
cosh:
|
|
15716
15717
|
Math.cosh ||
|
|
@@ -15719,10 +15720,10 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15719
15720
|
},
|
|
15720
15721
|
|
|
15721
15722
|
/**
|
|
15722
|
-
*
|
|
15723
|
+
* Hyperbolic sine of \\(x\\).
|
|
15723
15724
|
* @function
|
|
15724
|
-
* @param {Number} x The number the sine
|
|
15725
|
-
* @returns {Number}
|
|
15725
|
+
* @param {Number} x The number the hyperbolic sine will be calculated of.
|
|
15726
|
+
* @returns {Number} Hyperbolic sine of the given value.
|
|
15726
15727
|
*/
|
|
15727
15728
|
sinh:
|
|
15728
15729
|
Math.sinh ||
|
|
@@ -15731,7 +15732,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15731
15732
|
},
|
|
15732
15733
|
|
|
15733
15734
|
/**
|
|
15734
|
-
*
|
|
15735
|
+
* Inverse hyperbolic cosine of a number.
|
|
15735
15736
|
* @function
|
|
15736
15737
|
* @param {Number} x
|
|
15737
15738
|
* @returns {Number}
|
|
@@ -15743,7 +15744,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15743
15744
|
},
|
|
15744
15745
|
|
|
15745
15746
|
/**
|
|
15746
|
-
*
|
|
15747
|
+
* Inverse hyperbolic sine of a number
|
|
15747
15748
|
* @function
|
|
15748
15749
|
* @param {Number} x
|
|
15749
15750
|
* @returns {Number}
|
|
@@ -15820,7 +15821,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15820
15821
|
},
|
|
15821
15822
|
|
|
15822
15823
|
/**
|
|
15823
|
-
* Computes cube root of real number
|
|
15824
|
+
* Computes cube root of real number.
|
|
15824
15825
|
* Polyfill for Math.cbrt().
|
|
15825
15826
|
*
|
|
15826
15827
|
* @function
|
|
@@ -15940,7 +15941,11 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15940
15941
|
},
|
|
15941
15942
|
|
|
15942
15943
|
/**
|
|
15943
|
-
* A square & multiply algorithm to compute base to the power of exponent
|
|
15944
|
+
* A square & multiply algorithm to compute `base` to the power of `exponent`.
|
|
15945
|
+
* That is, for base \\(b\\) and integer exponent \\(e\\) it is a fast method to compute
|
|
15946
|
+
* \\[ b^e .\\]
|
|
15947
|
+
* For non-integer values of `exponent`, JavaScript's `Math.pow` is used.
|
|
15948
|
+
*
|
|
15944
15949
|
* Implementated by Wolfgang Riedl.
|
|
15945
15950
|
*
|
|
15946
15951
|
* @param {Number} base
|
|
@@ -15975,16 +15980,17 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15975
15980
|
},
|
|
15976
15981
|
|
|
15977
15982
|
/**
|
|
15978
|
-
* Greatest common divisor (gcd) of two numbers.
|
|
15979
|
-
* See {@link
|
|
15983
|
+
* Greatest common divisor (gcd) of two finite, non-zero integer numbers.
|
|
15984
|
+
* See {@link https://rosettacode.org/wiki/Greatest_common_divisor#JavaScript rosettacode.org}.
|
|
15980
15985
|
*
|
|
15981
|
-
* @param {Number} a First number
|
|
15982
|
-
* @param {Number} b Second number
|
|
15983
|
-
* @returns {Number}
|
|
15986
|
+
* @param {Number} a First number, not zero, Infinity, or NaN
|
|
15987
|
+
* @param {Number} b Second number, not zero, Infinity, or NaN
|
|
15988
|
+
* @returns {Number} gcd(a, b) if a and b are finite, non-zero numbers, NaN else.
|
|
15989
|
+
* @see JXG.Math#lcm
|
|
15984
15990
|
*/
|
|
15985
15991
|
gcd: function (a, b) {
|
|
15986
15992
|
var tmp,
|
|
15987
|
-
endless =
|
|
15993
|
+
endless = 100000;
|
|
15988
15994
|
|
|
15989
15995
|
a = Math.abs(a);
|
|
15990
15996
|
b = Math.abs(b);
|
|
@@ -15992,13 +15998,24 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
15992
15998
|
if (!(_utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(a) && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(b))) {
|
|
15993
15999
|
return NaN;
|
|
15994
16000
|
}
|
|
16001
|
+
if (isNaN(a) || isNaN(b) || a === Infinity || b === Infinity) {
|
|
16002
|
+
return NaN;
|
|
16003
|
+
}
|
|
16004
|
+
if (a === 0 || b === 0) {
|
|
16005
|
+
return NaN;
|
|
16006
|
+
}
|
|
16007
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
16008
|
+
_jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.warn('JSXGraph: JXG.Math.gcd requires integer parameters');
|
|
16009
|
+
return NaN;
|
|
16010
|
+
}
|
|
16011
|
+
|
|
15995
16012
|
if (b > a) {
|
|
15996
16013
|
tmp = a;
|
|
15997
16014
|
a = b;
|
|
15998
16015
|
b = tmp;
|
|
15999
16016
|
}
|
|
16000
16017
|
|
|
16001
|
-
while (endless) {
|
|
16018
|
+
while (endless > 0) {
|
|
16002
16019
|
a %= b;
|
|
16003
16020
|
if (a === 0) {
|
|
16004
16021
|
return b;
|
|
@@ -16007,15 +16024,18 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16007
16024
|
if (b === 0) {
|
|
16008
16025
|
return a;
|
|
16009
16026
|
}
|
|
16027
|
+
endless--;
|
|
16010
16028
|
}
|
|
16011
16029
|
},
|
|
16012
16030
|
|
|
16013
16031
|
/**
|
|
16014
|
-
* Least common multiple (lcm) of two numbers.
|
|
16032
|
+
* Least common multiple (lcm) of two finite integer numbers.
|
|
16033
|
+
* lcm(0, a) is defined as 0.
|
|
16015
16034
|
*
|
|
16016
16035
|
* @param {Number} a First number
|
|
16017
16036
|
* @param {Number} b Second number
|
|
16018
|
-
* @returns {Number}
|
|
16037
|
+
* @returns {Number} lcm(a, b) if a and b are finite integer numbers, NaN else.
|
|
16038
|
+
* @see JXG.Math#gcd
|
|
16019
16039
|
*/
|
|
16020
16040
|
lcm: function (a, b) {
|
|
16021
16041
|
var ret;
|
|
@@ -16023,6 +16043,16 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16023
16043
|
if (!(_utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(a) && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(b))) {
|
|
16024
16044
|
return NaN;
|
|
16025
16045
|
}
|
|
16046
|
+
if (isNaN(a) || isNaN(b) || Math.abs(a) === Infinity || Math.abs(b) === Infinity) {
|
|
16047
|
+
return NaN;
|
|
16048
|
+
}
|
|
16049
|
+
if (a === 0 || b === 0) {
|
|
16050
|
+
return 0;
|
|
16051
|
+
}
|
|
16052
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
16053
|
+
_jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.warn('JSXGraph: JXG.Math.gcd requires integer parameters');
|
|
16054
|
+
return NaN;
|
|
16055
|
+
}
|
|
16026
16056
|
|
|
16027
16057
|
ret = a * b;
|
|
16028
16058
|
if (ret !== 0) {
|
|
@@ -16208,7 +16238,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16208
16238
|
/* ******************** Comparisons and logical operators ************** */
|
|
16209
16239
|
|
|
16210
16240
|
/**
|
|
16211
|
-
* Logical test: a < b
|
|
16241
|
+
* Logical test: `a < b`?
|
|
16212
16242
|
*
|
|
16213
16243
|
* @param {Number} a
|
|
16214
16244
|
* @param {Number} b
|
|
@@ -16219,7 +16249,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16219
16249
|
},
|
|
16220
16250
|
|
|
16221
16251
|
/**
|
|
16222
|
-
* Logical test: a <= b
|
|
16252
|
+
* Logical test: `a <= b`?
|
|
16223
16253
|
*
|
|
16224
16254
|
* @param {Number} a
|
|
16225
16255
|
* @param {Number} b
|
|
@@ -16230,7 +16260,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16230
16260
|
},
|
|
16231
16261
|
|
|
16232
16262
|
/**
|
|
16233
|
-
* Logical test: a > b
|
|
16263
|
+
* Logical test: `a > b`?
|
|
16234
16264
|
*
|
|
16235
16265
|
* @param {Number} a
|
|
16236
16266
|
* @param {Number} b
|
|
@@ -16241,7 +16271,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16241
16271
|
},
|
|
16242
16272
|
|
|
16243
16273
|
/**
|
|
16244
|
-
* Logical test: a >= b
|
|
16274
|
+
* Logical test: `a >= b`?
|
|
16245
16275
|
*
|
|
16246
16276
|
* @param {Number} a
|
|
16247
16277
|
* @param {Number} b
|
|
@@ -16252,7 +16282,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16252
16282
|
},
|
|
16253
16283
|
|
|
16254
16284
|
/**
|
|
16255
|
-
* Logical test: a === b
|
|
16285
|
+
* Logical test: `a === b`?
|
|
16256
16286
|
*
|
|
16257
16287
|
* @param {Number} a
|
|
16258
16288
|
* @param {Number} b
|
|
@@ -16263,7 +16293,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16263
16293
|
},
|
|
16264
16294
|
|
|
16265
16295
|
/**
|
|
16266
|
-
* Logical test: a !== b
|
|
16296
|
+
* Logical test: `a !== b`?
|
|
16267
16297
|
*
|
|
16268
16298
|
* @param {Number} a
|
|
16269
16299
|
* @param {Number} b
|
|
@@ -16274,7 +16304,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16274
16304
|
},
|
|
16275
16305
|
|
|
16276
16306
|
/**
|
|
16277
|
-
* Logical operator: a && b
|
|
16307
|
+
* Logical operator: `a && b`?
|
|
16278
16308
|
*
|
|
16279
16309
|
* @param {Boolean} a
|
|
16280
16310
|
* @param {Boolean} b
|
|
@@ -16285,7 +16315,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16285
16315
|
},
|
|
16286
16316
|
|
|
16287
16317
|
/**
|
|
16288
|
-
* Logical operator:
|
|
16318
|
+
* Logical operator: `!a`?
|
|
16289
16319
|
*
|
|
16290
16320
|
* @param {Boolean} a
|
|
16291
16321
|
* @returns {Boolean}
|
|
@@ -16295,7 +16325,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16295
16325
|
},
|
|
16296
16326
|
|
|
16297
16327
|
/**
|
|
16298
|
-
* Logical operator: a || b
|
|
16328
|
+
* Logical operator: `a || b`?
|
|
16299
16329
|
*
|
|
16300
16330
|
* @param {Boolean} a
|
|
16301
16331
|
* @param {Boolean} b
|
|
@@ -16306,7 +16336,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16306
16336
|
},
|
|
16307
16337
|
|
|
16308
16338
|
/**
|
|
16309
|
-
* Logical operator: either a or b
|
|
16339
|
+
* Logical operator: either `a` or `b`?
|
|
16310
16340
|
*
|
|
16311
16341
|
* @param {Boolean} a
|
|
16312
16342
|
* @param {Boolean} b
|
|
@@ -16385,7 +16415,7 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16385
16415
|
/* *************************** Normalize *************************** */
|
|
16386
16416
|
|
|
16387
16417
|
/**
|
|
16388
|
-
* Normalize the standard form [c, b0, b1, a, k, r, q0, q1]
|
|
16418
|
+
* Normalize the standard form `[c, b0, b1, a, k, r, q0, q1]`.
|
|
16389
16419
|
* @private
|
|
16390
16420
|
* @param {Array} stdform The standard form to be normalized.
|
|
16391
16421
|
* @returns {Array} The normalized standard form.
|
|
@@ -16456,13 +16486,13 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.Math = {
|
|
|
16456
16486
|
},
|
|
16457
16487
|
|
|
16458
16488
|
/**
|
|
16459
|
-
* Theorem of Vieta: Given a set of simple zeroes x_0,
|
|
16460
|
-
* of a polynomial f, compute the coefficients s_k, (k=0
|
|
16461
|
-
* of the polynomial of the form
|
|
16489
|
+
* Theorem of Vieta: Given a set of simple zeroes \\(x_0, \ldots, x_n\\)
|
|
16490
|
+
* of a polynomial \\(f\\), compute the coefficients \\(s_k\\), \\(k=0, \ldots, n-1\\),
|
|
16491
|
+
* of the polynomial of the form
|
|
16492
|
+
* \\[ f(x) = (x-x_0)\cdots(x-x_n) = x^n + \sum_{k=1}^{n} (-1)^k s_{k-1} x^{n-k} \\]
|
|
16493
|
+
*
|
|
16494
|
+
* See {@link https://en.wikipedia.org/wiki/Vieta%27s_formulas}
|
|
16462
16495
|
*
|
|
16463
|
-
* f(x) = (x-x_0)*...*(x-x_n) =
|
|
16464
|
-
* x^n + sum_{k=1}^{n} (-1)^(k) s_{k-1} x^(n-k)
|
|
16465
|
-
* </p>
|
|
16466
16496
|
* @param {Array} x Simple zeroes of the polynomial.
|
|
16467
16497
|
* @returns {Array} Coefficients of the polynomial.
|
|
16468
16498
|
*
|
|
@@ -17010,22 +17040,20 @@ _math_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A.Numerics = {
|
|
|
17010
17040
|
* Calculates the integral of function f over interval using Romberg iteration.
|
|
17011
17041
|
* @param {Array} interval The integration interval, e.g. [0, 3].
|
|
17012
17042
|
* @param {function} f A function which takes one argument of type number and returns a number.
|
|
17013
|
-
* @param {Object} [config] The algorithm setup. Accepted properties are max_iterations of type number and precision eps
|
|
17043
|
+
* @param {Object} [config] The algorithm setup. Accepted properties are `max_iterations` of type number and precision `eps`.
|
|
17014
17044
|
* @param {Number} [config.max_iterations=20]
|
|
17015
17045
|
* @param {Number} [config.eps=0.0000001]
|
|
17016
17046
|
* @returns {Number} Integral value of f over interval
|
|
17017
17047
|
* @example
|
|
17018
|
-
*
|
|
17019
|
-
* return x*x;
|
|
17020
|
-
* }
|
|
17048
|
+
* var f = (x) => x * x;
|
|
17021
17049
|
*
|
|
17022
|
-
* //
|
|
17023
|
-
* var area1 = JXG.Math.Numerics.Romberg([0,
|
|
17050
|
+
* // Calculates integral of `f` from 0 to 3.
|
|
17051
|
+
* var area1 = JXG.Math.Numerics.Romberg([0, 3], f);
|
|
17024
17052
|
*
|
|
17025
|
-
* //
|
|
17026
|
-
* var area2 = JXG.Math.Numerics.Romberg([0,
|
|
17053
|
+
* // The same with an anonymous function
|
|
17054
|
+
* var area2 = JXG.Math.Numerics.Romberg([0, 3], function (x) { return x * x; });
|
|
17027
17055
|
*
|
|
17028
|
-
* //
|
|
17056
|
+
* // Use trapez rule with maximum of 16 iterations or stop if the precision 0.0001 has been reached.
|
|
17029
17057
|
* var area3 = JXG.Math.Numerics.Romberg([0, 2], f,
|
|
17030
17058
|
* {max_iterations: 16, eps: 0.0001});
|
|
17031
17059
|
* @memberof JXG.Math.Numerics
|
|
@@ -17042,8 +17070,11 @@ _math_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A.Numerics = {
|
|
|
17042
17070
|
p = [],
|
|
17043
17071
|
integral = 0.0,
|
|
17044
17072
|
last = Infinity,
|
|
17045
|
-
m
|
|
17046
|
-
|
|
17073
|
+
m, eps;
|
|
17074
|
+
|
|
17075
|
+
config = _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.def(config, {});
|
|
17076
|
+
m = config && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(config.max_iterations) ? config.max_iterations : 20;
|
|
17077
|
+
eps = config && _utils_type_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.isNumber(config.eps) ? config.eps : (config.eps || 0.0000001);
|
|
17047
17078
|
|
|
17048
17079
|
a = interval[0];
|
|
17049
17080
|
b = interval[1];
|
|
@@ -17310,7 +17341,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A.Numerics = {
|
|
|
17310
17341
|
xm = 0.5 * (b - a);
|
|
17311
17342
|
xp = 0.5 * (b + a);
|
|
17312
17343
|
|
|
17313
|
-
if (n &
|
|
17344
|
+
if ((n & 1) === 1) {
|
|
17314
17345
|
// n odd
|
|
17315
17346
|
result = w[0] * f(xp);
|
|
17316
17347
|
for (i = 1; i < m; ++i) {
|
|
@@ -22196,12 +22227,12 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22196
22227
|
* The Theil-Sen estimator can be used to determine a more robust linear regression of a set of sample
|
|
22197
22228
|
* points than least squares regression in {@link JXG.Math.Numerics.regressionPolynomial}.
|
|
22198
22229
|
*
|
|
22199
|
-
* If the function should be applied to an array a of points
|
|
22200
|
-
* JavaScript array.map
|
|
22230
|
+
* If the function should be applied to an array `a` of *points*, a coords array can be generated with
|
|
22231
|
+
* JavaScript `array.map`:
|
|
22201
22232
|
*
|
|
22202
|
-
*
|
|
22233
|
+
* ```
|
|
22203
22234
|
* JXG.Math.Statistics.TheilSenRegression(a.map(el => el.coords));
|
|
22204
|
-
*
|
|
22235
|
+
* ```
|
|
22205
22236
|
*
|
|
22206
22237
|
* @param {Array} coords Array of {@link JXG.Coords}.
|
|
22207
22238
|
* @returns {Array} A stdform array of the regression line.
|
|
@@ -22209,10 +22240,10 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22209
22240
|
*
|
|
22210
22241
|
* @example
|
|
22211
22242
|
* var board = JXG.JSXGraph.initBoard('jxgbox', { boundingbox: [-6,6,6,-6], axis : true });
|
|
22212
|
-
* var a=[];
|
|
22213
|
-
* a[0]=board.create('point', [0,0]);
|
|
22214
|
-
* a[1]=board.create('point', [3,0]);
|
|
22215
|
-
* a[2]=board.create('point', [0,3]);
|
|
22243
|
+
* var a = [];
|
|
22244
|
+
* a[0] = board.create('point', [0, 0]);
|
|
22245
|
+
* a[1] = board.create('point', [3, 0]);
|
|
22246
|
+
* a[2] = board.create('point', [0, 3]);
|
|
22216
22247
|
*
|
|
22217
22248
|
* board.create('line', [
|
|
22218
22249
|
* () => JXG.Math.Statistics.TheilSenRegression(a.map(el => el.coords))
|
|
@@ -22266,7 +22297,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22266
22297
|
|
|
22267
22298
|
/**
|
|
22268
22299
|
* Generate values of a standard normal random variable with the Marsaglia polar method, see
|
|
22269
|
-
*
|
|
22300
|
+
* {@link https://en.wikipedia.org/wiki/Marsaglia_polar_method}..
|
|
22270
22301
|
* See also D. E. Knuth, The art of computer programming, vol 2, p. 117.
|
|
22271
22302
|
*
|
|
22272
22303
|
* @param {Number} mean mean value of the normal distribution
|
|
@@ -22356,7 +22387,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22356
22387
|
},
|
|
22357
22388
|
|
|
22358
22389
|
/**
|
|
22359
|
-
* Generate value of a uniform distributed random variable in the interval [a, b]
|
|
22390
|
+
* Generate value of a uniform distributed random variable in the interval `[a, b]`.
|
|
22360
22391
|
* @param {Number} a
|
|
22361
22392
|
* @param {Number} b
|
|
22362
22393
|
* @returns Number
|
|
@@ -22368,7 +22399,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22368
22399
|
|
|
22369
22400
|
/**
|
|
22370
22401
|
* Generate value of a random variable with exponential distribution, i.e.
|
|
22371
|
-
* \\(f(x; \lambda) = \lambda
|
|
22402
|
+
* \\(f(x; \lambda) = \lambda \cdot e^{-\lambda x}\\) if \\(x \geq 0\\) and \\(f(x; \lambda) = 0\\) if \\(x < 0\\).
|
|
22372
22403
|
* See <a href="https://en.wikipedia.org/wiki/Exponential_distribution">https://en.wikipedia.org/wiki/Exponential_distribution</a>.
|
|
22373
22404
|
* Algorithm: D.E. Knuth, TAOCP 2, p. 128.
|
|
22374
22405
|
*
|
|
@@ -22437,7 +22468,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22437
22468
|
|
|
22438
22469
|
/**
|
|
22439
22470
|
* Generate value of a random variable with gamma distribution of order alpha.
|
|
22440
|
-
* See
|
|
22471
|
+
* See {@link https://en.wikipedia.org/wiki/Gamma_distribution}.
|
|
22441
22472
|
* Algorithm: D.E. Knuth, TAOCP 2, p. 129.
|
|
22442
22473
|
|
|
22443
22474
|
* @param {Number} a shape, \\( > 0\\)
|
|
@@ -22553,7 +22584,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22553
22584
|
|
|
22554
22585
|
/**
|
|
22555
22586
|
* Generate value of a random variable with beta distribution with shape parameters alpha and beta.
|
|
22556
|
-
* See
|
|
22587
|
+
* See {@link https://en.wikipedia.org/wiki/Beta_distribution}.
|
|
22557
22588
|
*
|
|
22558
22589
|
* @param {Number} alpha \\(< 0\\)
|
|
22559
22590
|
* @param {Number} beta \\(< 0\\)
|
|
@@ -22576,7 +22607,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22576
22607
|
|
|
22577
22608
|
/**
|
|
22578
22609
|
* Generate value of a random variable with chi-square distribution with k degrees of freedom.
|
|
22579
|
-
* See
|
|
22610
|
+
* See {@link https://en.wikipedia.org/wiki/Chi-squared_distribution}.
|
|
22580
22611
|
*
|
|
22581
22612
|
* @param {Number} k \\(>0\\)
|
|
22582
22613
|
* @returns Number
|
|
@@ -22594,7 +22625,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22594
22625
|
|
|
22595
22626
|
/**
|
|
22596
22627
|
* Generate value of a random variable with F-distribution with d<sub>1</sub> and d<sub>2</sub> degrees of freedom.
|
|
22597
|
-
* See
|
|
22628
|
+
* See {@link https://en.wikipedia.org/wiki/F-distribution}.
|
|
22598
22629
|
* @param {Number} d1 \\(>0\\)
|
|
22599
22630
|
* @param {Number} d2 \\(>0\\)
|
|
22600
22631
|
* @returns Number
|
|
@@ -22616,7 +22647,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22616
22647
|
|
|
22617
22648
|
/**
|
|
22618
22649
|
* Generate value of a random variable with Students-t-distribution with ν degrees of freedom.
|
|
22619
|
-
* See
|
|
22650
|
+
* See {@link https://en.wikipedia.org/wiki/Student%27s_t-distribution}.
|
|
22620
22651
|
* @param {Number} nu \\(>0\\)
|
|
22621
22652
|
* @returns Number
|
|
22622
22653
|
* @memberof JXG.Math.Statistics
|
|
@@ -22637,8 +22668,8 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22637
22668
|
|
|
22638
22669
|
/**
|
|
22639
22670
|
* Generate values for a random variable in binomial distribution with parameters \\(n\\) and \\(p\\).
|
|
22640
|
-
* See
|
|
22641
|
-
* It uses algorithm BG from
|
|
22671
|
+
* See {@link https://en.wikipedia.org/wiki/Binomial_distribution}.
|
|
22672
|
+
* It uses algorithm BG from {@link https://dl.acm.org/doi/pdf/10.1145/42372.42381}.
|
|
22642
22673
|
*
|
|
22643
22674
|
* @param {Number} n Number of trials (n >= 0)
|
|
22644
22675
|
* @param {Number} p Probability (0 <= p <= 1)
|
|
@@ -22762,7 +22793,7 @@ _math_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.Statistics = {
|
|
|
22762
22793
|
|
|
22763
22794
|
/**
|
|
22764
22795
|
* Generate values for a random variable in geometric distribution with probability \\(p\\).
|
|
22765
|
-
* See
|
|
22796
|
+
* See {@link https://en.wikipedia.org/wiki/Geometric_distribution}.
|
|
22766
22797
|
*
|
|
22767
22798
|
* @param {Number} p (0 <= p <= 1)
|
|
22768
22799
|
* @returns Number
|
|
@@ -38548,7 +38579,7 @@ upcomingInput:function () {
|
|
|
38548
38579
|
showPosition:function () {
|
|
38549
38580
|
var pre = this.pastInput();
|
|
38550
38581
|
var c = new Array(pre.length + 1).join("-");
|
|
38551
|
-
return pre + this.upcomingInput() + "\n" + c+"^";
|
|
38582
|
+
return _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.escapeHTML(pre + this.upcomingInput() + "\n" + c+"^");
|
|
38552
38583
|
},
|
|
38553
38584
|
next:function () {
|
|
38554
38585
|
if (this.done) {
|
|
@@ -42796,8 +42827,10 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.extend(
|
|
|
42796
42827
|
mergeAttr: function (attr, special, toLower, ignoreUndefinedSpecials) {
|
|
42797
42828
|
var e, e2, o;
|
|
42798
42829
|
|
|
42799
|
-
toLower = toLower || true;
|
|
42800
|
-
|
|
42830
|
+
// toLower = toLower || true;
|
|
42831
|
+
// ignoreUndefinedSpecials || false;
|
|
42832
|
+
toLower = this.def(toLower, true);
|
|
42833
|
+
ignoreUndefinedSpecials = this.def(ignoreUndefinedSpecials, false);
|
|
42801
42834
|
|
|
42802
42835
|
for (e in special) {
|
|
42803
42836
|
if (special.hasOwnProperty(e)) {
|
|
@@ -43270,8 +43303,13 @@ _jxg_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.extend(
|
|
|
43270
43303
|
* @returns {String}
|
|
43271
43304
|
*/
|
|
43272
43305
|
trimNumber: function (str) {
|
|
43273
|
-
str
|
|
43274
|
-
|
|
43306
|
+
if (str !== '0') {
|
|
43307
|
+
str = str.replace(/^0+/, "");
|
|
43308
|
+
}
|
|
43309
|
+
|
|
43310
|
+
if (str.indexOf('.') >= 0 || str.indexOf(',') >= 0) {
|
|
43311
|
+
str = str.replace(/0+$/, "");
|
|
43312
|
+
}
|
|
43275
43313
|
|
|
43276
43314
|
if (str[str.length - 1] === "." || str[str.length - 1] === ",") {
|
|
43277
43315
|
str = str.slice(0, -1);
|
|
@@ -54390,11 +54428,11 @@ jxg/* default */.A.Complex.C = jxg/* default */.A.C;
|
|
|
54390
54428
|
math/* default */.A.Tiling = {
|
|
54391
54429
|
/**
|
|
54392
54430
|
* Triangulate (partition it into triangles) a given two dimensional domain.
|
|
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
|
|
54431
|
+
* The number of triangles the original rectangle is divided into depends on the parameters` `stepsU` and `stepsV`.
|
|
54432
|
+
* Input are the ranges of \\(u\\) and \\(v\\), as well as `stepsU` and `stepsV` which are static.
|
|
54433
|
+
* If the optional parameter `stepsV` is not given or is equal to 0, the rectangle is partitioned into
|
|
54396
54434
|
* nearly equilateral triangles.
|
|
54397
|
-
* Otherwise, the shape of the triangles depends on the ratio of stepsU / stepsV
|
|
54435
|
+
* Otherwise, the shape of the triangles depends on the ratio of `stepsU / stepsV`.
|
|
54398
54436
|
*
|
|
54399
54437
|
* @param {JXG.ParametricSurface3D|JXG.Plane3D} el element which is displayed using a polyhedron3d.
|
|
54400
54438
|
* From this element its function F is used.
|
|
@@ -54550,8 +54588,8 @@ math/* default */.A.Tiling = {
|
|
|
54550
54588
|
|
|
54551
54589
|
/**
|
|
54552
54590
|
* Rectangulate (partition it into rectangles) a given two dimensional domain.
|
|
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.
|
|
54591
|
+
* The number of rectangles the original rectangle is divided into depends on the parameters `stepsU` and `stepsV`.
|
|
54592
|
+
* Input are the ranges of \\(u\\) and \\(v\\), as well as `stepsU` and `stepsV` which are static.
|
|
54555
54593
|
*
|
|
54556
54594
|
* @param {JXG.ParametricSurface3D|JXG.Plane3D} el element which is displayed using a polyhedron3d.
|
|
54557
54595
|
* From this element its function F is used.
|
|
@@ -54675,288 +54713,6 @@ math/* default */.A.Tiling = {
|
|
|
54675
54713
|
}
|
|
54676
54714
|
return [vertices, faces];
|
|
54677
54715
|
}
|
|
54678
|
-
|
|
54679
|
-
// triangulation_old: function (p1, p2, p3, p4, stepsU, stepsV) {
|
|
54680
|
-
// // Vectors used for checking if the given coordinates create a rectangle
|
|
54681
|
-
// var vec1 = [p2[0] - p1[0], p2[1] - p1[1]],
|
|
54682
|
-
// vec2 = [p3[0] - p2[0], p3[1] - p2[1]],
|
|
54683
|
-
// vec3 = [p4[0] - p3[0], p4[1] - p3[1]],
|
|
54684
|
-
// vec4 = [p1[0] - p4[0], p1[1] - p4[1]],
|
|
54685
|
-
|
|
54686
|
-
// coords = [],
|
|
54687
|
-
// faces = [],
|
|
54688
|
-
// width, height,
|
|
54689
|
-
// wSide, hSide,
|
|
54690
|
-
// triangleWidth, triangleHeight,
|
|
54691
|
-
// s1, s2,
|
|
54692
|
-
// i, j,
|
|
54693
|
-
// numRows,
|
|
54694
|
-
// widthX, widthY, heightX, heightY,
|
|
54695
|
-
// oddPoints,
|
|
54696
|
-
// evenPoints;
|
|
54697
|
-
|
|
54698
|
-
// // Check if the given coordinates create a rectangle, otherwise an exception is thrown
|
|
54699
|
-
// if (
|
|
54700
|
-
// vec1[0] * vec4[0] + vec1[1] * vec4[1] !== 0 ||
|
|
54701
|
-
// vec2[0] * vec1[0] + vec2[1] * vec1[1] !== 0 ||
|
|
54702
|
-
// vec3[0] * vec2[0] + vec3[1] * vec2[1] !== 0 ||
|
|
54703
|
-
// vec4[0] * vec3[0] + vec4[1] * vec3[1] !== 0
|
|
54704
|
-
// ) {
|
|
54705
|
-
// throw new Error(" the board created is not rectangle ");
|
|
54706
|
-
// }
|
|
54707
|
-
|
|
54708
|
-
// // Set initial values for wSide, hSide
|
|
54709
|
-
// wSide = [0, 0];
|
|
54710
|
-
// hSide = [0, 0];
|
|
54711
|
-
|
|
54712
|
-
// // Check for longer side of rectangle:
|
|
54713
|
-
// // longer side is appointed height, shorter side is appointed width
|
|
54714
|
-
// s1 = Math.sqrt((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]));
|
|
54715
|
-
// s2 = Math.sqrt((p3[0] - p2[0]) * (p3[0] - p2[0]) + (p3[1] - p2[1]) * (p3[1] - p2[1]));
|
|
54716
|
-
// if (s1 <= s2) {
|
|
54717
|
-
// width = s1;
|
|
54718
|
-
// height = s2;
|
|
54719
|
-
// // Determine start and end points of the width-side and height-side
|
|
54720
|
-
// wSide = [p1, p2];
|
|
54721
|
-
// hSide = [p2, p3];
|
|
54722
|
-
// } else {
|
|
54723
|
-
// width = s2;
|
|
54724
|
-
// height = s1;
|
|
54725
|
-
// // Determine start and end points of the width-side and height-side
|
|
54726
|
-
// wSide = [p2, p3];
|
|
54727
|
-
// hSide = [p1, p2];
|
|
54728
|
-
// }
|
|
54729
|
-
// // Calculate height and width of the triangles and number of rows
|
|
54730
|
-
// triangleWidth = width / stepsU;
|
|
54731
|
-
|
|
54732
|
-
// if (stepsV === undefined || stepsV === 0) {
|
|
54733
|
-
// // Equilateral triangles, depending on parameter "stepsU"
|
|
54734
|
-
// triangleHeight = (triangleWidth * Math.sqrt(3)) / 2;
|
|
54735
|
-
// numRows = Math.round(height / triangleHeight);
|
|
54736
|
-
// } else {
|
|
54737
|
-
// // Two parameters stepsU, stepsV
|
|
54738
|
-
// numRows = stepsV;
|
|
54739
|
-
// triangleHeight = height / numRows;
|
|
54740
|
-
// }
|
|
54741
|
-
|
|
54742
|
-
// // Calculate values of "shifting vectors"
|
|
54743
|
-
// widthX = (wSide[1][0] - wSide[0][0]) / stepsU;
|
|
54744
|
-
// widthY = (wSide[1][1] - wSide[0][1]) / stepsU;
|
|
54745
|
-
// heightX = (hSide[1][0] - hSide[0][0]) / numRows;
|
|
54746
|
-
// heightY = (hSide[1][1] - hSide[0][1]) / numRows;
|
|
54747
|
-
|
|
54748
|
-
// oddPoints = [];
|
|
54749
|
-
// evenPoints = [];
|
|
54750
|
-
|
|
54751
|
-
// // Push coordinates of the base point (p1)
|
|
54752
|
-
// coords.push([p1[0], p1[1]]);
|
|
54753
|
-
// evenPoints.push(coords.length - 1);
|
|
54754
|
-
|
|
54755
|
-
// // Calculate point coordinates of layer 0 and store indices in evenPoints
|
|
54756
|
-
// for (i = 1; i <= stepsU; i++) {
|
|
54757
|
-
// coords.push([p1[0] + i * widthX, p1[1] + i * widthY]); // Points first line
|
|
54758
|
-
// evenPoints.push(coords.length - 1);
|
|
54759
|
-
// }
|
|
54760
|
-
|
|
54761
|
-
// for (i = 1; i <= numRows; i++) {
|
|
54762
|
-
// if (i % 2 === 0) {
|
|
54763
|
-
// // Points and faces of layers with an even index
|
|
54764
|
-
|
|
54765
|
-
// evenPoints = [];
|
|
54766
|
-
// // Calculate first point coordinates within the layer
|
|
54767
|
-
// coords.push([
|
|
54768
|
-
// p1[0] + i * heightX,
|
|
54769
|
-
// p1[1] + i * heightY
|
|
54770
|
-
// ]);
|
|
54771
|
-
// // evenPoints stores index of the first point of the layer
|
|
54772
|
-
// evenPoints.push(coords.length - 1);
|
|
54773
|
-
// // Calculate all other point coordinates within the layer
|
|
54774
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54775
|
-
// coords.push([
|
|
54776
|
-
// coords[evenPoints[0]][0] + j * widthX,
|
|
54777
|
-
// coords[evenPoints[0]][1] + j * widthY
|
|
54778
|
-
// ]);
|
|
54779
|
-
// //evenPoints stores index of the most recently calculated point of the layer
|
|
54780
|
-
// evenPoints.push(coords.length - 1);
|
|
54781
|
-
// }
|
|
54782
|
-
// // Connect the faces of the row by grouping indices of points
|
|
54783
|
-
// faces.push([evenPoints[0], oddPoints[0], oddPoints[1]]);
|
|
54784
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54785
|
-
// faces.push([evenPoints[j - 1], oddPoints[j], evenPoints[j]]);
|
|
54786
|
-
// faces.push([evenPoints[j], oddPoints[j], oddPoints[j + 1]]);
|
|
54787
|
-
// }
|
|
54788
|
-
// } else {
|
|
54789
|
-
// // Points and faces of layers with an odd index
|
|
54790
|
-
|
|
54791
|
-
// oddPoints = [];
|
|
54792
|
-
// // Calculate first point coordinates within the layer
|
|
54793
|
-
// coords.push([
|
|
54794
|
-
// p1[0] + i * heightX,
|
|
54795
|
-
// p1[1] + i * heightY
|
|
54796
|
-
// ]);
|
|
54797
|
-
// // oddPoints stores index of the first point of the layer
|
|
54798
|
-
// oddPoints.push(coords.length - 1);
|
|
54799
|
-
// // Calculate all other point coordinates within the layer except for the last point
|
|
54800
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54801
|
-
// coords.push([
|
|
54802
|
-
// coords[oddPoints[0]][0] + j * widthX - widthX / 2,
|
|
54803
|
-
// coords[oddPoints[0]][1] + j * widthY - widthY / 2
|
|
54804
|
-
// ]);
|
|
54805
|
-
// // oddPoints stores index of the most recently calculated point of the layer
|
|
54806
|
-
// oddPoints.push(coords.length - 1);
|
|
54807
|
-
// }
|
|
54808
|
-
// // Calculate last point coordinates within the layer
|
|
54809
|
-
// coords.push([
|
|
54810
|
-
// coords[oddPoints[0]][0] + stepsU * widthX,
|
|
54811
|
-
// coords[oddPoints[0]][1] + stepsU * widthY
|
|
54812
|
-
// ]);
|
|
54813
|
-
// // oddPoints stores index of last point within the layer
|
|
54814
|
-
// oddPoints.push(coords.length - 1);
|
|
54815
|
-
// // Connect the faces of the row by grouping indices of points
|
|
54816
|
-
// faces.push([oddPoints[0], evenPoints[0], oddPoints[1]]);
|
|
54817
|
-
// for (j = 1; j <= stepsU; j++) {
|
|
54818
|
-
// faces.push([oddPoints[j], evenPoints[j - 1], evenPoints[j]]);
|
|
54819
|
-
// faces.push([oddPoints[j], evenPoints[j], oddPoints[j + 1]]);
|
|
54820
|
-
// }
|
|
54821
|
-
// }
|
|
54822
|
-
// }
|
|
54823
|
-
|
|
54824
|
-
// return [coords, faces];
|
|
54825
|
-
// },
|
|
54826
|
-
|
|
54827
|
-
// rectangulation_old: function (p1, p2, p3, p4, stepsU, stepsV) {
|
|
54828
|
-
// // Vectors used for checking if the given coordinates create a rectangle
|
|
54829
|
-
// var vec1 = [p2[0] - p1[0], p2[1] - p1[1]],
|
|
54830
|
-
// vec2 = [p3[0] - p2[0], p3[1] - p2[1]],
|
|
54831
|
-
// vec3 = [p4[0] - p3[0], p4[1] - p3[1]],
|
|
54832
|
-
// vec4 = [p1[0] - p4[0], p1[1] - p4[1]],
|
|
54833
|
-
|
|
54834
|
-
// coords = [],
|
|
54835
|
-
// faces = [],
|
|
54836
|
-
// wSide, hSide,
|
|
54837
|
-
// s1, s2,
|
|
54838
|
-
// i, j,
|
|
54839
|
-
// widthX, widthY,
|
|
54840
|
-
// heightX, heightY,
|
|
54841
|
-
// startPointLayer;
|
|
54842
|
-
|
|
54843
|
-
// // Check if the given coordinates create a rectangle, otherwise an exception is thrown
|
|
54844
|
-
// if (
|
|
54845
|
-
// vec1[0] * vec4[0] + vec1[1] * vec4[1] !== 0 ||
|
|
54846
|
-
// vec2[0] * vec1[0] + vec2[1] * vec1[1] !== 0 ||
|
|
54847
|
-
// vec3[0] * vec2[0] + vec3[1] * vec2[1] !== 0 ||
|
|
54848
|
-
// vec4[0] * vec3[0] + vec4[1] * vec3[1] !== 0
|
|
54849
|
-
// ) {
|
|
54850
|
-
// throw new Error("rectangulation_old: area is not rectangle ");
|
|
54851
|
-
// // console.log("rectangulation_old: area is not rectangle ");
|
|
54852
|
-
// }
|
|
54853
|
-
|
|
54854
|
-
// // Set initial values for wSide, hSide
|
|
54855
|
-
// wSide = [0, 0];
|
|
54856
|
-
// hSide = [0, 0];
|
|
54857
|
-
|
|
54858
|
-
// // Check for longer side of rectangle:
|
|
54859
|
-
// // longer side is appointed height, shorter side is appointed width
|
|
54860
|
-
// // s1 = Math.sqrt((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]));
|
|
54861
|
-
// // s2 = Math.sqrt((p3[0] - p2[0]) * (p3[0] - p2[0]) + (p3[1] - p2[1]) * (p3[1] - p2[1]));
|
|
54862
|
-
// s1 = Mat.hypot(vec1[0], vec1[1]);
|
|
54863
|
-
// s2 = Mat.hypot(vec2[0], vec2[1]);
|
|
54864
|
-
|
|
54865
|
-
// if (s1 <= s2) {
|
|
54866
|
-
// // Determine start and end points of the width-side and height-side
|
|
54867
|
-
// wSide = [p1, p2];
|
|
54868
|
-
// hSide = [p2, p3];
|
|
54869
|
-
// } else {
|
|
54870
|
-
// // Determine start and end points of the width-side and height-side
|
|
54871
|
-
// wSide = [p2, p3];
|
|
54872
|
-
// hSide = [p1, p2];
|
|
54873
|
-
// }
|
|
54874
|
-
|
|
54875
|
-
// // Calculate values of "shifting vectors"
|
|
54876
|
-
// widthX = (wSide[1][0] - wSide[0][0]) / stepsV;
|
|
54877
|
-
// widthY = (wSide[1][1] - wSide[0][1]) / stepsV;
|
|
54878
|
-
// heightX = (hSide[1][0] - hSide[0][0]) / stepsU;
|
|
54879
|
-
// heightY = (hSide[1][1] - hSide[0][1]) / stepsU;
|
|
54880
|
-
|
|
54881
|
-
// // Initialize startPointLayer that stores coordinates of the first point of the current layer
|
|
54882
|
-
// startPointLayer = [];
|
|
54883
|
-
|
|
54884
|
-
// // Push coordinates of base point (p1)
|
|
54885
|
-
// coords.push([p1[0], p1[1]]);
|
|
54886
|
-
// startPointLayer = coords[0];
|
|
54887
|
-
|
|
54888
|
-
// // Calculate point coordinates of layer 0
|
|
54889
|
-
// for (j = 1; j <= stepsV; j++) {
|
|
54890
|
-
// coords.push([startPointLayer[0] + j * widthX, startPointLayer[1] + j * widthY]);
|
|
54891
|
-
// }
|
|
54892
|
-
|
|
54893
|
-
// for (i = 1; i <= stepsU; i++) {
|
|
54894
|
-
// startPointLayer = [];
|
|
54895
|
-
|
|
54896
|
-
// // Calculate point coordinates of first point of layer
|
|
54897
|
-
// coords.push([
|
|
54898
|
-
// p1[0] + i * heightX,
|
|
54899
|
-
// p1[1] + i * heightY
|
|
54900
|
-
// ]);
|
|
54901
|
-
// startPointLayer = coords[coords.length - 1];
|
|
54902
|
-
|
|
54903
|
-
// // Calculating remaining point coordinates of layer
|
|
54904
|
-
// for (j = 1; j <= stepsV; j++) {
|
|
54905
|
-
// coords.push([
|
|
54906
|
-
// startPointLayer[0] + j * widthX,
|
|
54907
|
-
// startPointLayer[1] + j * widthY
|
|
54908
|
-
// ]);
|
|
54909
|
-
// }
|
|
54910
|
-
|
|
54911
|
-
// // Connect rectangles by grouping indices of points
|
|
54912
|
-
// for (
|
|
54913
|
-
// j = coords.length - stepsV - 1;
|
|
54914
|
-
// j < coords.length - 1;
|
|
54915
|
-
// j++
|
|
54916
|
-
// ) {
|
|
54917
|
-
// faces.push([j, j - stepsV - 1, j - stepsV, j + 1]);
|
|
54918
|
-
// }
|
|
54919
|
-
// }
|
|
54920
|
-
|
|
54921
|
-
// return [coords, faces];
|
|
54922
|
-
// },
|
|
54923
|
-
|
|
54924
|
-
// /**
|
|
54925
|
-
// * This function creates an array of dynamic 3-dimensional points
|
|
54926
|
-
// * based on an array of pairs of two coordinates.
|
|
54927
|
-
// * It uses a mathematical function to assign a third coordinate (the z-coordinate)
|
|
54928
|
-
// * to each pair of two coordinates.
|
|
54929
|
-
// * The 3-dimensional points are not stored directly.
|
|
54930
|
-
// * Instead the array stores JavaScript functions that utilize the mentioned mathematical function
|
|
54931
|
-
// * to return an array of three coordinates.
|
|
54932
|
-
// * This allows the recognition and proper visualization of changes to the underlying
|
|
54933
|
-
// * mathematical function.
|
|
54934
|
-
// * @name mapMeshTo3D
|
|
54935
|
-
// * @param {Array} surface
|
|
54936
|
-
// * @param {Parametricsurface3d} el
|
|
54937
|
-
// * @returns {Array} dynamicPoints array of [x, y, z] coordinates
|
|
54938
|
-
// *
|
|
54939
|
-
// * @private
|
|
54940
|
-
// * @memberof JXG.Math.Tiling
|
|
54941
|
-
// */
|
|
54942
|
-
// mapMeshTo3D: function (surface, el) {
|
|
54943
|
-
// var dynamicPoints = [], i;
|
|
54944
|
-
|
|
54945
|
-
// for (i = 0; i < surface[0].length; i++) {
|
|
54946
|
-
// dynamicPoints.push(
|
|
54947
|
-
// (function (u, v) {
|
|
54948
|
-
// return function(x, y) { return el.F(u, v); };
|
|
54949
|
-
// })(surface[0][i][0], surface[0][i][1])
|
|
54950
|
-
// ); // Capture values explicitly
|
|
54951
|
-
// // dynamicPoints.push(
|
|
54952
|
-
// // (function (u, v) {
|
|
54953
|
-
// // return function(x, y) { return el.F(Type.evaluate(u), Type.evaluate(v)); };
|
|
54954
|
-
// // })(surface[0][i][0], surface[0][i][1])
|
|
54955
|
-
// // ); // Capture values explicitly
|
|
54956
|
-
// }
|
|
54957
|
-
|
|
54958
|
-
// return dynamicPoints;
|
|
54959
|
-
// }
|
|
54960
54716
|
};
|
|
54961
54717
|
|
|
54962
54718
|
/* harmony default export */ const math_tiling = (math/* default */.A.Tiling);
|
|
@@ -58274,9 +58030,9 @@ jxg/* default */.A.extend(
|
|
|
58274
58030
|
/** @lends JXG.Composition.prototype */ {
|
|
58275
58031
|
/**
|
|
58276
58032
|
* Adds an element to the composition container.
|
|
58277
|
-
* @param {String} what Descriptive name for the element, e.g.
|
|
58278
|
-
* access the element later on. There are some reserved names:
|
|
58279
|
-
* updateRenderer
|
|
58033
|
+
* @param {String} what Descriptive name for the element, e.g. `startpoint` or `area`. This is used to
|
|
58034
|
+
* access the element later on. There are some reserved names: `elements`, `add`, `remove`, `update`, `prepareUpdate`,
|
|
58035
|
+
* `updateRenderer`, `highlight`, `noHighlight`, and all names that would form invalid object property names in
|
|
58280
58036
|
* JavaScript.
|
|
58281
58037
|
* @param {JXG.GeometryElement|JXG.Composition} element A reference to the element that is to be added. This can be
|
|
58282
58038
|
* another composition, too.
|
|
@@ -62800,6 +62556,9 @@ jxg/* default */.A.extend(
|
|
|
62800
62556
|
var w = width,
|
|
62801
62557
|
h = height,
|
|
62802
62558
|
// bb,
|
|
62559
|
+
bbox,
|
|
62560
|
+
offX = 0,
|
|
62561
|
+
offY = 0,
|
|
62803
62562
|
css,
|
|
62804
62563
|
width_adjustment, height_adjustment;
|
|
62805
62564
|
|
|
@@ -62836,7 +62595,38 @@ jxg/* default */.A.extend(
|
|
|
62836
62595
|
|
|
62837
62596
|
// If bounding box is not yet initialized, do it now.
|
|
62838
62597
|
if (isNaN(this.getBoundingBox()[0])) {
|
|
62839
|
-
|
|
62598
|
+
// This is not enough
|
|
62599
|
+
// this.setBoundingBox(this.attr.boundingbox, this.keepaspectratio, 'keep');
|
|
62600
|
+
// Instead, we do the same as in JXG.JSXGraphinitBoard():
|
|
62601
|
+
bbox = this.attr.boundingbox;
|
|
62602
|
+
if (utils_type/* default */.A.exists(bbox) && this.keepaspectratio) {
|
|
62603
|
+
/*
|
|
62604
|
+
* If the boundingbox attribute is given and the ratio of height and width of the
|
|
62605
|
+
* sides defined by the bounding box and the ratio of the dimensions of the div tag
|
|
62606
|
+
* which contains the board do not coincide, then the smaller side is chosen.
|
|
62607
|
+
*/
|
|
62608
|
+
this.unitX = w / (bbox[2] - bbox[0]);
|
|
62609
|
+
this.unitY = h / (bbox[1] - bbox[3]);
|
|
62610
|
+
|
|
62611
|
+
if (Math.abs(this.unitX) < Math.abs(this.unitY)) {
|
|
62612
|
+
this.unitY = (Math.abs(this.unitX) * this.unitY) / Math.abs(this.unitY);
|
|
62613
|
+
// Add the additional units in equal portions above and below
|
|
62614
|
+
offY = (h / this.unitY - (bbox[1] - bbox[3])) * 0.5;
|
|
62615
|
+
} else {
|
|
62616
|
+
this.unitX = (Math.abs(this.unitY) * this.unitX) / Math.abs(this.unitX);
|
|
62617
|
+
// Add the additional units in equal portions left and right
|
|
62618
|
+
offX = (w / this.unitX - (bbox[2] - bbox[0])) * 0.5;
|
|
62619
|
+
}
|
|
62620
|
+
} else {
|
|
62621
|
+
this.unitX = w / (bbox[2] - bbox[0]);
|
|
62622
|
+
this.unitY = h / (bbox[1] - bbox[3]);
|
|
62623
|
+
}
|
|
62624
|
+
this.origin.scrCoords = [1,
|
|
62625
|
+
-this.unitX * (bbox[0] - offX),
|
|
62626
|
+
this.unitY * (bbox[1] + offY)
|
|
62627
|
+
];
|
|
62628
|
+
this.canvasWidth = w;
|
|
62629
|
+
this.canvasHeight = h;
|
|
62840
62630
|
}
|
|
62841
62631
|
|
|
62842
62632
|
// Do nothing if the dimension did not change since being visible
|
|
@@ -62877,16 +62667,21 @@ jxg/* default */.A.extend(
|
|
|
62877
62667
|
}
|
|
62878
62668
|
|
|
62879
62669
|
this.resizeObserver = new ResizeObserver(function (entries) {
|
|
62880
|
-
var bb;
|
|
62670
|
+
// var bb;
|
|
62671
|
+
|
|
62672
|
+
// Take the last observed size
|
|
62673
|
+
that._lastContentRect = entries[entries.length - 1].contentRect;
|
|
62881
62674
|
if (!that._isResizing) {
|
|
62882
62675
|
that._isResizing = true;
|
|
62883
|
-
bb = entries[0].contentRect;
|
|
62676
|
+
// bb = entries[0].contentRect;
|
|
62884
62677
|
window.setTimeout(function () {
|
|
62678
|
+
var bb = that._lastContentRect;
|
|
62885
62679
|
try {
|
|
62886
62680
|
that.updateContainerDims(bb.width, bb.height);
|
|
62887
62681
|
} catch (e) {
|
|
62888
|
-
|
|
62889
|
-
|
|
62682
|
+
// JXG.debug(e); // Used to log errors during board.update()
|
|
62683
|
+
console.error(e);
|
|
62684
|
+
// that.stopResizeObserver();
|
|
62890
62685
|
} finally {
|
|
62891
62686
|
that._isResizing = false;
|
|
62892
62687
|
}
|
|
@@ -63919,7 +63714,7 @@ jxg/* default */.A.extend(
|
|
|
63919
63714
|
* @private
|
|
63920
63715
|
*/
|
|
63921
63716
|
_removeObj: function (object, saveMethod) {
|
|
63922
|
-
var el,
|
|
63717
|
+
var el, i, pos;
|
|
63923
63718
|
|
|
63924
63719
|
if (utils_type/* default */.A.isArray(object)) {
|
|
63925
63720
|
for (i = 0; i < object.length; i++) {
|
|
@@ -63937,6 +63732,16 @@ jxg/* default */.A.extend(
|
|
|
63937
63732
|
return this;
|
|
63938
63733
|
}
|
|
63939
63734
|
|
|
63735
|
+
// Already removed (e.g. reached again through a parent's childElements
|
|
63736
|
+
// or View3D.removeObject). Removing it twice used to splice a live element.
|
|
63737
|
+
if (object._pos === -1 && this.objects[object.id] !== object) {
|
|
63738
|
+
return this;
|
|
63739
|
+
}
|
|
63740
|
+
|
|
63741
|
+
if (object.is3D && utils_type/* default */.A.exists(object.view.objects[object.id])) {
|
|
63742
|
+
jxg/* default */.A.warn("board.removeObject() of 3D object " + object.id + ". Use view3d.removeObject() instead.");
|
|
63743
|
+
}
|
|
63744
|
+
|
|
63940
63745
|
try {
|
|
63941
63746
|
// remove all children.
|
|
63942
63747
|
for (el in object.childElements) {
|
|
@@ -63986,15 +63791,16 @@ jxg/* default */.A.extend(
|
|
|
63986
63791
|
}
|
|
63987
63792
|
|
|
63988
63793
|
// remove the object itself from our control structures
|
|
63989
|
-
if
|
|
63990
|
-
|
|
63794
|
+
// Trust _pos only if it still points at the object, and reset it
|
|
63795
|
+
// afterwards, so a stale index can never splice another element.
|
|
63796
|
+
pos = this.objectsList[object._pos] === object ? object._pos : this.objectsList.indexOf(object);
|
|
63797
|
+
if (pos > -1) {
|
|
63798
|
+
this.objectsList.splice(pos, 1);
|
|
63991
63799
|
// Quadratic complexity for reindexing the positions:
|
|
63992
|
-
for (i =
|
|
63993
|
-
|
|
63994
|
-
if (o._pos > -1) {
|
|
63995
|
-
o._pos--;
|
|
63996
|
-
}
|
|
63800
|
+
for (i = pos; i < this.objectsList.length; i++) {
|
|
63801
|
+
this.objectsList[i]._pos = i;
|
|
63997
63802
|
}
|
|
63803
|
+
object._pos = -1;
|
|
63998
63804
|
} else if (object.type !== constants/* default */.A.OBJECT_TYPE_TURTLE) {
|
|
63999
63805
|
jxg/* default */.A.debug(
|
|
64000
63806
|
'Board.removeObject: object ' + object.id + ' not found in list.'
|
|
@@ -67140,7 +66946,7 @@ jxg/* default */.A.SVGRenderer = function (container, dim) {
|
|
|
67140
66946
|
var id = this.uniqName('ClipFull'),
|
|
67141
66947
|
node1 = this.container.ownerDocument.createElementNS(this.svgNamespace, 'clipPath'),
|
|
67142
66948
|
node2 = this.container.ownerDocument.createElementNS(this.svgNamespace, 'rect'),
|
|
67143
|
-
style,
|
|
66949
|
+
style, r;
|
|
67144
66950
|
node1.setAttributeNS(null, 'id', id);
|
|
67145
66951
|
|
|
67146
66952
|
node2.setAttributeNS(null, 'x', 0);
|
|
@@ -67150,10 +66956,9 @@ jxg/* default */.A.SVGRenderer = function (container, dim) {
|
|
|
67150
66956
|
|
|
67151
66957
|
// Inherit border-radius
|
|
67152
66958
|
style = getComputedStyle(this.container);
|
|
67153
|
-
|
|
67154
|
-
|
|
67155
|
-
node2.setAttributeNS(null, '
|
|
67156
|
-
node2.setAttributeNS(null, 'ry', ry);
|
|
66959
|
+
r = (utils_type/* default */.A.exists(style['border-radius']) && style['border-radius'] !== '') ? parseFloat(style['border-radius']) : 0;
|
|
66960
|
+
node2.setAttributeNS(null, 'rx', r);
|
|
66961
|
+
node2.setAttributeNS(null, 'ry', r);
|
|
67157
66962
|
|
|
67158
66963
|
node1.appendChild(node2);
|
|
67159
66964
|
return node1;
|
|
@@ -67841,7 +67646,7 @@ jxg/* default */.A.extend(
|
|
|
67841
67646
|
|
|
67842
67647
|
// Already documented in JXG.AbstractRenderer
|
|
67843
67648
|
setLayer: function (el, level) {
|
|
67844
|
-
var node;
|
|
67649
|
+
var node, elNode;
|
|
67845
67650
|
if (!utils_type/* default */.A.exists(level)) {
|
|
67846
67651
|
level = 0;
|
|
67847
67652
|
} else if (level >= src_options/* default */.A.layer.numlayers) {
|
|
@@ -67849,8 +67654,16 @@ jxg/* default */.A.extend(
|
|
|
67849
67654
|
}
|
|
67850
67655
|
|
|
67851
67656
|
node = this.layer[level];
|
|
67657
|
+
// if ('moveBefore' in Element.prototype) {
|
|
67852
67658
|
if (utils_type/* default */.A.exists(node.moveBefore)) {
|
|
67853
|
-
node.moveBefore(el.rendNode, null);
|
|
67659
|
+
// node.moveBefore(el.rendNode, null);
|
|
67660
|
+
elNode = el.rendNode;
|
|
67661
|
+
if (elNode.isConnected && node.isConnected &&
|
|
67662
|
+
(elNode.ownerDocument === node.ownerDocument)) {
|
|
67663
|
+
node.moveBefore(elNode, null);
|
|
67664
|
+
} else {
|
|
67665
|
+
node.insertBefore(elNode, null);
|
|
67666
|
+
}
|
|
67854
67667
|
} else {
|
|
67855
67668
|
node.appendChild(el.rendNode);
|
|
67856
67669
|
}
|
|
@@ -68137,6 +67950,7 @@ jxg/* default */.A.extend(
|
|
|
68137
67950
|
i = 0;
|
|
68138
67951
|
while (i < len) {
|
|
68139
67952
|
if (el.points[i] === undefined) {
|
|
67953
|
+
i++;
|
|
68140
67954
|
continue;
|
|
68141
67955
|
}
|
|
68142
67956
|
scr = el.points[i].scrCoords;
|
|
@@ -70970,7 +70784,7 @@ jxg/* default */.A.extend(
|
|
|
70970
70784
|
* Set the gradient angle for linear color gradients.
|
|
70971
70785
|
*
|
|
70972
70786
|
* @private
|
|
70973
|
-
* @param {JXG.GeometryElement}
|
|
70787
|
+
* @param {JXG.GeometryElement} el An arbitrary JSXGraph element, preferably one with an area.
|
|
70974
70788
|
* @param {Number} radians angle value in radians. 0 is horizontal from left to right, Pi/4 is vertical from top to bottom.
|
|
70975
70789
|
*/
|
|
70976
70790
|
updateGradientAngle: function (el, radians) {
|
|
@@ -71026,7 +70840,7 @@ jxg/* default */.A.extend(
|
|
|
71026
70840
|
* Set circles for radial color gradients.
|
|
71027
70841
|
*
|
|
71028
70842
|
* @private
|
|
71029
|
-
* @param {
|
|
70843
|
+
* @param {JXG.GeometryElement} el An arbitrary JSXGraph element, preferably one with an area.
|
|
71030
70844
|
* @param {Number} cx Canvas value x1 (but value between 0 and 1)
|
|
71031
70845
|
* @param {Number} cy Canvas value y1 (but value between 0 and 1)
|
|
71032
70846
|
* @param {Number} r Canvas value r1 (but value between 0 and 1)
|
|
@@ -71039,19 +70853,20 @@ jxg/* default */.A.extend(
|
|
|
71039
70853
|
c1, c2,
|
|
71040
70854
|
cxs, cys, rs,
|
|
71041
70855
|
fxs, fys, frs,
|
|
71042
|
-
dx, dy;
|
|
70856
|
+
dx, dy, d;
|
|
71043
70857
|
|
|
71044
70858
|
c1 = new base_coords/* default */.A(constants/* default */.A.COORDS_BY_USER, [bb[0], bb[1]], el.board);
|
|
71045
70859
|
c2 = new base_coords/* default */.A(constants/* default */.A.COORDS_BY_USER, [bb[2], bb[3]], el.board);
|
|
71046
70860
|
dx = c2.scrCoords[1] - c1.scrCoords[1];
|
|
71047
70861
|
dy = c1.scrCoords[2] - c2.scrCoords[2];
|
|
71048
|
-
|
|
71049
70862
|
cxs = c1.scrCoords[1] + dx * cx;
|
|
71050
70863
|
cys = c2.scrCoords[2] + dy * cy;
|
|
71051
70864
|
fxs = c1.scrCoords[1] + dx * fx;
|
|
71052
70865
|
fys = c2.scrCoords[2] + dy * fy;
|
|
71053
|
-
|
|
71054
|
-
|
|
70866
|
+
|
|
70867
|
+
d = Math.abs(dx) + Math.abs(dy);
|
|
70868
|
+
rs = Math.max(r * d * 0.5, 0);
|
|
70869
|
+
frs = Math.max(fr * d * 0.5, 0);
|
|
71055
70870
|
|
|
71056
70871
|
return this.context.createRadialGradient(fxs, fys, frs, cxs, cys, rs);
|
|
71057
70872
|
},
|
|
@@ -80392,13 +80207,30 @@ jxg/* default */.A.registerElement("circle", jxg/* default */.A.createCircle);
|
|
|
80392
80207
|
* @jsxgraphsignature Ellipse
|
|
80393
80208
|
* Parent elements can be two elements either of type {@link JXG.Point} or array of
|
|
80394
80209
|
* numbers describing the coordinates of a point.
|
|
80395
|
-
* The third parameter is a number/function which defines the length of the major axis
|
|
80210
|
+
* The third parameter is a number/function which defines the length of the major axis.
|
|
80396
80211
|
* @param {PointLike} point1
|
|
80397
80212
|
* @param {PointLike} point2
|
|
80398
80213
|
* @param {NumberLike} number
|
|
80399
80214
|
* @param {Number} [start=0] parameter of the curve start, default: 0.
|
|
80400
80215
|
* @param {Number} [end=2π] parameter for the curve end, default: 2π.
|
|
80401
80216
|
*
|
|
80217
|
+
* @example
|
|
80218
|
+
* var A = board.create('point', [1,0]);
|
|
80219
|
+
* var B = board.create('point', [-1,0]);
|
|
80220
|
+
* var el = board.create('ellipse',[A, B, 4]);
|
|
80221
|
+
*
|
|
80222
|
+
* </pre><div id="JXG7898d447-94dc-4dce-9ad3-60e3387be9f3" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
80223
|
+
* <script type="text/javascript">
|
|
80224
|
+
* (function() {
|
|
80225
|
+
* var board = JXG.JSXGraph.initBoard('JXG7898d447-94dc-4dce-9ad3-60e3387be9f3',
|
|
80226
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
80227
|
+
* var A = board.create('point', [1,0]);
|
|
80228
|
+
* var B = board.create('point', [-1,0]);
|
|
80229
|
+
* var el = board.create('ellipse',[A,B, 4]);
|
|
80230
|
+
* })();
|
|
80231
|
+
*
|
|
80232
|
+
* </script><pre>
|
|
80233
|
+
*
|
|
80402
80234
|
*/
|
|
80403
80235
|
jxg/* default */.A.createEllipse = function (board, parents, attributes) {
|
|
80404
80236
|
var polarForm,
|
|
@@ -80670,6 +80502,23 @@ jxg/* default */.A.createEllipse = function (board, parents, attributes) {
|
|
|
80670
80502
|
* @param {NumberLike} number
|
|
80671
80503
|
* @param {Number} [start=-π] parameter of the curve start, default: -π.
|
|
80672
80504
|
* @param {Number} [end=π] parameter for the curve end, default: π.
|
|
80505
|
+
* @example
|
|
80506
|
+
* var A = board.create('point', [1,0]);
|
|
80507
|
+
* var B = board.create('point', [-1,0]);
|
|
80508
|
+
* var el = board.create('hyperbola',[A, B, 1]);
|
|
80509
|
+
*
|
|
80510
|
+
* </pre><div id="JXGa4c0068b-41bc-4be4-b485-d0d0c7f2e10b" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
80511
|
+
* <script type="text/javascript">
|
|
80512
|
+
* (function() {
|
|
80513
|
+
* var board = JXG.JSXGraph.initBoard('JXGa4c0068b-41bc-4be4-b485-d0d0c7f2e10b',
|
|
80514
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
80515
|
+
* var A = board.create('point', [1,0]);
|
|
80516
|
+
* var B = board.create('point', [-1,0]);
|
|
80517
|
+
* var el = board.create('hyperbola',[A,B, 1]);
|
|
80518
|
+
*
|
|
80519
|
+
* })();
|
|
80520
|
+
*
|
|
80521
|
+
* </script><pre>
|
|
80673
80522
|
*/
|
|
80674
80523
|
jxg/* default */.A.createHyperbola = function (board, parents, attributes) {
|
|
80675
80524
|
var polarForm,
|
|
@@ -87894,11 +87743,11 @@ jxg/* default */.A.createSector = function (board, parents, attributes) {
|
|
|
87894
87743
|
s = el.line1.point1.coords;
|
|
87895
87744
|
} else if (
|
|
87896
87745
|
el.line1.point2.Dist(el.line2.point1) < eps ||
|
|
87897
|
-
el.line1.point2.Dist(el.line2.
|
|
87746
|
+
el.line1.point2.Dist(el.line2.point2) < eps
|
|
87898
87747
|
) {
|
|
87899
87748
|
s = el.line1.point2.coords;
|
|
87900
87749
|
} else {
|
|
87901
|
-
|
|
87750
|
+
jxg/* default */.A.warn(
|
|
87902
87751
|
"JSXGraph warning: Can't create Sector from parallel lines with no common defining point."
|
|
87903
87752
|
);
|
|
87904
87753
|
}
|
|
@@ -87979,10 +87828,13 @@ jxg/* default */.A.createSector = function (board, parents, attributes) {
|
|
|
87979
87828
|
B = l1.point1.coords.usrCoords;
|
|
87980
87829
|
} else if (
|
|
87981
87830
|
l1.point2.Dist(l2.point1) < eps ||
|
|
87982
|
-
l1.point2.Dist(l2.
|
|
87831
|
+
l1.point2.Dist(l2.point2) < eps
|
|
87983
87832
|
) {
|
|
87984
87833
|
B = l1.point2.coords.usrCoords;
|
|
87985
87834
|
} else {
|
|
87835
|
+
jxg/* default */.A.warn(
|
|
87836
|
+
"JSXGraph warning: sector from parallel lines with no common defining point."
|
|
87837
|
+
);
|
|
87986
87838
|
}
|
|
87987
87839
|
}
|
|
87988
87840
|
|
|
@@ -111954,7 +111806,7 @@ jxg/* default */.A.extend(
|
|
|
111954
111806
|
},
|
|
111955
111807
|
|
|
111956
111808
|
removeObject: function (object, saveMethod) {
|
|
111957
|
-
var i, el, le, o, fst, face;
|
|
111809
|
+
var i, el, le, o, fst, face, gone, list;
|
|
111958
111810
|
|
|
111959
111811
|
// this.board.removeObject(object, saveMethod);
|
|
111960
111812
|
if (utils_type/* default */.A.isArray(object)) {
|
|
@@ -111966,8 +111818,8 @@ jxg/* default */.A.extend(
|
|
|
111966
111818
|
|
|
111967
111819
|
object = this.select(object);
|
|
111968
111820
|
|
|
111969
|
-
//
|
|
111970
|
-
//
|
|
111821
|
+
// If the object which is about to be removed unknown or a string, do nothing.
|
|
111822
|
+
// it is a string if a string was given and could not be resolved to an element.
|
|
111971
111823
|
if (!utils_type/* default */.A.exists(object) || utils_type/* default */.A.isString(object)) {
|
|
111972
111824
|
return this;
|
|
111973
111825
|
}
|
|
@@ -111976,38 +111828,46 @@ jxg/* default */.A.extend(
|
|
|
111976
111828
|
// Remove all children.
|
|
111977
111829
|
for (el in object.childElements) {
|
|
111978
111830
|
if (object.childElements.hasOwnProperty(el)) {
|
|
111979
|
-
|
|
111831
|
+
o = object.childElements[el];
|
|
111832
|
+
if (!(object.is3D && object.element2D === o)) {
|
|
111833
|
+
this.removeObject(o);
|
|
111834
|
+
}
|
|
111980
111835
|
}
|
|
111981
111836
|
}
|
|
111982
111837
|
if (object.type === constants/* default */.A.OBJECT_TYPE_POLYHEDRON3D) {
|
|
111983
111838
|
// Special treatment for polyhedron3d.
|
|
111984
111839
|
// With this we can avoid the time consuming addChild() calls.
|
|
111840
|
+
// Mark faces and their 2D elements, then compact objectsList once.
|
|
111841
|
+
// Splicing face by face with stale _pos removed unrelated elements.
|
|
111842
|
+
gone = {};
|
|
111985
111843
|
le = object.faces.length;
|
|
111986
|
-
if (le > 0) {
|
|
111987
|
-
fst = object.faces[0]._pos;
|
|
111988
|
-
fst = (object.faces[0].element2D._pos < fst) ? object.faces[0].element2D._pos : fst;
|
|
111989
|
-
}
|
|
111990
111844
|
for (i = 0; i < le; i++) {
|
|
111991
111845
|
face = object.faces[i];
|
|
111992
111846
|
delete this.objects[face.id];
|
|
111993
111847
|
|
|
111994
|
-
// this.board.removeObject(face.element2D, saveMethod);
|
|
111995
111848
|
delete this.board.objects[face.element2D.id];
|
|
111996
111849
|
delete this.board.elementsByName[face.element2D.name];
|
|
111997
111850
|
face.element2D.remove();
|
|
111998
|
-
|
|
111851
|
+
gone[face.element2D.id] = true;
|
|
111852
|
+
face.element2D._pos = -1;
|
|
111999
111853
|
|
|
112000
111854
|
delete this.board.objects[face.id];
|
|
112001
111855
|
delete this.board.elementsByName[face.name];
|
|
112002
111856
|
face.remove();
|
|
112003
|
-
|
|
111857
|
+
gone[face.id] = true;
|
|
111858
|
+
face._pos = -1;
|
|
112004
111859
|
}
|
|
112005
|
-
|
|
112006
|
-
|
|
112007
|
-
for (i =
|
|
112008
|
-
o =
|
|
112009
|
-
if (o.
|
|
111860
|
+
list = this.board.objectsList;
|
|
111861
|
+
fst = 0;
|
|
111862
|
+
for (i = 0; i < list.length; i++) {
|
|
111863
|
+
o = list[i];
|
|
111864
|
+
if (!gone.hasOwnProperty(o.id)) {
|
|
111865
|
+
o._pos = fst;
|
|
111866
|
+
list[fst] = o;
|
|
111867
|
+
fst++;
|
|
111868
|
+
}
|
|
112010
111869
|
}
|
|
111870
|
+
list.length = fst;
|
|
112011
111871
|
object.faces = [];
|
|
112012
111872
|
}
|
|
112013
111873
|
|
|
@@ -115676,8 +115536,6 @@ jxg/* default */.A.extend(
|
|
|
115676
115536
|
}
|
|
115677
115537
|
},
|
|
115678
115538
|
|
|
115679
|
-
|
|
115680
|
-
|
|
115681
115539
|
/**
|
|
115682
115540
|
* Starts an animated point movement towards the given coordinates `where`.
|
|
115683
115541
|
* The animation is done after `time` milliseconds.
|
|
@@ -115899,9 +115757,6 @@ jxg/* default */.A.extend(
|
|
|
115899
115757
|
});
|
|
115900
115758
|
},
|
|
115901
115759
|
|
|
115902
|
-
|
|
115903
|
-
|
|
115904
|
-
|
|
115905
115760
|
// Not yet working
|
|
115906
115761
|
__evt__update3D: function (oc) { }
|
|
115907
115762
|
}
|
|
@@ -117519,8 +117374,8 @@ jxg/* default */.A.createLine3D = function (board, parents, attributes) {
|
|
|
117519
117374
|
* @private
|
|
117520
117375
|
*/
|
|
117521
117376
|
el.endpoints = endpoints;
|
|
117522
|
-
el.addChild(endpoints[0]);
|
|
117523
|
-
el.addChild(endpoints[1]);
|
|
117377
|
+
// el.addChild(endpoints[0]); // Is done below
|
|
117378
|
+
// el.addChild(endpoints[1]);
|
|
117524
117379
|
// el.setParents(endpoints);
|
|
117525
117380
|
el.addParents([point1, point2]);
|
|
117526
117381
|
|
|
@@ -118867,18 +118722,24 @@ jxg/* default */.A.createIntersectionLine3D = function (board, parents, attribut
|
|
|
118867
118722
|
var view = parents[0],
|
|
118868
118723
|
el1 = parents[1],
|
|
118869
118724
|
el2 = parents[2],
|
|
118870
|
-
ixnLine, i,//
|
|
118725
|
+
ixnLine, i,// f,
|
|
118871
118726
|
attr = utils_type/* default */.A.copyAttributes(attributes, board.options, 'intersectionline3d'),
|
|
118872
118727
|
pts = [];
|
|
118873
118728
|
|
|
118874
|
-
// func = Geometry.intersectionFunction3D(view, el1, el2);
|
|
118729
|
+
// var func = Geometry.intersectionFunction3D(view, el1, el2);
|
|
118875
118730
|
for (i = 0; i < 2; i++) {
|
|
118876
|
-
|
|
118877
|
-
|
|
118878
|
-
|
|
118879
|
-
|
|
118880
|
-
|
|
118881
|
-
|
|
118731
|
+
try {
|
|
118732
|
+
pts[i] = view.create('point3d', [
|
|
118733
|
+
// Use closures
|
|
118734
|
+
(function (ii) {
|
|
118735
|
+
return function () { return geometry/* default */.A.intersectionFunction3D(view, el1, el2)[ii]; };
|
|
118736
|
+
})(i)
|
|
118737
|
+
], attr['point' + (i + 1)]);
|
|
118738
|
+
} catch (err) {
|
|
118739
|
+
throw new Error(
|
|
118740
|
+
"JSXGraph: Can't create IntersectionLine3D from the intersection of these types. Please check the intersecting elements."
|
|
118741
|
+
);
|
|
118742
|
+
}
|
|
118882
118743
|
}
|
|
118883
118744
|
ixnLine = view.create('line3d', pts, attr);
|
|
118884
118745
|
|
|
@@ -121238,28 +121099,52 @@ jxg/* default */.A.extend(
|
|
|
121238
121099
|
jxg/* default */.A.Sphere3D.prototype,
|
|
121239
121100
|
/** @lends JXG.Sphere3D.prototype */ {
|
|
121240
121101
|
|
|
121102
|
+
/**
|
|
121103
|
+
* Returns the x-coordinate of the sphere given as parametric surface for parameters `u` and `v`.
|
|
121104
|
+
* @param {Number} u
|
|
121105
|
+
* @param {Number} v
|
|
121106
|
+
* @returns {Number} x-coordinate
|
|
121107
|
+
*/
|
|
121241
121108
|
X: function(u, v) {
|
|
121242
121109
|
var r = this.Radius();
|
|
121243
121110
|
return r * Math.sin(u) * Math.cos(v);
|
|
121244
121111
|
},
|
|
121245
121112
|
|
|
121113
|
+
/**
|
|
121114
|
+
* Returns the y-coordinate of the sphere given as parametric surface for parameters `u` and `v`.
|
|
121115
|
+
* @param {Number} u
|
|
121116
|
+
* @param {Number} v
|
|
121117
|
+
* @returns {Number} y-coordinate
|
|
121118
|
+
*/
|
|
121246
121119
|
Y: function(u, v) {
|
|
121247
121120
|
var r = this.Radius();
|
|
121248
121121
|
return r * Math.sin(u) * Math.sin(v);
|
|
121249
121122
|
},
|
|
121250
121123
|
|
|
121124
|
+
/**
|
|
121125
|
+
* Returns the z-coordinate of the sphere given as parametric surface for parameters `u` and `v`.
|
|
121126
|
+
* @param {Number} u
|
|
121127
|
+
* @param {Number} v
|
|
121128
|
+
* @returns {Number} z-coordinate
|
|
121129
|
+
*/
|
|
121251
121130
|
Z: function(u, v) {
|
|
121252
121131
|
var r = this.Radius();
|
|
121253
121132
|
return r * Math.cos(u);
|
|
121254
121133
|
},
|
|
121255
121134
|
|
|
121135
|
+
/**
|
|
121136
|
+
* The parameter range of `u`
|
|
121137
|
+
* @type {Array}
|
|
121138
|
+
*/
|
|
121256
121139
|
range_u: [0, 2 * Math.PI],
|
|
121140
|
+
|
|
121141
|
+
/**
|
|
121142
|
+
* The parameter range of `v`
|
|
121143
|
+
* @type {Array}
|
|
121144
|
+
*/
|
|
121257
121145
|
range_v: [0, Math.PI],
|
|
121258
121146
|
|
|
121259
121147
|
update: function () {
|
|
121260
|
-
if (this.projectionType !== this.view.projectionType) {
|
|
121261
|
-
this.rebuildProjection();
|
|
121262
|
-
}
|
|
121263
121148
|
return this;
|
|
121264
121149
|
},
|
|
121265
121150
|
|
|
@@ -121307,34 +121192,55 @@ jxg/* default */.A.extend(
|
|
|
121307
121192
|
return NaN;
|
|
121308
121193
|
},
|
|
121309
121194
|
|
|
121310
|
-
|
|
121311
|
-
|
|
121312
|
-
|
|
121313
|
-
|
|
121314
|
-
|
|
121315
|
-
|
|
121316
|
-
|
|
121317
|
-
|
|
121318
|
-
|
|
121319
|
-
|
|
121320
|
-
|
|
121321
|
-
|
|
121322
|
-
|
|
121195
|
+
/**
|
|
121196
|
+
* The central projection of a sphere is an ellipse. The front and back
|
|
121197
|
+
* points of the sphere -- that is, the points closest to and furthest
|
|
121198
|
+
* from the screen -- project to the foci of the ellipse.
|
|
121199
|
+
*
|
|
121200
|
+
* To see this, look at the cone tangent to the sphere whose tip is at
|
|
121201
|
+
* the camera. The image of the sphere is the ellipse where this cone
|
|
121202
|
+
* intersects the screen. By acting on the sphere with scalings centered
|
|
121203
|
+
* on the camera, you can send it to either of the Dandelin spheres that
|
|
121204
|
+
* touch the screen at the foci of the image ellipse.
|
|
121205
|
+
*
|
|
121206
|
+
* This factory method produces two functions, `focusFn(-1)` and
|
|
121207
|
+
* `focusFn(1)`, that evaluate to the projections of the front and back
|
|
121208
|
+
* points of the sphere, respectively.
|
|
121209
|
+
*
|
|
121210
|
+
* The parallel projection of a sphere is a cicle. We use an ellipse curve
|
|
121211
|
+
* for this projection, too. The two focii now coincide with the center of
|
|
121212
|
+
* the sphere. The 2D radius point is defined by the projection of the center
|
|
121213
|
+
* and the projected radius.
|
|
121214
|
+
* @param {Number} sgn Expecst -1 or 1 for the two focus points
|
|
121215
|
+
* @returns {Array} 2D coordinates of the projected focus point
|
|
121216
|
+
*
|
|
121217
|
+
*/
|
|
121323
121218
|
focusFn: function (sgn) {
|
|
121324
121219
|
var that = this;
|
|
121325
121220
|
|
|
121326
121221
|
return function () {
|
|
121327
|
-
var camDir
|
|
121222
|
+
var camDir,
|
|
121223
|
+
v = (that.view.projectionType === 'central') ? 1 : 0,
|
|
121328
121224
|
r = that.Radius();
|
|
121329
121225
|
|
|
121226
|
+
// Parallel projection: v === 0, the two focii coincide with the center
|
|
121227
|
+
// Central projection: v === 1
|
|
121228
|
+
camDir = (v === 0) ? [0, 0, 0, 0] : that.view.boxToCam[3];
|
|
121229
|
+
|
|
121330
121230
|
return that.view.project3DTo2D([
|
|
121331
|
-
that.center.X() + sgn * r * camDir[1],
|
|
121332
|
-
that.center.Y() + sgn * r * camDir[2],
|
|
121333
|
-
that.center.Z() + sgn * r * camDir[3]
|
|
121231
|
+
that.center.X() + v * sgn * r * camDir[1],
|
|
121232
|
+
that.center.Y() + v * sgn * r * camDir[2],
|
|
121233
|
+
that.center.Z() + v * sgn * r * camDir[3]
|
|
121334
121234
|
]).slice(1, 3);
|
|
121335
121235
|
};
|
|
121336
121236
|
},
|
|
121337
121237
|
|
|
121238
|
+
// Replace our 2D representation with a new one that's consistent with
|
|
121239
|
+
// the view's current projection type
|
|
121240
|
+
/**
|
|
121241
|
+
*
|
|
121242
|
+
* @returns {Array} 2D coordinates of the projected 3rd point that is on the ellipse.
|
|
121243
|
+
*/
|
|
121338
121244
|
innerVertexFn: function () {
|
|
121339
121245
|
var that = this;
|
|
121340
121246
|
|
|
@@ -121344,6 +121250,7 @@ jxg/* default */.A.extend(
|
|
|
121344
121250
|
distOffAxis = math/* default */.A.hypot(p[0], p[1]),
|
|
121345
121251
|
cam = view.boxToCam,
|
|
121346
121252
|
r = that.Radius(),
|
|
121253
|
+
c, bs,
|
|
121347
121254
|
angleOffAxis = Math.atan(-distOffAxis / p[2]),
|
|
121348
121255
|
steepness = Math.acos(r / math/* default */.A.norm(p)),
|
|
121349
121256
|
lean = angleOffAxis + steepness,
|
|
@@ -121351,6 +121258,22 @@ jxg/* default */.A.extend(
|
|
|
121351
121258
|
sin_lean = Math.sin(lean),
|
|
121352
121259
|
inward;
|
|
121353
121260
|
|
|
121261
|
+
// Do parallel projection
|
|
121262
|
+
if (that.view.projectionType !== 'central') {
|
|
121263
|
+
bs = view.bbox3D[0][1] - view.bbox3D[0][0];
|
|
121264
|
+
r *= view.size[0] / bs;
|
|
121265
|
+
|
|
121266
|
+
c = view.project3DTo2D([
|
|
121267
|
+
that.center.X(),
|
|
121268
|
+
that.center.Y(),
|
|
121269
|
+
that.center.Z()
|
|
121270
|
+
]);
|
|
121271
|
+
c[1] += r;
|
|
121272
|
+
|
|
121273
|
+
return c;
|
|
121274
|
+
}
|
|
121275
|
+
|
|
121276
|
+
// Do central projection
|
|
121354
121277
|
if (distOffAxis > 1e-8) {
|
|
121355
121278
|
// if the center of the sphere isn't too close to the camera
|
|
121356
121279
|
// axis, find the direction in plane of the screen that
|
|
@@ -121375,7 +121298,15 @@ jxg/* default */.A.extend(
|
|
|
121375
121298
|
};
|
|
121376
121299
|
},
|
|
121377
121300
|
|
|
121378
|
-
|
|
121301
|
+
/**
|
|
121302
|
+
* Create 2D helper points and an ellipse to visualize the `sphere3d`.
|
|
121303
|
+
* Handles central and parallel projection simultaneously.
|
|
121304
|
+
*
|
|
121305
|
+
* This is done only once at creation time.
|
|
121306
|
+
*
|
|
121307
|
+
* @param {object} attr Attributes for the sphere objects
|
|
121308
|
+
*/
|
|
121309
|
+
buildProjection: function (attr) {
|
|
121379
121310
|
var view = this.view,
|
|
121380
121311
|
auxStyle = { visible: false, withLabel: false },
|
|
121381
121312
|
frontFocus = view.create('point', this.focusFn(-1), auxStyle),
|
|
@@ -121384,53 +121315,6 @@ jxg/* default */.A.extend(
|
|
|
121384
121315
|
|
|
121385
121316
|
this.aux2D = [frontFocus, backFocus, innerVertex];
|
|
121386
121317
|
this.element2D = view.create('ellipse', this.aux2D, attr === undefined ? this.visProp : attr);
|
|
121387
|
-
},
|
|
121388
|
-
|
|
121389
|
-
buildParallelProjection: function (attr) {
|
|
121390
|
-
// The parallel projection of a sphere is a circle
|
|
121391
|
-
var that = this,
|
|
121392
|
-
// center2d = function () {
|
|
121393
|
-
// var c3d = [1, that.center.X(), that.center.Y(), that.center.Z()];
|
|
121394
|
-
// return that.view.project3DTo2D(c3d);
|
|
121395
|
-
// },
|
|
121396
|
-
radius2d = function () {
|
|
121397
|
-
var boxSize = that.view.bbox3D[0][1] - that.view.bbox3D[0][0];
|
|
121398
|
-
return that.Radius() * that.view.size[0] / boxSize;
|
|
121399
|
-
};
|
|
121400
|
-
|
|
121401
|
-
this.aux2D = [];
|
|
121402
|
-
this.element2D = this.view.create(
|
|
121403
|
-
'circle',
|
|
121404
|
-
// [center2d, radius2d],
|
|
121405
|
-
[that.center.element2D, radius2d],
|
|
121406
|
-
attr === undefined ? this.visProp : attr
|
|
121407
|
-
);
|
|
121408
|
-
},
|
|
121409
|
-
|
|
121410
|
-
// replace our 2D representation with a new one that's consistent with
|
|
121411
|
-
// the view's current projection type
|
|
121412
|
-
rebuildProjection: function (attr) {
|
|
121413
|
-
var i;
|
|
121414
|
-
|
|
121415
|
-
// remove the old 2D representation from the scene tree
|
|
121416
|
-
if (this.element2D) {
|
|
121417
|
-
this.view.board.removeObject(this.element2D);
|
|
121418
|
-
for (i in this.aux2D) {
|
|
121419
|
-
if (this.aux2D.hasOwnProperty(i)) {
|
|
121420
|
-
this.view.board.removeObject(this.aux2D[i]);
|
|
121421
|
-
}
|
|
121422
|
-
}
|
|
121423
|
-
}
|
|
121424
|
-
|
|
121425
|
-
// build a new 2D representation. the representation is stored in
|
|
121426
|
-
// `this.element2D`, and any auxiliary elements are stored in
|
|
121427
|
-
// `this.aux2D`
|
|
121428
|
-
this.projectionType = this.view.projectionType;
|
|
121429
|
-
if (this.projectionType === 'central') {
|
|
121430
|
-
this.buildCentralProjection(attr);
|
|
121431
|
-
} else {
|
|
121432
|
-
this.buildParallelProjection(attr);
|
|
121433
|
-
}
|
|
121434
121318
|
|
|
121435
121319
|
// attach the new 2D representation to the scene tree
|
|
121436
121320
|
this.addChild(this.element2D);
|
|
@@ -121724,7 +121608,7 @@ jxg/* default */.A.createSphere3D = function (board, parents, attributes) {
|
|
|
121724
121608
|
// to the correct initial state
|
|
121725
121609
|
// Here, element2D is created.
|
|
121726
121610
|
attr = el.setAttr2D(attr);
|
|
121727
|
-
el.
|
|
121611
|
+
el.buildProjection(attr);
|
|
121728
121612
|
|
|
121729
121613
|
el.element2D.prepareUpdate().update();
|
|
121730
121614
|
if (!board.isSuspendedUpdate) {
|