• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1123

# Ray-Plane Collision

I've got a Light source L (a vector) and a vertex V (a vector also). I then have a ray originating at the light source, and passing through the vertex.

Therefore, my ray is defined as:

r = L + t (V - L)

(Where (V-L) is normalised).

I now need to find at what point this ray hits a plane...

However, I'm not sure how to do this. My first problem is how I should define the plane, and then secondly, is how to actually locate the point of collision..

Any suggestions?

Thanks.
0
InteractiveMind
• 6
• 5
• 2
3 Solutions

Commented:
A plane can be defined by two vectors if you like (both in the plane, and eg. perpendicular to one another), or by one vector (perpendicular to the plane), or by three points (in the plane, and not on one line), or ...

your ray is defined by (in 3D) :

r = L + t (V - L)

p = P0 + u(P1 - P0) + v(P2 - P0)

with P0, P1 and P2 the three points that define the plane (not on one line !).

To find where the ray "cuts" the plane :

L + t (V - L) = P0 + u(P1 - P0) + v(P2 - P0)

This can be easily solved for unknowns t, u and v ...
0

Author Commented:
3 unkowns, and 1 equation?
0

Commented:
This is a vector equation, so there are seperate eqations for the x, y, and z-components.
0

Author Commented:
Oh yeah. Cheers.

I'll have a go at solving it.

:)
0

Author Commented:
Uh oh..
is there gonna be any easier way of doing this, than Gaussian Elimination?
0

Commented:
Not in general, unless the points defining the plane and vector are well chosen. Strive to get 0's in the equations, so you can eliminate terms.

Choose the reference axes well !!
0

Commented:
Yes:    http://astronomy.swin.edu.au/~pbourke/geometry/planeline/

Look up line-plane intersections.  There are one-step projection methods for all of the alternate expressions of a plane.
0

Commented:
And btw, since you only want to find the point of intersection, you just need to find t :

R = L + t (V - L)

So :

Lx + t (Vx - Lx) = P0x + u(P1x - P0x) + v(P2x - P0x)                         (1)
Ly + t (Vy - Ly) = P0y + u(P1y - P0y) + v(P2y - P0y)                         (2)
Lz + t (Vz - Lz) = P0z + u(P1z - P0z) + v(P2z - P0z)                         (3)

express u an v as a function of t using (2) and (3), and replace those in (1), to get something of the form :

t = ...

which you easily use in :

R = L + t (V - L)

to get the point of intersection.

If you want to use it in software, this is easier than performing Gauss elimination each time. Just construct a general formula for R using the above method, and fill in the correct values to get R from then on.
0

Commented:
>> Yes:    http://astronomy.swin.edu.au/~pbourke/geometry/planeline/
Nice page ... solution 2 on that page is similar to the one I presented in my last post ... so you might want to just copy that :)
0

Author Commented:
Okay, cool.

For this definition of a plane:

A x + B y + C z + D = 0

How could I find the values of A, B, C, and D, given two adjacement lines that lie on the plane?
0

Commented:
A x + B y + C z + D = 0

is actually :

N * (R - p) = 0

with N the normal vector (perpendicular to the plane), R is (x,y,z), and p a point in the plane.

So, all you have to do is take one point of one of the lines defining the plane and use it as p. Next calculate the normal vector to the plane (see further), and substitute in the above equation.

How to calculate the normal vector ? take three points (P1, P2 and P3) that are in the plane (not on one line), and then this is the normal :

N = (P1 - P2) x (P3 - P2)

Note that x is the cross product between two vectors, defined like this :

A x B = <Ay*Bz - Az*By, Az*Bx - Ax*Bz, Ax*By - Ay*Bx>
0

Commented:
In case you don't know, the cross product of two vectors will return a vector perpendicular to both of the two vectors.
0

Author Commented:
Thanks guys; that's all working nicely now :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.