jsxgraph 1.4.3 → 1.4.4
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/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +56 -3
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraphcore.js +3 -3
- package/distrib/jsxgraphsrc.js +698 -65
- package/distrib/sketch.min.js +1 -1
- package/package.json +1 -1
- package/src/3d/box3d.js +12 -8
- package/src/3d/surface3d.js +142 -3
- package/src/3d/view3d.js +74 -4
- package/src/base/board.js +21 -18
- package/src/base/constants.js +1 -1
- package/src/element/composition.js +61 -22
- package/src/jsxgraph.js +6 -4
- package/src/math/clip.js +0 -1
- package/src/math/geometry.js +107 -1
- package/src/options3d.js +155 -13
- package/src/renderer/svg.js +7 -4
package/src/math/clip.js
CHANGED
|
@@ -1888,7 +1888,6 @@ define([
|
|
|
1888
1888
|
|
|
1889
1889
|
// Collect all points into clip array C
|
|
1890
1890
|
C = this._getPath(clip, board);
|
|
1891
|
-
|
|
1892
1891
|
len = C.length;
|
|
1893
1892
|
if (len > 0 && Geometry.distance(C[0].coords.usrCoords, C[len - 1].coords.usrCoords, 3) < Mat.eps * Mat.eps) {
|
|
1894
1893
|
C.pop();
|
package/src/math/geometry.js
CHANGED
|
@@ -1101,6 +1101,30 @@ define([
|
|
|
1101
1101
|
return that.meetCurveLine(el1, el2, i, el1.board, alwaysintersect);
|
|
1102
1102
|
};
|
|
1103
1103
|
|
|
1104
|
+
} else if (el1.type === Const.OBJECT_TYPE_POLYGON || el2.type === Const.OBJECT_TYPE_POLYGON) {
|
|
1105
|
+
// polygon - other
|
|
1106
|
+
// Uses the Greiner-Hormann clipping algorithm
|
|
1107
|
+
// Not implemented: polygon - point
|
|
1108
|
+
|
|
1109
|
+
if (el1.elementClass === Const.OBJECT_CLASS_LINE) {
|
|
1110
|
+
// line - path
|
|
1111
|
+
/** @ignore */
|
|
1112
|
+
func = function () {
|
|
1113
|
+
return that.meetPolygonLine(el2, el1, i, el1.board, alwaysintersect);
|
|
1114
|
+
};
|
|
1115
|
+
} else if (el2.elementClass === Const.OBJECT_CLASS_LINE) {
|
|
1116
|
+
// path - line
|
|
1117
|
+
func = function () {
|
|
1118
|
+
return that.meetPolygonLine(el1, el2, i, el1.board, alwaysintersect);
|
|
1119
|
+
};
|
|
1120
|
+
} else {
|
|
1121
|
+
// path - path
|
|
1122
|
+
/** @ignore */
|
|
1123
|
+
func = function () {
|
|
1124
|
+
return that.meetPathPath(el1, el2, i, el1.board);
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1104
1128
|
} else if (el1.elementClass === Const.OBJECT_CLASS_LINE && el2.elementClass === Const.OBJECT_CLASS_LINE) {
|
|
1105
1129
|
// line - line, lines may also be segments.
|
|
1106
1130
|
/** @ignore */
|
|
@@ -1516,6 +1540,8 @@ define([
|
|
|
1516
1540
|
* @param {JXG.Line} li Line
|
|
1517
1541
|
* @param {Number} nr Will return the nr-th intersection point.
|
|
1518
1542
|
* @param {JXG.Board} board
|
|
1543
|
+
* @param {Boolean} testSegment Test if intersection has to be inside of the segment or somewhere on the
|
|
1544
|
+
* line defined by the segment
|
|
1519
1545
|
* @returns {JXG.Coords} Coords object containing the intersection.
|
|
1520
1546
|
*/
|
|
1521
1547
|
meetCurveLineContinuous: function (cu, li, nr, board, testSegment) {
|
|
@@ -1580,7 +1606,6 @@ define([
|
|
|
1580
1606
|
return (new Coords(Const.COORDS_BY_USER, [z, cu.X(t), cu.Y(t)], board));
|
|
1581
1607
|
},
|
|
1582
1608
|
|
|
1583
|
-
|
|
1584
1609
|
/**
|
|
1585
1610
|
* Intersection of line and curve, discrete case.
|
|
1586
1611
|
* Segments are treated as lines.
|
|
@@ -1767,6 +1792,87 @@ define([
|
|
|
1767
1792
|
return [c, t, u];
|
|
1768
1793
|
},
|
|
1769
1794
|
|
|
1795
|
+
/**
|
|
1796
|
+
* Find the n-th intersection point of two pathes, usually given by polygons. Uses parts of the
|
|
1797
|
+
* Greiner-Hormann algorithm in JXG.Math.Clip.
|
|
1798
|
+
*
|
|
1799
|
+
* @param {JXG.Circle|JXG.Curve|JXG.Polygon} path1
|
|
1800
|
+
* @param {JXG.Circle|JXG.Curve|JXG.Polygon} path2
|
|
1801
|
+
* @param {Number} n
|
|
1802
|
+
* @param {JXG.Board} board
|
|
1803
|
+
*
|
|
1804
|
+
* @returns {JXG.Coords} Intersection point. In case no intersection point is detected,
|
|
1805
|
+
* the ideal point [0,0,0] is returned.
|
|
1806
|
+
*
|
|
1807
|
+
*/
|
|
1808
|
+
meetPathPath: function(path1, path2, nr, board) {
|
|
1809
|
+
var S, C, len, intersections;
|
|
1810
|
+
|
|
1811
|
+
S = JXG.Math.Clip._getPath(path1, board);
|
|
1812
|
+
len = S.length;
|
|
1813
|
+
if (len > 0 && this.distance(S[0].coords.usrCoords, S[len - 1].coords.usrCoords, 3) < Mat.eps) {
|
|
1814
|
+
S.pop();
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
C = JXG.Math.Clip._getPath(path2, board);
|
|
1818
|
+
len = C.length;
|
|
1819
|
+
if (len > 0 && this.distance(C[0].coords.usrCoords, C[len - 1].coords.usrCoords, 3) < Mat.eps * Mat.eps) {
|
|
1820
|
+
C.pop();
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
// Handle cases where at least one of the paths is empty
|
|
1824
|
+
if (nr < 0 || JXG.Math.Clip.isEmptyCase(S, C, 'intersection')) {
|
|
1825
|
+
return (new Coords(Const.COORDS_BY_USER, [0, 0, 0], board));
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
JXG.Math.Clip.makeDoublyLinkedList(S);
|
|
1829
|
+
JXG.Math.Clip.makeDoublyLinkedList(C);
|
|
1830
|
+
|
|
1831
|
+
intersections = JXG.Math.Clip.findIntersections(S, C, board)[0];
|
|
1832
|
+
if (nr < intersections.length) {
|
|
1833
|
+
return intersections[nr].coords;
|
|
1834
|
+
}
|
|
1835
|
+
return (new Coords(Const.COORDS_BY_USER, [0, 0, 0], board));
|
|
1836
|
+
},
|
|
1837
|
+
|
|
1838
|
+
/**
|
|
1839
|
+
* Find the n-th intersection point between a polygon and a line.
|
|
1840
|
+
* @param {JXG.Polygon} path
|
|
1841
|
+
* @param {JXG.Line} line
|
|
1842
|
+
* @param {Number} nr
|
|
1843
|
+
* @param {JXG.Board} board
|
|
1844
|
+
* @param {Boolean} alwaysIntersect If false just the segment between the two defining points of the line are tested for intersection.
|
|
1845
|
+
*
|
|
1846
|
+
* @returns {JXG.Coords} Intersection point. In case no intersection point is detected,
|
|
1847
|
+
* the ideal point [0,0,0] is returned.
|
|
1848
|
+
*/
|
|
1849
|
+
meetPolygonLine: function(path, line, nr, board, alwaysIntersect) {
|
|
1850
|
+
var i, res, border,
|
|
1851
|
+
crds = [0,0,0],
|
|
1852
|
+
len = path.borders.length,
|
|
1853
|
+
intersections = [];
|
|
1854
|
+
|
|
1855
|
+
for (i = 0; i < len; i++) {
|
|
1856
|
+
border = path.borders[i];
|
|
1857
|
+
res = this.meetSegmentSegment(
|
|
1858
|
+
border.point1.coords.usrCoords,
|
|
1859
|
+
border.point2.coords.usrCoords,
|
|
1860
|
+
line.point1.coords.usrCoords,
|
|
1861
|
+
line.point2.coords.usrCoords);
|
|
1862
|
+
|
|
1863
|
+
if (
|
|
1864
|
+
(!alwaysIntersect || (res[2] >= 0 && res[2] < 1)) &&
|
|
1865
|
+
res[1] >= 0 && res[1] < 1) {
|
|
1866
|
+
intersections.push(res[0]);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
if (nr >= 0 && nr < intersections.length) {
|
|
1871
|
+
crds = intersections[nr];
|
|
1872
|
+
}
|
|
1873
|
+
return (new Coords(Const.COORDS_BY_USER, crds, board));
|
|
1874
|
+
},
|
|
1875
|
+
|
|
1770
1876
|
/****************************************/
|
|
1771
1877
|
/**** BEZIER CURVE ALGORITHMS ****/
|
|
1772
1878
|
/****************************************/
|
package/src/options3d.js
CHANGED
|
@@ -13,38 +13,162 @@ define([
|
|
|
13
13
|
},
|
|
14
14
|
|
|
15
15
|
axes3d: {
|
|
16
|
+
/**#@+
|
|
17
|
+
* @visprop
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Position of the main axes in a View3D element. Possible values are
|
|
22
|
+
* 'center' and 'border'.
|
|
23
|
+
*
|
|
24
|
+
* @type String
|
|
25
|
+
* @name View3D#axesPosition
|
|
26
|
+
* @default 'center'
|
|
27
|
+
*/
|
|
16
28
|
axesPosition: 'center', // Possible values: 'center', otherwise: border
|
|
17
29
|
|
|
18
30
|
// Main axes
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Attributes of the 3D x-axis.
|
|
34
|
+
*
|
|
35
|
+
* @type Line3D
|
|
36
|
+
* @name View3D#xAxis
|
|
37
|
+
*/
|
|
19
38
|
xAxis: { visible: true, point2: {name: 'x'}},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Attributes of the 3D y-axis.
|
|
42
|
+
*
|
|
43
|
+
* @type Line3D
|
|
44
|
+
* @name View3D#yAxis
|
|
45
|
+
*/
|
|
20
46
|
yAxis: { visible: true, point2: {name: 'y'}},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Attributes of the 3D z-axis.
|
|
50
|
+
*
|
|
51
|
+
* @type Line3D
|
|
52
|
+
* @name View3D#zAxis
|
|
53
|
+
*/
|
|
21
54
|
zAxis: { visible: true, point2: {name: 'z'}},
|
|
22
55
|
|
|
23
56
|
// Planes
|
|
57
|
+
/**
|
|
58
|
+
* Attributes of the 3D plane orthogonal to the x-axis at the "rear" of the cube.
|
|
59
|
+
* @type Plane3D
|
|
60
|
+
* @name View3D#xPlaneRear
|
|
61
|
+
*/
|
|
24
62
|
xPlaneRear: { visible: true, layer: 0, mesh3d: { layer: 1 } },
|
|
63
|
+
/**
|
|
64
|
+
* Attributes of the 3D plane orthogonal to the y-axis at the "rear" of the cube.
|
|
65
|
+
* @type Plane3D
|
|
66
|
+
* @name View3D#yPlaneRear
|
|
67
|
+
*/
|
|
25
68
|
yPlaneRear: { visible: true, layer: 0, mesh3d: { layer: 1 } },
|
|
69
|
+
/**
|
|
70
|
+
* Attributes of the 3D plane orthogonal to the z-axis at the "rear" of the cube.
|
|
71
|
+
* @type Plane3D
|
|
72
|
+
* @name View3D#zPlaneRear
|
|
73
|
+
*/
|
|
26
74
|
zPlaneRear: { visible: true, layer: 0, mesh3d: { layer: 1 } },
|
|
27
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Attributes of the 3D plane orthogonal to the x-axis at the "front" of the cube.
|
|
78
|
+
* @type Plane3D
|
|
79
|
+
* @name View3D#xPlaneFront
|
|
80
|
+
*/
|
|
28
81
|
xPlaneFront: { visible: false, layer: 0, mesh3d: { layer: 1 } },
|
|
82
|
+
/**
|
|
83
|
+
* Attributes of the 3D plane orthogonal to the y-axis at the "front" of the cube.
|
|
84
|
+
* @type Plane3D
|
|
85
|
+
* @name View3D#yPlaneFront
|
|
86
|
+
*/
|
|
29
87
|
yPlaneFront: { visible: false, layer: 0, mesh3d: { layer: 1 } },
|
|
88
|
+
/**
|
|
89
|
+
* Attributes of the 3D plane orthogonal to the z-axis at the "front" of the cube.
|
|
90
|
+
* @type Plane3D
|
|
91
|
+
* @name View3D#zPlaneFront
|
|
92
|
+
*/
|
|
30
93
|
zPlaneFront: { visible: false, layer: 0, mesh3d: { layer: 1 } },
|
|
31
94
|
|
|
32
95
|
// Axes on the planes
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Attributes of the 3D y-axis on the 3D plane orthogonal to the x-axis at the "rear" of the cube.
|
|
98
|
+
* @type Plane3D
|
|
99
|
+
* @name View3D#xPlaneRearYAxis
|
|
100
|
+
*/
|
|
101
|
+
xPlaneRearYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
102
|
+
/**
|
|
103
|
+
* Attributes of the 3D z-axis on the 3D plane orthogonal to the x-axis at the "rear" of the cube.
|
|
104
|
+
* @type Plane3D
|
|
105
|
+
* @name View3D#xPlaneRearZAxis
|
|
106
|
+
*/
|
|
107
|
+
xPlaneRearZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
108
|
+
/**
|
|
109
|
+
* Attributes of the 3D y-axis on the 3D plane orthogonal to the x-axis at the "front" of the cube.
|
|
110
|
+
* @type Plane3D
|
|
111
|
+
* @name View3D#xPlaneFrontYAxis
|
|
112
|
+
*/
|
|
113
|
+
xPlaneFrontYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
114
|
+
/**
|
|
115
|
+
* Attributes of the 3D z-axis on the 3D plane orthogonal to the x-axis at the "front" of the cube.
|
|
116
|
+
* @type Plane3D
|
|
117
|
+
* @name View3D#xPlaneFrontZAxis
|
|
118
|
+
*/
|
|
119
|
+
xPlaneFrontZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
37
120
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Attributes of the 3D x-axis on the 3D plane orthogonal to the y-axis at the "rear" of the cube.
|
|
123
|
+
* @type Plane3D
|
|
124
|
+
* @name View3D#yPlaneRearXAxis
|
|
125
|
+
*/
|
|
126
|
+
yPlaneRearXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
127
|
+
/**
|
|
128
|
+
* Attributes of the 3D z-axis on the 3D plane orthogonal to the y-axis at the "rear" of the cube.
|
|
129
|
+
* @type Plane3D
|
|
130
|
+
* @name View3D#yPlaneRearZAxis
|
|
131
|
+
*/
|
|
132
|
+
yPlaneRearZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
133
|
+
/**
|
|
134
|
+
* Attributes of the 3D x-axis on the 3D plane orthogonal to the y-axis at the "front" of the cube.
|
|
135
|
+
* @type Plane3D
|
|
136
|
+
* @name View3D#yPlaneFrontXAxis
|
|
137
|
+
*/
|
|
138
|
+
yPlaneFrontXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
139
|
+
/**
|
|
140
|
+
* Attributes of the 3D z-axis on the 3D plane orthogonal to the y-axis at the "front" of the cube.
|
|
141
|
+
* @type Plane3D
|
|
142
|
+
* @name View3D#yPlaneFrontZAxis
|
|
143
|
+
*/
|
|
144
|
+
yPlaneFrontZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
42
145
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Attributes of the 3D x-axis on the 3D plane orthogonal to the z-axis at the "rear" of the cube.
|
|
148
|
+
* @type Plane3D
|
|
149
|
+
* @name View3D#zPlaneRearXAxis
|
|
150
|
+
*/
|
|
151
|
+
zPlaneRearXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
152
|
+
/**
|
|
153
|
+
* Attributes of the 3D y-axis on the 3D plane orthogonal to the z-axis at the "rear" of the cube.
|
|
154
|
+
* @type Plane3D
|
|
155
|
+
* @name View3D#zPlaneRearYAxis
|
|
156
|
+
*/
|
|
157
|
+
zPlaneRearYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
158
|
+
/**
|
|
159
|
+
* Attributes of the 3D x-axis on the 3D plane orthogonal to the z-axis at the "front" of the cube.
|
|
160
|
+
* @type Plane3D
|
|
161
|
+
* @name View3D#zPlaneFrontXAxis
|
|
162
|
+
*/
|
|
163
|
+
zPlaneFrontXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
|
|
164
|
+
/**
|
|
165
|
+
* Attributes of the 3D y-axis on the 3D plane orthogonal to the z-axis at the "front" of the cube.
|
|
166
|
+
* @type Plane3D
|
|
167
|
+
* @name View3D#zPlaneFrontYAxis
|
|
168
|
+
*/
|
|
169
|
+
zPlaneFrontYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1}
|
|
47
170
|
|
|
171
|
+
/**#@-*/
|
|
48
172
|
},
|
|
49
173
|
|
|
50
174
|
axis3d: {
|
|
@@ -105,11 +229,29 @@ define([
|
|
|
105
229
|
},
|
|
106
230
|
|
|
107
231
|
surface3d: {
|
|
232
|
+
/**#@+
|
|
233
|
+
* @visprop
|
|
234
|
+
*/
|
|
235
|
+
|
|
108
236
|
highlight: false,
|
|
109
237
|
tabindex: -1,
|
|
110
238
|
strokeWidth: 1,
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Number of intervals the mesh is divided into in direction of parameter u.
|
|
242
|
+
* @type Number
|
|
243
|
+
* @name Surface3D#stepsU
|
|
244
|
+
*/
|
|
111
245
|
stepsU: 30,
|
|
112
|
-
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Number of intervals the mesh is divided into in direction of parameter v.
|
|
249
|
+
* @type Number
|
|
250
|
+
* @name Surface3D#stepsV
|
|
251
|
+
*/
|
|
252
|
+
stepsV: 30
|
|
253
|
+
|
|
254
|
+
/**#@-*/
|
|
113
255
|
},
|
|
114
256
|
|
|
115
257
|
view3d: {
|
package/src/renderer/svg.js
CHANGED
|
@@ -1694,10 +1694,11 @@ define([
|
|
|
1694
1694
|
* setTimeout(function() { console.log('done'); }, 400);
|
|
1695
1695
|
*/
|
|
1696
1696
|
dumpToCanvas: function (canvasId, w, h, ignoreTexts) {
|
|
1697
|
-
var svg, tmpImg, cv, ctx
|
|
1697
|
+
var svg, tmpImg, cv, ctx,
|
|
1698
|
+
doc = this.container.ownerDocument;
|
|
1698
1699
|
|
|
1699
1700
|
// Prepare the canvas element
|
|
1700
|
-
cv =
|
|
1701
|
+
cv = doc.getElementById(canvasId);
|
|
1701
1702
|
|
|
1702
1703
|
// Clear the canvas
|
|
1703
1704
|
/* eslint-disable no-self-assign */
|
|
@@ -1833,7 +1834,8 @@ define([
|
|
|
1833
1834
|
} else {
|
|
1834
1835
|
// Debug: use canvas element 'jxgbox_canvas' from jsxdev/dump.html
|
|
1835
1836
|
id = 'jxgbox_canvas';
|
|
1836
|
-
canvas = document.getElementById(id);
|
|
1837
|
+
// canvas = document.getElementById(id);
|
|
1838
|
+
canvas = doc.getElementById(id);
|
|
1837
1839
|
}
|
|
1838
1840
|
|
|
1839
1841
|
if (newImg) {
|
|
@@ -1853,7 +1855,8 @@ define([
|
|
|
1853
1855
|
}
|
|
1854
1856
|
|
|
1855
1857
|
// Hide navigation bar in board
|
|
1856
|
-
zbar = document.getElementById(this.container.id + '_navigationbar');
|
|
1858
|
+
// zbar = document.getElementById(this.container.id + '_navigationbar');
|
|
1859
|
+
zbar = doc.getElementById(this.container.id + '_navigationbar');
|
|
1857
1860
|
if (Type.exists(zbar)) {
|
|
1858
1861
|
zbarDisplay = zbar.style.display;
|
|
1859
1862
|
zbar.style.display = 'none';
|