point.moveAlong 的混乱行为
Chaotic behavior with point.moveAlong
这是一个沿曲线滑动点的简单动画:
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-5, 5, 5, -5],
axis: true
});
function f(x) {
return Math.sin(x);
}
board.create('functiongraph', f);
p = board.create('point', [0, 0], {
name: ''
});
var path = [];
var N = 500;
var x = 0;
for (i = 0; i < N; i++) {
path[i] = [x, f(x)];
x += 5 / N;
}
p.moveAlong(path, 5000);
当步数 N 相当小时,比如 50,点按预期沿着曲线平滑移动。但是当 N 较大时,例如 100 或 500,点会在棋盘周围随机跳舞。知道发生了什么事吗?
在这种情况下,动画有 50 个步骤就足够流畅了,但在我正在编写的另一个动画中,我需要更多步骤,我 运行 遇到了同样的故障。任何人都可以建议修复或至少是解决方法吗?
当给定 moveAlong 的路径是数组时,默认情况下会在连续步骤之间执行某种插值(参见 https://jsxgraph.org/docs/symbols/JXG.CoordsElement.html#moveAlong)。
我检查禁用此选项草图是否按预期工作:
p.moveAlong(路径, 6000, { 插值: false });
这是一个沿曲线滑动点的简单动画:
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-5, 5, 5, -5],
axis: true
});
function f(x) {
return Math.sin(x);
}
board.create('functiongraph', f);
p = board.create('point', [0, 0], {
name: ''
});
var path = [];
var N = 500;
var x = 0;
for (i = 0; i < N; i++) {
path[i] = [x, f(x)];
x += 5 / N;
}
p.moveAlong(path, 5000);
当步数 N 相当小时,比如 50,点按预期沿着曲线平滑移动。但是当 N 较大时,例如 100 或 500,点会在棋盘周围随机跳舞。知道发生了什么事吗?
在这种情况下,动画有 50 个步骤就足够流畅了,但在我正在编写的另一个动画中,我需要更多步骤,我 运行 遇到了同样的故障。任何人都可以建议修复或至少是解决方法吗?
当给定 moveAlong 的路径是数组时,默认情况下会在连续步骤之间执行某种插值(参见 https://jsxgraph.org/docs/symbols/JXG.CoordsElement.html#moveAlong)。
我检查禁用此选项草图是否按预期工作:
p.moveAlong(路径, 6000, { 插值: false });