简短版本:如果E是一般圆锥曲线,L是穿过它的线,我想要这样的东西:
P = board.create('intersection',[L,E,0]);
Q = board.create('otherintersection',[L,E,P]);
除了
otherintersection
似乎不起作用,除非 E 是一个圆。
长版:附图显示了我正在做的事情。我有一个内椭圆和一个外圆锥截面 E,这里是一个椭圆,但也可以是任何其他。 P 在外部曲线上滑动,并创建其与内部椭圆的切线。
问题是我想命名切线与外椭圆相交的其他交点。
如果外曲线是圆,我可以使用
otherintersection
,但我不能在这里,即使我可以找到两端的交点。这是我使用的标准几何方法:
如果切线是T1和T2,我可以找到与外圆锥曲线E的交点
t10 = board.create('intersection',[T1,E,0]);
t11 = board.create('intersection',[T1,E,1]);
t20 = board.create('intersection',[T2,E,0]);
t21 = board.create('intersection',[T2,E,1]);
因为所有这些都是在 JSXGraph 中以数字方式完成的,所以切线的两个端点都不可能完全等于 P。所以我不能简单地问两个端点中哪一个不是 P。我尝试找出哪个端点离 P 更远,但我无法让它工作:
if (P.Dist(t10) > P.Dist(t11)) {
t10.setAttribute({name:'Q'});
} else {
t11.setAttribute({name:'Q'});
}
这只适用于一半曲线。我已经检查了输出到 console.log 的长度和距离,显然有些东西不起作用。但我不知道如何解决。
我希望我已经弄清楚了我的问题。这些信息足够吗?
事实上,从 JSXGraph v1.6.2 版本开始,
otherintersection
仅处理圆/线或圆/圆的组合。添加直线/圆锥曲线、圆锥曲线/圆和圆锥曲线/圆锥曲线是一个很好的建议。也许,这将使它已经进入即将到来的 v1.7.0。
在此之前的解决方法是以下代码。 您生成上述图像(但不太漂亮)的构造,包括切线
t1
和 t2
看起来像这样:
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-7, 7, 7, -7], axis: true
});
var f1 = board.create('point', [1, 0], { name: 'f_1' });
var f2 = board.create('point', [-1, 0], { name: 'f_2' });
var A = board.create('point', [0, 1], { name: 'A' });
var inner = board.create('ellipse', [f1, f2, A]);
var P = board.create('point', [-3, 4], { name: 'P' });
var outer = board.create('ellipse', [[-3, -3], [3, 3], P]);
var c1 = board.create('circle', [f1, () => (f1.Dist(A) + f2.Dist(A))], { strokeColor: '#bbb', dash: 2 });
var c2 = board.create('circle', [P, f2], { strokeColor: '#bbb', dash: 2 });
var M1 = board.create('intersection', [c1, c2], { name: 'M1', size: 2 });
var M2 = board.create('otherintersection', [c1, c2, M1], { name: 'M2', size: 2 });
var l1 = board.create('line', [f2, M1], { strokeWidth: 1, dash: 3, visible: false });
var l2 = board.create('line', [f2, M2], { strokeWidth: 1, dash: 3, visible: false });
var a1 = board.create('midpoint', [f2, M1], { size: 2, name: '' });
var a2 = board.create('midpoint', [f2, M2], { size: 2, name: '' });
var t1 = board.create('perpendicular', [l1, a1]);
var t2 = board.create('perpendicular', [l2, a2]);
现在,
t1
和t2
与outer
的“其他”交点可以用以下代码构造:
var otherIntersection = function (el1, el2, other) {
var c = JXG.Math.Geometry.meetCurveLine(el1, el2, 0, el1.board);
if (
Math.abs(other.X() - c.usrCoords[1]) > 0.001 ||
Math.abs(other.Y() - c.usrCoords[2]) > 0.001 ||
Math.abs(other.Z() - c.usrCoords[0]) > 0.001
) {
return c.usrCoords;
}
return JXG.Math.Geometry.meetCurveLine(el1, el2, 1, el1.board).usrCoords;
};
var other1 = board.create('point', [() => otherIntersection(outer, t1, P)], { name: 'Q_1' });
var other2 = board.create('point', [() => otherIntersection(outer, t2, P)], { name: 'Q_2' });