jsxgraph 1.4.4 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +24 -0
  2. package/build/Readme.md +17 -0
  3. package/build/bin/jsxcompressor.js +1 -0
  4. package/build/bin/jsxgraphcore-min.js +7 -0
  5. package/build/bin/jsxgraphcore.js +83017 -0
  6. package/build/bin/jsxgraphcore.min.js +67 -0
  7. package/build/compressor.build.json +14 -0
  8. package/build/compressor.deps.js +8 -0
  9. package/build/core-amd.build.json +14 -0
  10. package/build/core-amd.deps.js +81 -0
  11. package/build/core.build.json +14 -0
  12. package/build/core.deps.js +102 -0
  13. package/build/plot.build.json +15 -0
  14. package/distrib/README.md +24 -0
  15. package/distrib/geogebra.min.js +1 -1
  16. package/distrib/geonext.min.js +1 -1
  17. package/distrib/index.d.ts +28 -7
  18. package/distrib/intergeo.min.js +1 -1
  19. package/distrib/jsxgraph.css +6 -0
  20. package/distrib/jsxgraphcore.js +3 -3
  21. package/distrib/jsxgraphsrc.js +3558 -1857
  22. package/distrib/sketch.min.js +1 -1
  23. package/package.json +1 -1
  24. package/src/3d/box3d.js +43 -38
  25. package/src/3d/curve3d.js +157 -53
  26. package/src/3d/element3d.js +84 -0
  27. package/src/3d/linspace3d.js +427 -146
  28. package/src/3d/point3d.js +360 -123
  29. package/src/3d/surface3d.js +140 -42
  30. package/src/3d/view3d.js +319 -164
  31. package/src/base/board.js +163 -78
  32. package/src/base/constants.js +8 -1
  33. package/src/base/curve.js +51 -9
  34. package/src/base/polygon.js +111 -69
  35. package/src/base/text.js +122 -19
  36. package/src/base/ticks.js +12 -3
  37. package/src/element/button.js +7 -3
  38. package/src/element/checkbox.js +8 -4
  39. package/src/element/composition.js +7 -1
  40. package/src/element/conic.js +2 -2
  41. package/src/element/input.js +9 -5
  42. package/src/jsxgraph.js +4 -1
  43. package/src/loadjsxgraph.js +13 -8
  44. package/src/math/clip.js +34 -134
  45. package/src/math/geometry.js +204 -3
  46. package/src/math/math.js +1 -2
  47. package/src/math/nlp.js +865 -774
  48. package/src/options.js +185 -12
  49. package/src/options3d.js +24 -7
  50. package/src/parser/jessiecode.js +9 -3
  51. package/src/renderer/abstract.js +26 -15
  52. package/src/renderer/canvas.js +2 -2
  53. package/src/renderer/svg.js +15 -2
  54. package/src/utils/env.js +36 -53
  55. package/src/utils/type.js +75 -2
  56. package/src/3d/threed.js +0 -38
@@ -28,10 +28,100 @@
28
28
  */
29
29
  /*global JXG:true, define: true*/
30
30
 
31
- define(['jxg', 'utils/type', '3d/view3d'
32
- ], function (JXG, Type, ThreeD) {
31
+ define(['jxg', 'base/constants', 'utils/type'], function (JXG, Const, Type) {
33
32
  "use strict";
34
33
 
34
+ /**
35
+ * Constructor for 3D surfaces.
36
+ * @class Creates a new 3D surface object. Do not use this constructor to create a 3D surface. Use {@link JXG.Board#create} with type {@link Surface3D} instead.
37
+ *
38
+ * @augments JXG.GeometryElement3D
39
+ * @augments JXG.GeometryElement
40
+ * @param {View3D} view
41
+ * @param {Function} F
42
+ * @param {Function} X
43
+ * @param {Function} Y
44
+ * @param {Function} Z
45
+ * @param {Array} range_u
46
+ * @param {Array} range_v
47
+ * @param {Object} attributes
48
+ * @see JXG.Board#generateName
49
+ */
50
+ JXG.Surface3D = function (view, F, X, Y, Z, range_u, range_v, attributes) {
51
+ this.constructor(view.board, attributes, Const.OBJECT_TYPE_SURFACE3D, Const.OBJECT_CLASS_3D);
52
+ this.constructor3D(view, 'surface3d');
53
+
54
+ this.id = this.view.board.setId(this, 'S3D');
55
+ this.board.finalizeAdding(this);
56
+
57
+ this.F = F;
58
+
59
+ /**
60
+ * Function which maps (u, v) to x; i.e. it defines the x-coordinate of the surface
61
+ * @function
62
+ * @returns Number
63
+ */
64
+ this.X = X;
65
+
66
+ /**
67
+ * Function which maps (u, v) to y; i.e. it defines the y-coordinate of the surface
68
+ * @function
69
+ * @returns Number
70
+ */
71
+ this.Y = Y;
72
+
73
+ /**
74
+ * Function which maps (u, v) to z; i.e. it defines the x-coordinate of the surface
75
+ * @function
76
+ * @returns Number
77
+ */
78
+ this.Z = Z;
79
+
80
+ if (this.F !== null) {
81
+ this.X = function(u, v) { return this.F(u, v)[0]; };
82
+ this.Y = function(u, v) { return this.F(u, v)[1]; };
83
+ this.Z = function(u, v) { return this.F(u, v)[2]; };
84
+ }
85
+
86
+ this.range_u = range_u;
87
+ this.range_v = range_v;
88
+
89
+ this.methodMap = Type.deepCopy(this.methodMap, {
90
+ // TODO
91
+ });
92
+ };
93
+ JXG.Surface3D.prototype = new JXG.GeometryElement();
94
+ Type.copyPrototypeMethods(JXG.Surface3D, JXG.GeometryElement3D, 'constructor3D');
95
+
96
+ JXG.extend(JXG.Surface3D.prototype, /** @lends JXG.Surface3D.prototype */ {
97
+
98
+ updateDataArray: function () {
99
+ var steps_u = Type.evaluate(this.visProp.stepsu),
100
+ steps_v = Type.evaluate(this.visProp.stepsv),
101
+ r_u = Type.evaluate(this.range_u),
102
+ r_v = Type.evaluate(this.range_v),
103
+ func, res;
104
+
105
+ if (this.F !== null) {
106
+ func = this.F;
107
+ } else {
108
+ func = [this.X, this.Y, this.Z];
109
+ }
110
+ res = this.view.getMesh(func,
111
+ r_u.concat([steps_u]),
112
+ r_v.concat([steps_v]));
113
+
114
+ return {'X': res[0], 'Y': res[1]};
115
+ },
116
+
117
+ update: function () { return this; },
118
+
119
+ updateRenderer: function () {
120
+ this.needsUpdate = false;
121
+ return this;
122
+ }
123
+
124
+ });
35
125
 
36
126
  /**
37
127
  * @class This element creates a 3D parametric surface.
@@ -44,10 +134,13 @@ define(['jxg', 'utils/type', '3d/view3d'
44
134
  * @constructor
45
135
  * @type Object
46
136
  * @throws {Exception} If the element cannot be constructed with the given parent objects an exception is thrown.
47
- * @param {Function_Function_Function_Array_Array} F<sub>X</sub>,F<sub>Y</sub>,F<sub>Z</sub>,rangeX,rangeY
48
- * F<sub>X</sub>(u,v), F<sub>Y</sub>(u,v), F<sub>Z</sub>(u,v) are functions returning a number, rangeU is the array containing
49
- * lower and upper bound for the range of parameter u, rangeV is the array containing
50
- * lower and upper bound for the range of parameter v. rangeU and rangeV may also be functions returning an array of length two.
137
+ *
138
+ * @param {Function_Function_Function_Array,Function_Array,Function} F<sub>X</sub>,F<sub>Y</sub>,F<sub>Z</sub>,rangeU,rangeV F<sub>X</sub>(u,v), F<sub>Y</sub>(u,v), F<sub>Z</sub>(u,v)
139
+ * are functions returning a number, rangeU is the array containing lower and upper bound for the range of parameter u, rangeV is the array containing lower and
140
+ * upper bound for the range of parameter v. rangeU and rangeV may also be functions returning an array of length two.
141
+ * @param {Function_Array,Function_Array,Function} F,rangeU,rangeV Alternatively: F<sub>[X,Y,Z]</sub>(u,v)
142
+ * a function returning an array [x,y,z] of numbers, rangeU and rangeV as above.
143
+ *
51
144
  * @example
52
145
  * var view = board.create('view3d',
53
146
  * [[-6, -3], [8, 8],
@@ -72,8 +165,8 @@ define(['jxg', 'utils/type', '3d/view3d'
72
165
  * var board = JXG.JSXGraph.initBoard('JXG52da0ecc-1ba9-4d41-850c-36e5120025a5',
73
166
  * {boundingbox: [-8, 8, 8,-8], axis: false, showcopyright: false, shownavigation: false});
74
167
  * var view = board.create('view3d',
75
- * [[-6, -3], [8, 8],
76
- * [[-5, 5], [-5, 5], [-5, 5]]]);
168
+ * [[-6, -3], [8, 8],
169
+ * [[-5, 5], [-5, 5], [-5, 5]]]);
77
170
  *
78
171
  * // Sphere
79
172
  * var c = view.create('parametricsurface3d', [
@@ -87,48 +180,54 @@ define(['jxg', 'utils/type', '3d/view3d'
87
180
  * stepsU: 20,
88
181
  * stepsV: 20
89
182
  * });
90
- *
91
183
  * })();
92
184
  *
93
185
  * </script><pre>
94
186
  *
95
187
  */
96
- ThreeD.createParametricSurface = function (board, parents, attributes) {
188
+ JXG.createParametricSurface3D = function (board, parents, attributes) {
97
189
  var view = parents[0],
98
- attr,
99
- X = parents[1],
100
- Y = parents[2],
101
- Z = parents[3],
102
- range_u = parents[4],
103
- range_v = parents[5],
104
- D3, el;
105
-
106
- D3 = {
107
- elType: 'surface3d',
108
- X: X,
109
- Y: Y,
110
- Z: Z,
111
- range_u: range_u,
112
- range_v: range_v
113
- };
190
+ F, X, Y, Z,
191
+ range_u, range_v,
192
+ attr, el;
193
+
194
+ if (parents.length === 4) {
195
+ F = parents[1];
196
+ range_u = parents[2];
197
+ range_v = parents[3];
198
+ X = null;
199
+ Y = null;
200
+ Z = null;
201
+ } else {
202
+ X = parents[1];
203
+ Y = parents[2];
204
+ Z = parents[3];
205
+ range_u = parents[4];
206
+ range_v = parents[5];
207
+ F = null;
208
+ }
209
+
114
210
  attr = Type.copyAttributes(attributes, board.options, 'surface3d');
115
- el = board.create('curve', [[], []], attr);
116
- el.updateDataArray = function () {
117
- var steps_u = Type.evaluate(this.visProp.stepsu),
118
- steps_v = Type.evaluate(this.visProp.stepsv),
119
- r_u = Type.evaluate(this.D3.range_u), // Type.evaluate(range_u),
120
- r_v = Type.evaluate(this.D3.range_v), // Type.evaluate(range_v),
121
- res = view.getMesh(this.D3.X, this.D3.Y, this.D3.Z,
122
- r_u.concat([steps_u]),
123
- r_v.concat([steps_v]));
124
- this.dataX = res[0];
125
- this.dataY = res[1];
211
+ el = new JXG.Surface3D(view, F, X, Y, Z, range_u, range_v, attr);
212
+
213
+ el.element2D = view.create('curve', [[], []], attr);
214
+ el.element2D.updateDataArray = function() {
215
+ var ret = el.updateDataArray();
216
+ this.dataX = ret.X;
217
+ this.dataY = ret.Y;
126
218
  };
127
- el.D3 = D3;
219
+ el.addChild(el.element2D);
220
+ el.inherits.push(el.element2D);
221
+ el.element2D.setParents(el);
222
+
223
+ el.element2D.prepareUpdate().update();
224
+ if (!board.isSuspendedUpdate) {
225
+ el.element2D.updateVisibility().updateRenderer();
226
+ }
128
227
 
129
228
  return el;
130
229
  };
131
- JXG.registerElement('parametricsurface3d', ThreeD.createParametricSurface);
230
+ JXG.registerElement('parametricsurface3d', JXG.createParametricSurface3D);
132
231
 
133
232
  /**
134
233
  * @class This element creates a 3D function graph.
@@ -199,13 +298,12 @@ define(['jxg', 'utils/type', '3d/view3d'
199
298
  * stepsU: 70,
200
299
  * stepsV: 70
201
300
  * });
202
- *
203
301
  * })();
204
302
  *
205
303
  * </script><pre>
206
304
  *
207
305
  */
208
- ThreeD.createFunctiongraph = function (board, parents, attributes) {
306
+ JXG.createFunctiongraph3D = function (board, parents, attributes) {
209
307
  var view = parents[0],
210
308
  X = function(u, v) { return u; },
211
309
  Y = function(u, v) { return v; },
@@ -215,6 +313,6 @@ define(['jxg', 'utils/type', '3d/view3d'
215
313
 
216
314
  return view.create('parametricsurface3d', [X, Y, Z, range_u, range_v], attributes);
217
315
  };
218
- JXG.registerElement('functiongraph3d', ThreeD.createFunctiongraph);
316
+ JXG.registerElement('functiongraph3d', JXG.createFunctiongraph3D);
219
317
 
220
318
  });