I am currently working on a project in Lua that involves calculating the intersection points of two ellipses that share a common focus O. The parameters for the ellipses include the coordinates of their shared focus, the coordinates of the second foci (F1 and F2), and the distances from the foci to the vertices of each ellipse (p1 and p2).
(it's a part of Voronoi Diagram, where the sweep line is a circle, the beach line is a fan of ellipses, the project will be written in Lua)
The code for eliipses:
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)
How can I find the points T1 and T2?
Actually, it looks like a solution for PPC Apollonius Problem:
Each circle's middle point is the ellipse and the radius to the own focus of it, it touches the circle with tangent!

Update: I've found the solution for not inclined ellipses:
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)
Example:
