I have been trying to get the common tangents to two rotated ellipse. I was following the method given by Edward Doolittle in the following thread. The two ellipses are given as the equation given in Wiki.
In the Matrix form the ellipse can be shown as this:
First ellipse is centered at (0,0) rotated by 45 degrees with semi-major and semi-minor axes length as 2,1. Second ellipse is centered at (15,0), rotated by 120 degrees with semi-major and semi-minor axes length as 3,1
Linear combination of the adjoint matrices of the two ellipses are per dual of two ellipse combined
I am getting this value
.
Then I tried to find to find the value of t which will make the conic (above matrix) degenerate.
I found the value of t to be (-0.05,0.29,2.46). However, when I put these values back into the above matrix I am not able to reduce the matrix to two variables form. I am always dealing with 3 variables. For example, if I put t = -0.05 then I get the following:
Can someone please help me with this?
It boils down to finding an algorithm for solving a system of two quadratic equations of two variables, by interpreting it as a projective geometry pencil of conics, then finding the three degenerate conics of the pencil together with a projective transformation that simplifies these three degenerate conics to the point of your being able to read off the solutions very easily in new simplifying coordinate system, and after that transforming them back to the original coordinate system.
I sketched an algorithm in python, I think it seems to work on your example... but I was in a hurry and did not check it properly, so there may be bugs...
Some Explanations: Assume you want to find the intersection points of two conics C1 and C2. Let us assume for simplicity that they are real ellipses that intersect in four different points (to avoid complex numbers)
In the case of finding the common tangents to a pair of conics, simply convert the two conics two corresponding duals and then find the intersection points of the duals. These intersection points are the equation coefficients of the tangents of the original conics.
There are possibly several different geometric interpretations of this problem, but let us go with the pencil of conics. The two conics C1 and C2 are represented by 3 by 3 symmetric matrices with non-zero determinants, which I have denoted C1 and C2. The linear combination, called pencil of conics generated by C1 and C2, is the t-parametrized family of conics
C1 - t*C2
, where t is just a number. What is crucial is that every conicC1 - tC2
passes through the intersection points of C1 and C2 and these are the only four points they all have in common. You can prove this by observing that ifx.T * C1 * x = x.T * C1 * x = 0
thenx.T * (C1 - t*C2) * x = x.T * C1 * x - t * x.T * C2 * x = 0 - t*0 = 0
. Furthermore, if you take an intersection point ofC1
andC1 - t*C2
, thenC2 = C1 - t*C2 + s*C2
you can apply the same argument whens = t
.In this family of conics, there are three degenerate conics, that are geometrically three pairs of lines. They occur exactly when t is such that
det( C1 - t*C2 ) = 0
. This is a polynomial equation of degree 3 with respect to t, so there are three, say different solutionsk[0], k[1], k[2],
due to the niceness of the C1 and C2. Projectively speaking, each degenerate conicC1 - k[j]*C2
is a pair of lines and they have a common intersection pointu[:,j] = [ u[0,j] : u[1,j] : u[2,j] ]
. Moreover,rank(C1 - k[j]*C2) = 2
, soker(C1 - k[j]*C2) = 1
. This pointu[:,j]
is characterized as a solution to the equation(C1 - k[j]*C2) * u[:,j] = 0
. SinceC2
is invertible (non-degenerate), multiply both sides of the equation byinverse(C2)
and obtain the equivalent equation( (inverse(C2) * C1) - k[j]*Identity ) * u[:,j] = 0
which is an eigenvalue equation, withk[j]
as eigenvalue andu[:,j]
as eigenvector. The output of the functiontransform()
is the 1 by 3 arrayk
of eigenvalues and the 3 by 3 matrixU = [ u[:,0], u[:,1], u[:,2] ]
of eigenvectors.Conjugating
C1 - k[j]*C2 by U, i.e. (U.T)*(C1 - k[j]*C2)*U
, is geometrically equivalent to performing a projective transformation that sendsu[:,0]
andu[:,1]
to infinity andu[:,2]
to the origin. Thus,U
changes the coordinate system from a general one to a special coordinate system, in which two of the degenerate conics are given by pairs of parallel lines and combined they intersect in a rectangle. The third conic is represeneted by the diagnols of the rectangle.In this new picture, the intersection problem can be easily solved, just by reading off one solution from the entries of the matrices
(U.T)*(C1 - k[j]*C2)*U
(the intersection points are the vertices of the rectangle, so if you find one of them, the others are simply mirror symmetric of each other).