I am trying to find the common tangents between 2 ellipses by using solve function. I have f(x1) and g(x2) which are my 2 elipses (ellipse 1 the smallest and ellipse 2) equations and the 2 unknows (x1 and x2) and their derivative at each point which gives me the slope of their tangents at each point.
Then, my equations to solve are:
and here my Matlab code:
syms x1 x2
f_x1 = -sqrt(b1^2*(1-((x1-xC1)/a1)^2)) + yC1;
g_x2 = sqrt(b2^2*(1-((x2-xC2)/a2)^2)) + yC2;
f_x1_prime = b1^2*(x1-xC1)/(a1^2*sqrt(b1^2*(1-((x1-xC1)/a1)^2)));
g_x2_prime = -b2^2*(x2-xC2)/(a2^2*sqrt(b2^2*(1-((x2-xC2)/a2)^2)));
eq1 = (g_x2 - f_x1)/(x2 - x1) == f_x1_prime;
eq2 = f_x1_prime == g_x2_prime;
[S] = solve(eq1, eq2, x1, x2, 'ReturnConditions', true, 'Real', true);
restriction = [S.x1>xC1, S.x1<xC1+a1, S.x2<xC2, S.x2>xC2-a2];
solx = solve(restriction, S.parameters);
x1 = subs(S.x1, S.parameters, solx);
x2 = subs(S.x2, S.parameters, solx);
As result, I have something in S but the warning and no solution after having assume the condition and solve the parameter.
struct with fields:
x1: [1×1 sym]
x2: [1×1 sym]
parameters: [1×1 sym]
conditions: [1×1 sym]
and the warning:
Warning: Unable to find explicit solution. For options, see help.
> In sym/solve (line 317)
In findTangentPoints (line 24)
In testTangent (line 11)
Does anyone can help me to use this function solve or see any errors ? I am going to be crazy...
Thanks a lot everyone and have a nice evening!