1
$\begingroup$

If I have a line segment defined by two points p1, p2, and then a rectangular prism defined by (x,y,z) (lowest corner point) with length/width/height (l, w, h), how can I check if the line will intersect the prism? And also get the point of intersection if there is one?

Does anyone know?

Thanks

1 Answers 1

0

You should first parametrize the line as $(x,y,z)=p_1+t(p_2-p_1)$, for $t\in\mathbb{R}$. From this, substituting the coordinates of the two points, you get the equations that define this line in $\mathbb{R}^3$ in terms of $x,y,z$.

On the other hand, you can similarly parametrize the prism (if it's a solid volume then it will be defined by inequalities in $x,y,z$).

Then you put both systems together, the equations that define the line and the inequalities that define the prism, and see if it has a solution (if it exists a point that belongs to both line and prism, so it belongs to their intersection).

  • 0
    Can you show an example?2017-02-08
  • 0
    Can you give the coordinates of the points or the information you have in the problem statement?2017-02-08