You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求两共焦点椭圆的交点T1、T2(Lua实现)

共焦点椭圆交点求解需求(Lua环境)

我正在Lua环境下开发Voronoi图相关项目,需计算两个共享同一焦点O的椭圆的交点T1和T2。椭圆参数包括共享焦点坐标、各自的第二焦点F1、F2坐标,以及焦点到顶点的距离p1、p2。项目中扫描线为圆形,海岸线由椭圆扇构成。

现有椭圆生成代码

local f0 = {x=400, y=300, r=290}

local function newEllipse (x, y)
    local r = f0.r
    local ellipse = {f0 = f0, f= {x=x, y=y}}

    ellipse.c = length(f0.x, f0.y, x, y)/2
    print ('c', ellipse.c)
    local p = (f0.r - 2*ellipse.c)/2
    print ('p', p)
    ellipse.a = ellipse.c + p
    print ('a', ellipse.a)
    ellipse.b = math.sqrt(ellipse.a^2 - ellipse.c^2)
    
    ellipse.alpha = math.atan2 (y-f0.y, x-f0.x)
    print ('alpha', ellipse.alpha)

    local vertices = {}
    local numPoints = 32
    for i = 1, numPoints do
        local t = (i / numPoints) * (2 * math.pi)
        local x = (f0.x + x) / 2 + ellipse.a * math.cos(t) * math.cos(ellipse.alpha) - ellipse.b * math.sin(t) * math.sin(ellipse.alpha)
        local y = (f0.y + y) / 2 + ellipse.a * math.cos(t) * math.sin(ellipse.alpha) + ellipse.b * math.sin(t) * math.cos(ellipse.alpha)
--      print (x, y)
        table.insert (vertices, x)
        table.insert (vertices, y)
    end
    ellipse.vertices = vertices

    return ellipse
end

local e1 = newEllipse (500, 300)
local e2 = newEllipse (400, 500)

该问题类似PPC阿波罗尼斯问题:每个圆的中点对应椭圆,其到自身焦点的半径与圆相切。

已实现的非倾斜椭圆交点求解方案

x = f*d
y = f*sqrt(1-d^2)
-- where d is cos theta:
d = (t1 - t2)/(t1*e2 - t2*e1)
t1 = 1-e1^2 -- also t1 = b^2/a^2
t2 = 1-e2^2
-- f is radius for this theta:
f = a*t1/(1-e1*d)

现寻求通用的两共焦点椭圆交点T1、T2的求解方法。


内容的提问来源于stack exchange,提问作者darkfrei

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 11:11:05