How do I calculate the intersection between a plane and a line in 3 dimensions?

54 Views Asked by At

Given some lines in 3-D space, represented by a series of points (x, y, z) etc., and a plane represented by a point and a normal vector, how can I calculate if/where the plane intersects between two given points, which form my line?

I'm working on a programming project, and I'm not super well-versed in 3d geometry. I worked out my proof-of-concept in 2d, and am having trouble scaling it into this third dimension.

1

There are 1 best solutions below

1
On BEST ANSWER

Let $\Pi$ be the plane containing $A$ normal to $N$. Let $L$ be the line passing through $B,C$.

$$\Pi=\{x\in \mathbb{R}^3|(x-A)\cdot N=0\}$$ $$L=\{tB+(1-t)C|t\in \mathbb{R}\}$$

So, the intersection is a point $P=tB+(1-t)C$ satisfying the equation, i.e.

$$(tB+(1-t)C-A)\cdot N=0$$ $$t(B-C)\cdot N+(C-A)\cdot N=0$$ $$t=\frac{(A-C)\cdot N}{(B-C)\cdot N}$$ so the intersection in question is $$P=\frac{(A-C)\cdot N}{(B-C)\cdot N}B+\frac{(B-A)\cdot N}{(B-C)\cdot N}C$$ ... that is, unless $(B-C)\cdot N=0$, i.e. if $L$ is parallel to $\Pi$.