Intersection of yaw pitch vector with plane

3danalytic geometrygeometryrotationstrigonometry

I am trying to calculate the point of intersection between a vector (or simply a line) and a plane. Here's the information I have:

The plane is $z = 0$ and the application point of the vector is a known point $(x_p, y_p, z_p)$. The angles I know are the yaw and pitch of the vector relative to the coordinate system, be they $yaw = \theta$ and $pitch = \phi$. Again, what I wish to calculate are the coordinates of the intersection of said vector and the plane.

I have tried the following trigonometric approach:

The offset on the $X$ axis if $\phi = 0$ should be $z_p \tan(\theta)$ and the offset on the $Y$ axis when $\theta = 0$ is $z_p \tan(\phi)$.

Thus, the intersection points are $(x_p + z_p \tan(\theta), y_p, 0)$ for $\phi = 0$ and $(x_p, y_p + z_p \tan(\phi), 0)$ for $\theta = 0$.

That was obvious, I know, but what do I do if both $\theta$ and $\phi$ are nonzero?

Thank you in advance

P.S. I know I suck at formatting, but I hope the explanations are clear enough.

Best Answer

There are different ways of defining yaw and pitch. In my experience they usually express a change in attitude of an object relative to whatever attitude the object had before yaw and pitch were applied, so yaw and pitch do not tell you which way the object is pointing; you also have to know how the object was oriented before the yaw and pitch.

So I would assume that you always start with a certain reference vector and then apply your yaw and pitch to obtain the final direction of the vector. For the direction of the vector I would use coordinates of the vector. A good reference vector might have coordinates $(1,0,0).$ Applying a pitch of $\phi$ above the $x,y$ plane, we turn the vector $(1,0,0)$ to the vector $(\cos\phi, 0, \sin\phi).$ Next, rotating around the $z$ axis to apply the yaw, we get the vector $(\cos\phi\cos\theta, \cos\phi\sin\theta, \sin\phi).$

An alternative definition would apply the yaw first and then the pitch, but I would then expect the pitch to be a rotation around an axis in the $x,y$ plane perpendicular to wherever the yaw directed the vector, not necessarily a rotation around the $y$ axis as I used in the previous paragraph. The result would still be the vector $(\cos\phi\cos\theta, \cos\phi\sin\theta, \sin\phi).$

Notice that the yaw and pitch angles do not appear symmetrically in this result. Since rotation is non-commutative I would not expect any possible definition of the effect of yaw and pitch to be symmetric in $\theta$ and $\phi.$ So I also would not expect the formulas for the intersection to be symmetric in $\theta$ and $\phi.$ The fact that your formulas are symmetric is prima facie evidence that they are not correct.

If $\phi = 0$ then we have two cases. In the first case, $z_p= 0$ and the intersection point is simply $(x_p,y_p,0).$ In the second case, $z_p\neq 0$ and there is no intersection point.

If $-\frac\pi2 \leq \phi \leq \frac\pi2$ and $\phi\neq 0$ there is always an intersection point. The vector from $(x_p,y_p,z_p)$ is $(x_d,y_d,-z_p)$ for some numbers $x_d$ and $y_d.$ That vector also needs to be a scalar multiple of the yaw-pitch vector $(\cos\phi\cos\theta, \cos\phi\sin\theta, \sin\phi),$ that is, we require there be a number $r$ such that $$ (x_d,y_d,-z_p) = (r\cos\phi\cos\theta, r\cos\phi\sin\theta, r\sin\phi). $$

From this we deduce that $r \sin\phi = -z_p.$ Then $r \cos\phi = -z_p\cot\phi.$ We then find that \begin{align} x_d &= r\cos\phi\cos\theta = -z_p\cot\phi\cos\theta,\\ y_d &= r\cos\phi\sin\theta = -z_p\cot\phi\sin\theta.\\ \end{align}

This gives the intersection point $$ (x_p + x_d, y_p + y_d, 0) = (x_p - z_p\cot\phi\cos\theta, y_p - z_p\cot\phi\sin\theta, 0). $$

You will get different results if you start with a reference vector other than $(1,0,0)$ or if you define the angles differently. For example, if $\phi$ is the angle between the vector and a line parallel to the $z$ axis (rather than the angle between the vector and the $x,y$ plane) then you would have $\tan\phi$ where I wrote $\cot\phi.$ Making the "pitch" rotation around the $x$ axis rather than the $y$ axis also would change the results.