There exists some rectangle in 3d defined by 4 points $p1,p2,p3,p4$, and some line that's defined by two points $q1,q2$.
How to find out if the line intersects the rectangle?
So basically I have the answer, but I just have questions about it.
We find the intersection between the line spanned by the segment and the plane spanned by the rectangle and then verify that the intersection point is on both.
$N=v_1 \times v_2$
Then we find $t$ such that $((q_1+tu)-p_1)\cdot N=0$
Question 1: I don't 100% understand why we take $v_2=p_3-p_1$ - why we take the diagonal of the rectangle (from the drawing it's the diagonal)? I Would it still be correct if we defined $v_2=p_4-p_1$ ?
And obviously if $t<0$ or $t>1$ we reject since it's not on the actual line.
The intersection point on the plane is $=q_1+tu$
Now we want to check if $p$ resides in the given rectangle. In the answers they say:
if $(p-p_1)\cdot v_1 <0$ or $(p-p_1)\cdot v_1 > v_1 \cdot v_1 $ reject, and the same thing for $v_2$.
Question 2: I'm having a hard time understanding the above. I think that by doing $(p-p_1)\cdot v_1 <0$ it's basically projecting $p-p_1$ on $v_1$, and if it's negative, then $a>90$ and it's not on the rectangle. But what happens with $(p-p_1)\cdot v_1 > v_1 \cdot v_1 $ ? What is that checking? What's the geometrical meaning of this?