使用 JSXGraph 绘制不等式域梳状图
Plotting inequalities domain comb-style with JSXGraph
我想用不等式域的梳状选择来绘制轴线,如下图:
JSXGraph 可以吗?
它还不是 JSXGraph built-in。但这是个好建议。
这是一个实现(要成为 built-in,必须将其重写为 JSXGraph 元素)。
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-5, 5, 5, -5],
axis: true
});
var comb = function(board, [left, right, n, base, height]) {
var delta,
c = board.create('curve', [[0], [0]]);
delta = (right - left) / n;
c.updateDataArray = function() {
var s;
this.dataX = [];
this.dataY = [];
for (s = left; s + delta*0.5<= right; s += delta) {
this.dataX.push(s);
this.dataY.push(base);
this.dataX.push(s + delta);
this.dataY.push(base + height);
this.dataX.push(NaN); // Force a jump
this.dataY.push(NaN);
}
};
board.update();
return c;
};
var c1 = comb(board, [1, 3, 10, 0, 0.2]);
var c2 = comb(board, [-4, -1, 20, -2, 0.2]);
在此处查看实际效果:https://jsfiddle.net/vcL7aepo/217/ .
我想用不等式域的梳状选择来绘制轴线,如下图:
JSXGraph 可以吗?
它还不是 JSXGraph built-in。但这是个好建议。 这是一个实现(要成为 built-in,必须将其重写为 JSXGraph 元素)。
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-5, 5, 5, -5],
axis: true
});
var comb = function(board, [left, right, n, base, height]) {
var delta,
c = board.create('curve', [[0], [0]]);
delta = (right - left) / n;
c.updateDataArray = function() {
var s;
this.dataX = [];
this.dataY = [];
for (s = left; s + delta*0.5<= right; s += delta) {
this.dataX.push(s);
this.dataY.push(base);
this.dataX.push(s + delta);
this.dataY.push(base + height);
this.dataX.push(NaN); // Force a jump
this.dataY.push(NaN);
}
};
board.update();
return c;
};
var c1 = comb(board, [1, 3, 10, 0, 0.2]);
var c2 = comb(board, [-4, -1, 20, -2, 0.2]);
在此处查看实际效果:https://jsfiddle.net/vcL7aepo/217/ .