# Find the point of tangency from a point above a spheroid to its surface at a given azimuth

The Earth as spheroid, with semi-axis major $$a$$ in the $$xy$$ plane and semi-axis minor $$b$$ along the $$z-$$axis. At a point $$B$$ raised of distance $$h$$ above the spheroid surface, if I would to find the point of tangency between the spheroid and the line drawn from $$B$$ to the spheroid's surface at a given azimuth, let call this point of tangency $$C$$.

My illustration:

The description of my illustration: the red conic (ellipse) is the intersection of the meridian plane of $$A$$, the orthogonal projection of $$B$$ at the spheroid's surface, and the spheroid. I choose for example an azimuth $$\theta$$ turned clockwise from North, then I get the blue conic (ellipse) as intersection of that plane with the spheroid, then I draw a line from my location $$B$$ into that direction, the tangency point there at horizon between this line and the blue ellipse is $$C$$.

The first order of business appears to be finding the point $$A$$. It is the nearest point on the surface to $$B$$. This is common exercise given for practicing the Lagrange multiplier method, but its not necessary to introduce an extraneous variable. The point $$A$$ is characterized by the surface normal at $$A$$ being parallel to the line through $$A$$ and $$B$$. Letting $$f(x,y,z)=(x^2+y^2)/a^2+z^2/b^2$$, this condition can be expressed as $$(x-x_B,y-y_B,z-z_B)\times\nabla f(x,y,z)=0. \tag1$$ This produces a system of three equations, only two of which are independent. Combine with the equation $$f(x,y,z)=1$$ of the spheroid and solve to find $$A$$. This system will have two solutions, as the parallel normal condition is also met by the point on the surface that is farthest from $$B$$.
Now, the tangent lines through $$B$$ form a cone, but what’s more interesting for this problem is that the curve of contact of this cone with the spheroid is planar, and this common plane is the polar of $$B$$ with respect to the spheroid. Its equation is $${xx_B\over a^2}+{yy_B\over a^2}+{zz_B\over b^2}=1.\tag 2$$ The points $$A$$ and $$B$$ in turn, define a pencil of planes whose intersections with the spheroid generate the blue curves in your diagram. From the way that you’ve set up your problem, parameterizing these planes by the azimuth angle $$\theta$$ seems most natural, but there might be a more convenient parameterization.
Point $$C$$ then lies at the intersection of this plane, the polar to $$B$$ and the spheroid. This corresponds to a system of three implicit Cartesian equations to be solved. Alternatively, first find a parameterization of the line of intersection of the two planes and then substitute into $$f(x,y,z)=1$$. This will give you a simple quadratic equation to solve. As above, there might be two solutions, so you will have to select the correct one.