I want to find the rotation angle $\theta$ so that a line with given slope $m$ and y-intersect $t$ is tangential to an ellipse with a given minor axis $a$, major axis $b$ and center $h,k$. The rotation axis is the global z-axis.
Given:
- The blue ellipse with $a$,$b$ in a given reference state (center: $h=r+a, k=0$)
- The green line with $m$,$t$.
Todo:
- Rotate the green line around the origin until it is tangential to the blue ellipse (result is grey line) OR
- Rotate the blue ellipse until it is tangential to the green line (result is grey ellipse)
What I know:
(1) Equation of a straight line $$y=m*x+t$$
(2) Rotation around z-axis $$x'=x*\cos(\theta)-y*\sin(\theta)$$ $$y'=x*\sin(\theta)+y*\cos(\theta)$$
(3) Equation of a ellipse in the given reference state (blue ellipse) $$\frac{(x-h)^2}{a^2}+\frac{(y(x)-k)^2}{b^2}-1$$
I can find the implicit derivative of the ellipse $$\frac{d}{dx}y(x)=-\frac{b^2*(2*h-2*x)}{2*a^2*(k-y(x))}$$
and I know that this must be equal to the slope $m$ of the line. But here comes the problem. Not with the slope $m$ of the green line but with the slope $m$ of the rotated line (which is unknown, since I don't know the rotation angle.)
Can anybody help me to find what I'm missing? I think somehow I have to use equation 1 and 2 but I don't see how to solve for the angle $\theta$.
I would appreciate help very much.

HINT...When you rotate the green line by $\theta$ clockwise, to get the grey line, the equation of this line is $$y(\cos\theta+m\sin\theta)=x(m\cos\theta-\sin\theta)+t$$
This is of the form $y=Mx+C$, (assuming $\cos\theta+m\sin\theta \neq0)$.
If you solve this simultaneously with the equation of the ellipse $$\frac{(x-h)^2}{a^2}+\frac{y^2}{b^2}=1,$$ the resulting quadratic in $x$ must have double roots since the line is a tangent. Putting the discriminant $=0$ results in the equation $$-2MCh-C^2+b^2-M^2h^2+a^2M^2=0$$ where $$M=\frac{m\cos\theta-\sin\theta}{\cos\theta+m\sin\theta}$$ and $$C=\frac{t}{\cos\theta+m\sin\theta}$$
You then have an equation for $\theta$ to solve.