jsxgraph 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/distrib/docs.zip +0 -0
- package/distrib/geogebra.min.js +2 -2
- package/distrib/geonext.min.js +2 -2
- package/distrib/intergeo.min.js +2 -2
- package/distrib/jsxgraph.css +1 -1
- package/distrib/jsxgraph.zip +0 -0
- package/distrib/jsxgraphcore.js +3 -3
- package/distrib/jsxgraphcore.mjs +3 -3
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +2328 -1508
- package/distrib/jsxgraphsrc.mjs +2328 -1508
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/distrib/sketch.min.js +3 -3
- package/package.json +4 -4
- package/src/3d/box3d.js +4 -1
- package/src/3d/circle3d.js +10 -9
- package/src/3d/curve3d.js +2 -0
- package/src/3d/linspace3d.js +18 -55
- package/src/3d/point3d.js +6 -0
- package/src/3d/polygon3d.js +1 -0
- package/src/3d/sphere3d.js +47 -43
- package/src/3d/surface3d.js +1 -0
- package/src/3d/view3d.js +1504 -1067
- package/src/base/board.js +176 -55
- package/src/base/circle.js +3 -1
- package/src/base/constants.js +1 -1
- package/src/base/curve.js +1 -0
- package/src/base/element.js +38 -30
- package/src/base/line.js +93 -105
- package/src/base/polygon.js +1 -1
- package/src/base/text.js +5 -1
- package/src/element/button.js +62 -12
- package/src/element/checkbox.js +6 -2
- package/src/element/grid.js +6 -6
- package/src/element/input.js +9 -6
- package/src/element/slider.js +42 -39
- package/src/jsxgraph.js +5 -3
- package/src/math/geometry.js +86 -64
- package/src/math/math.js +47 -5
- package/src/options.js +45 -0
- package/src/options3d.js +82 -5
- package/src/parser/jessiecode.js +2 -1
- package/src/parser/prefix.js +8 -1
- package/src/reader/sketch.js +106 -0
- package/src/renderer/svg.js +16 -6
- package/src/utils/env.js +2 -2
- package/src/utils/type.js +27 -15
package/src/3d/sphere3d.js
CHANGED
|
@@ -209,54 +209,54 @@ JXG.extend(
|
|
|
209
209
|
// `focusFn(1)`, that evaluate to the projections of the front and back
|
|
210
210
|
// points of the sphere, respectively.
|
|
211
211
|
focusFn: function (sgn) {
|
|
212
|
-
|
|
212
|
+
var that = this;
|
|
213
213
|
|
|
214
214
|
return function () {
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
var camDir = that.view.boxToCam[3],
|
|
216
|
+
r = that.Radius();
|
|
217
217
|
|
|
218
218
|
return that.view.project3DTo2D([
|
|
219
|
-
that.center.X() + sgn*r*camDir[1],
|
|
220
|
-
that.center.Y() + sgn*r*camDir[2],
|
|
221
|
-
that.center.Z() + sgn*r*camDir[3]
|
|
219
|
+
that.center.X() + sgn * r * camDir[1],
|
|
220
|
+
that.center.Y() + sgn * r * camDir[2],
|
|
221
|
+
that.center.Z() + sgn * r * camDir[3]
|
|
222
222
|
]).slice(1, 3);
|
|
223
223
|
};
|
|
224
224
|
},
|
|
225
225
|
|
|
226
226
|
innerVertexFn: function () {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return function() {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
227
|
+
var that = this;
|
|
228
|
+
|
|
229
|
+
return function () {
|
|
230
|
+
var view = that.view,
|
|
231
|
+
p = view.worldToFocal(that.center.coords, false),
|
|
232
|
+
distOffAxis = Mat.hypot(p[0], p[1]),
|
|
233
|
+
cam = view.boxToCam,
|
|
234
|
+
inward = [
|
|
235
|
+
-(p[0] * cam[1][1] + p[1] * cam[2][1]) / distOffAxis,
|
|
236
|
+
-(p[0] * cam[1][2] + p[1] * cam[2][2]) / distOffAxis,
|
|
237
|
+
-(p[0] * cam[1][3] + p[1] * cam[2][3]) / distOffAxis
|
|
238
|
+
],
|
|
239
|
+
r = that.Radius(),
|
|
240
|
+
angleOffAxis = Math.atan(-distOffAxis / p[2]),
|
|
241
|
+
steepness = Math.acos(r / Mat.norm(p)),
|
|
242
|
+
lean = angleOffAxis + steepness,
|
|
243
|
+
cos_lean = Math.cos(lean),
|
|
244
|
+
sin_lean = Math.sin(lean);
|
|
245
245
|
|
|
246
246
|
return view.project3DTo2D([
|
|
247
|
-
that.center.X() + r * (sin_lean*inward[0] + cos_lean*cam[3][1]),
|
|
248
|
-
that.center.Y() + r * (sin_lean*inward[1] + cos_lean*cam[3][2]),
|
|
249
|
-
that.center.Z() + r * (sin_lean*inward[2] + cos_lean*cam[3][3])
|
|
247
|
+
that.center.X() + r * (sin_lean * inward[0] + cos_lean * cam[3][1]),
|
|
248
|
+
that.center.Y() + r * (sin_lean * inward[1] + cos_lean * cam[3][2]),
|
|
249
|
+
that.center.Z() + r * (sin_lean * inward[2] + cos_lean * cam[3][3])
|
|
250
250
|
]);
|
|
251
251
|
};
|
|
252
252
|
},
|
|
253
253
|
|
|
254
254
|
buildCentralProjection: function () {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
255
|
+
var view = this.view,
|
|
256
|
+
auxStyle = { visible: false, withLabel: false },
|
|
257
|
+
frontFocus = view.create('point', this.focusFn(-1), auxStyle),
|
|
258
|
+
backFocus = view.create('point', this.focusFn(1), auxStyle),
|
|
259
|
+
innerVertex = view.create('point', this.innerVertexFn(view), auxStyle);
|
|
260
260
|
|
|
261
261
|
this.aux2D = [frontFocus, backFocus, innerVertex];
|
|
262
262
|
this.element2D = view.create('ellipse', this.aux2D, this.visProp);
|
|
@@ -264,14 +264,13 @@ JXG.extend(
|
|
|
264
264
|
|
|
265
265
|
buildParallelProjection: function () {
|
|
266
266
|
// The parallel projection of a sphere is a circle
|
|
267
|
-
|
|
268
|
-
that = this,
|
|
267
|
+
var that = this,
|
|
269
268
|
center2d = function () {
|
|
270
|
-
|
|
269
|
+
var c3d = [1, that.center.X(), that.center.Y(), that.center.Z()];
|
|
271
270
|
return that.view.project3DTo2D(c3d);
|
|
272
271
|
},
|
|
273
272
|
radius2d = function () {
|
|
274
|
-
|
|
273
|
+
var boxSize = that.view.bbox3D[0][1] - that.view.bbox3D[0][0];
|
|
275
274
|
return that.Radius() * that.view.size[0] / boxSize;
|
|
276
275
|
};
|
|
277
276
|
|
|
@@ -286,11 +285,15 @@ JXG.extend(
|
|
|
286
285
|
// replace our 2D representation with a new one that's consistent with
|
|
287
286
|
// the view's current projection type
|
|
288
287
|
rebuildProjection: function () {
|
|
288
|
+
var i;
|
|
289
|
+
|
|
289
290
|
// remove the old 2D representation from the scene tree
|
|
290
291
|
if (this.element2D) {
|
|
291
292
|
this.view.board.removeObject(this.element2D);
|
|
292
|
-
for (
|
|
293
|
-
this.
|
|
293
|
+
for (i in this.aux2D) {
|
|
294
|
+
if (this.aux2D.hasOwnProperty(i)) {
|
|
295
|
+
this.view.board.removeObject(this.aux2D[i]);
|
|
296
|
+
}
|
|
294
297
|
}
|
|
295
298
|
}
|
|
296
299
|
|
|
@@ -307,6 +310,7 @@ JXG.extend(
|
|
|
307
310
|
// attach the new 2D representation to the scene tree
|
|
308
311
|
this.addChild(this.element2D);
|
|
309
312
|
this.inherits.push(this.element2D);
|
|
313
|
+
this.element2D.view = this.view;
|
|
310
314
|
}
|
|
311
315
|
}
|
|
312
316
|
);
|
|
@@ -463,11 +467,11 @@ JXG.createSphere3D = function (board, parents, attributes) {
|
|
|
463
467
|
} else {
|
|
464
468
|
throw new Error(
|
|
465
469
|
"JSXGraph: Can't create sphere3d with parent types '" +
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
470
|
+
typeof parents[1] +
|
|
471
|
+
"' and '" +
|
|
472
|
+
typeof parents[2] +
|
|
473
|
+
"'." +
|
|
474
|
+
"\nPossible parent types: [point,point], [point,number], [point,function]"
|
|
471
475
|
);
|
|
472
476
|
}
|
|
473
477
|
|
package/src/3d/surface3d.js
CHANGED