I’m trying to find the point where a line intersects the YZ plane, but having trouble getting the solution to work.

algebra-precalculustrigonometry

I made a visual of what I'm trying to do here. I have a plane on the XY axis, and I'm trying to trace a ray and find where it lands on the imaginary wall on the other side.

We know:

  • Point where the ray intersects the XY plane (P)
  • Normalized direction vector of the ray (V)
  • The imaginary wall is perfectly aligned with the YZ axis, and goes on infinitely in the positive YZ directions.

As you can tell from the link above, my idea was to approach it from the POV of a simple middle school algebra problem, where I break it down into two simple Y-intercept problems, one looking from the top and one looking from the side, to figure out the Y & Z coordinates of the intersection point.

The point slope equations of the problem would look like:

y - P_y = V_y(0 - P_x)

z - 0 = V_z(0 - P_x)

and after simplifying them into slope-intercept form to get the coordinates of the intersection I get:

x =  0

y = V_y(-P_x) + P_y

z = V_z(-P_x)

It's one of those things that seems stupidly simple, but for some reason it's not working. I'm using it in a shader program and it's just giving me a bunch of random gradients like I dropped acid in the middle of trig class.

Does anything stand out as something I'm doing wrong? Also, if anyone has a better solution than this, I'm all ears.

Best Answer

We have ... \begin{eqnarray*} \begin{pmatrix} p_x \\ p_y \\ 0 \end{pmatrix} +\lambda \begin{pmatrix} v_x \\ v_y \\ v_z \end{pmatrix} = \begin{pmatrix} 0 \\ q_y \\ q_z \end{pmatrix} \tag{1} \end{eqnarray*} Use the first equation to obtain a value for $ \lambda$ & then the second & third equation to obtain $Q$.

Edit: We have a point $P=\begin{pmatrix} p_x \\ p_y \\ 0 \end{pmatrix}$ in the XY plane. and vector $V= \begin{pmatrix} v_x \\ v_y \\ v_z \end{pmatrix}$ that goes through the point.

The equation of this line will be $P+\lambda V$ where $\lambda \in \mathbb{R}$.

This line intersects the YZ plane at $Q= \begin{pmatrix} 0 \\ q_y \\ q_z \end{pmatrix}$

Equation $(1)$ has three components & can be considered as the following $3$ equations \begin{eqnarray*} p_x +\lambda v_x = 0 \\ p_y +\lambda v_y = q_y \\ 0 +\lambda v_z = q_z \\ \end{eqnarray*}

Related Question