Line in 3D space (crossing two circles)

Given two circles and an external point P in 3D space, I want to find the line in which passes through point P and also through the perimeters of both circles. The circles are parallell and concentric but offset in height, as on a cone. (Whether there exists none, one, two or infinite solutions depend on the positions of P and the circles. We can assume that there exist two solutions.)

This is how I have started out:

- The point P outside of the circles has the known coordinates
{xP; zP; yP}

- With the parametric equation for a circle, the point on circle one, C1, has the coordinates
{x1=r1*Cos[alpha1]; z1=r1*Sin[alpha1]; y1}
where r1 is the radius of circle one and alfa1 is the origo-angular position of point C1.

- Correspondingly for the point on the other circle, C2. The heights of the circles are independent of the angular parameter alpha, and are y1 and y2 respectively.

But then how do I find the conditions for when these three points line up?

I've actually used the law of cosinus to formulate the angle C1'P'C2 at point P as a function of alpha1 and alpha2 in order to minimize it numerically. However, this is cumbersome and I'm sure there are far simpler and better approaches.

A better idea would be to use the distance between points C1 and C2 as target equation to minimize. That simplifies the numerical method. I'll try that when I have access to Mathematica next. I'm just thining out loud here.

So, my plan now is to:

1) Choose some starting point C1 on circle one.

2) Calculate the point C2 on circle two which is closest to the line through C1 and P.

4) Choose some other point on circle one, through a numerical method such as the secant method. Go to step 2 above.

In step 2 above, it should be possible to have a nice algebraic solution. The 3D equation of the line through P to C1 is known. And the y-coordinate of C2 is given beforehand.

So I formulate the distance between the coordinates of the line at Y=y2 (in the plane of circle 2), from the coordinates of the equation of circle 2. I derivate that expression with respect to the parametric angle alfa2. I set the derivative to zero and solve for alpha2. That gives the point on C2 which is closest to the line (in its own plane Y=y2, not orthogonally). I then calculate the distance C1 to C2 and use secant method to minimize it by choosing new points on circle 1. If the line crosses both circles, then that distance will be zero for some chosen C1.

I'm still convinced that there are better ways, so if anyone sees is it, I'd appreciate the advice!