Check if a point is behind a plane (along a vector)

3dgeometrylinear algebravectors

I have an arbitrary vertex $v$ from a plane with a normal vector $\vec{n}$, I have a ray vector $\vec{r}$ I am shooting through the plane sort of, from a point $p$, I want to know if the point is behind the plane relative to the ray vector instead (I tried applying the same logic here asper the point being behind the plane relative to the normal vector, but that didn’t work)

Example
plane $(0,0,0)$ $(4,0,0)$ $(0,0,4)$ $(4,0,4)$
normal $\vec{n}$ $[0,1,0]$
ray $\vec{r}$ $[1,1,0]$
point $p$ $(1,2,2)$

I meant I tried picking an arbitrary vertex $v=(4,0,4)$ and doing $\vec{r} \cdot (p-v)$ and it turned out incorrect. Although for $v=(0,0,4)$ it works as expected.

Please how can one decipher if a point is behind a plane relative to some vector?

here’s my plane with the normal and ray vectors
enter image description here

here’s how one would normally check if a point is behind a plane (i.e. $\vec{n} \cdot (p-v)$):
enter image description here
enter image description here

here’s what I want to do instead:
enter image description here
enter image description here

Best Answer

Define $$s:=\left(\vec n\cdot\vec r\right)\left((p-v)\cdot\vec n\right).$$

Case 1: $s=0$ Then, the ray vector $\vec r$ is parallel to the plane or your point $p$ is in your plane.

Case 2: $s>0$ Then, your point $p$ is in the same half space which the ray vector $\vec r$ points into.

Case 3: $s<0$ Your point $p$ is behind the plane w.r.t. the ray vector $\vec r$.

This method works since $\vec n\cdot \vec r$ checks if $\vec n$ and $\vec r$ "are on the same side" of your plane, while $\left((p-v)\cdot\vec n\right)$ checks if $p$ is on the same side as the normal vector.

Related Question