Intersection between Segment and Plane

398 Views Asked by At

I have to calculate the point of intersection between a segment and a plane.

The segment is defined by the two points $S_1=(x_1, y_1, z_1)$ and $S_2=(x_2, y_2, z_2)$.

The plane is defined by a point $P=(x_p, y_p, z_p)$ and by the normal $n=(n_1, n_2, n_3)$.

Important: I am also interested in knowing if the intersection point falls between S1 and S2 or if it falls in another point of the line passing through these points.

1

There are 1 best solutions below

1
On BEST ANSWER

The key to solving this problem is parametrising the line segment first, for example as $$S = S_1 + t (S_2 - S_1)$$ so that at $t = 0$, $S = S_1$, and at $t = 1$, $S = S_2$.

Also remember that point $S$ is on the plane with normal $n$ and signed distance $d$ (in units of normal length) from origin, if and only if $$S \cdot n = d$$ Since point $P$ is on the plane, $P \cdot n = d$.

Therefore, the line extending the segment intersects the plane when $$S \cdot n = P \cdot n$$ If you work it out, you'll arrive at a single possible solution, $$t = \frac{n \cdot (P - S_1)}{n \cdot (S_2 - S_1)}$$ There is no solution, when the segment is perpendicular to the plane normal (i.e., segment is parallel to the plane).

If and only if $0 \le t \le 1$, does the segment intersect the plane, at $S$.

If $t \lt 0$, the intersection occurs on the line before $S_1$.
If $t \gt 1$, the intersection occurs on the line after $S_2$.