I made some small bug fixes to the conic intersection package. Thanks to Dany for pointing the bug out. The matlab code that you can download here can be used to detect the (up to) four intersections of two conics. The usage is quite straightforward but anyway, here is an example:

%%the homogeneous representation of a conic is a matrix

%% m = [A C D; C B E; D E F] that represents the equation

%%A x^2 + B y^2 + 2C xy + 2D x + 2Ey + F = 0

%a circle centered in the origin

E1 = [1 0 0; 0 1 0; 0 0 -3]

%an ellipse centered in the origin

E2 = [1 0 0; 0 3 0; 0 0 -6]

%get the four homogeneous intersections

P = intersectConics(E1, E2)

%plot the normalized points

plot(P(1,:) ./ P(3,:) , P(2,:) ./ P(3,:), 'ro');

## Algorithm description

The solutions to a two second degree equations system in two variables may be seen as the coordinates of the intersections of two generic conic section. In particular two conics may possess none, two, four possibly coincident intersection points. The best method to locate these solutions is to exploit the homogeneous matrix representation of conic sections, i.e. a 3x3 symmetric matrix which depends on six parameters.

The procedure to locate the intersection points follows these steps:

- given the two conics
*C*_{1}and*C*_{2}consider the pencil of conics given by their linear combination ?*C*_{1}+ ?*C*_{2} - identify the homogeneous parameters (?,?) which corresponds to the degenerate conic of the pencil. This can be done by imposing that
*d**e**t*(?*C*_{1}+ ?*C*_{2}) = 0, which turns out to be the solution to a third degree equation. - given the degenerate cone
*C*_{0}, identify the two, possibly coincident, lines constituting it - intersects each identified line with one of the two original conic; this step can be done efficiently using the dual conic representation of
*C*_{0} - the points of intersection will represent the solution to the initial equation system

## Matlab implementation

In the library you will find a couple of matlab function which implements the above steps to intersect two conics. In particular the main functions are:

**intersectConics**: this is the main function to perform the intersection**decomposeDegenerateConic**: this function allow to split a degenerate conic into two lines**intersecLineConic**: this function recover the, possibly two, points of intersection of a line and a conic

If you have any comments please refer to me by email!