# Calculate intersection of a line with a plane

I was reading something about: “Intersection of a line with a plane”. But I don’t fully understand how to calculate it on their way.

The goal is to calculate where the plane and the line will “cross”. These items are given:

• The eye is in position: O(0,0,-10)
• A point of a 3D-object is P(10,20,30)
• The screen has the equation z=0

I have a questions about how they calculate this:

This part is clear. That is the location form the eye (vector representation).

They specify the location of the plane, there is nothing strange here (vector representation).

Now they calculate what part of the line will cross, how did they calculate this? How did they know a = 1/4? And b = 10/4?

This is everything that was given.

-
This SO answer might help. – Anko Feb 5 '13 at 10:20

linear systems of N variables can be solved if you have N equations.

``````x = 10ɑ
y = 20ɑ
z = -10 + 40ɑ
x = β
y = 2β + μ
z = 0
``````

6 equations, 6 unknowns. You can solve for all 6. In fact, generally you can just combine the x/y/z parts and say

``````10ɑ = β
20ɑ = 2β + μ
-10 + 40ɑ = 0
``````

and get 3-variable system in ɑ,β,μ. Once you get a value for ɑ, you can plug back in to Pintersection = PlineEye + ɑ * PlineDirection to get x,y, and z.

-

It's easier to think of this using vector maths.

The plane equation is `N.P = -D` for all points on the plane.

Therefore, the intersection point must satisfy this. If our point P is defined by the line equation `P = P0 + tQ` (where `Q` is the line's direction and t is the distance along the line) we can sub this in:

``````N.(P0 + tQ) = -D
``````

The dot product is bilinear:

``````t(N.Q) + (N.P0) = -D
``````

rearrange for `t`:

``````t(N.Q) = -D - N.P0
t = (-D - N.P0)/N.Q
``````

and then plug your `t` back in to the line equation to get the crossing point.

From this we can intuitively read a couple of simple properties:

If the line's direction and the plane's normal are perpendicular there is no crossing. `N.Q` is zero, which would be a divide by zero.

`-D - N.P0` describes how 'far' `P0` is from the plane in the direction of the plane's normal. N.Q then describes the ratio between the direction of the plane and the direction of the line - the more parallel the direction and normal, the faster it will intersect.

-