Archived

This topic is now archived and is closed to further replies.

How can I tell if a vector intersects a plane?

This topic is 6347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know this is more of a maths question but it does relate to 3D graphics: If I have a 3D vector which goes infinitely in one direction how can I work out if that vector intersects with a plane and at what point on that plane (in 3D coordinates) it collides? Regards, Paulcoz.

Share this post


Link to post
Share on other sites
I think you mean a line, not a vector, because a vector always has finite length.

If v is the direction vector of the line and n is the normal of the plane, there''s only an intersection if v*a != 0.

line equation:
x = A.x + t*v.x
y = A.y + t*v.y
z = A.z + t*v.z

plane equation:

a*x + b*y + c*z + d = 0

Substitute x, y and z in the plane equation with x, y and z of the line equations and calculate t. Then calculate x, y and z in the line equation with t.

GA

Share this post


Link to post
Share on other sites
How do you find the intersection between a line and a plane bounded
by 4 vertices at its corners (i.e. not infinite) ?

Share this post


Link to post
Share on other sites
Ok here is a really simple explanation but youll have to figure out putting it in

BEGIN: CALC

Intermediate value theorem (?):

If F(x) is continuous (no holes, asymptotes, etc.) and if X1
Hope it helps you some, probally not :]

Share this post


Link to post
Share on other sites
Ok here is a really simple explanation but youll have to figure out putting it in

BEGIN: CALC

Intermediate value theorem (?):

If F(x) is continuous (no holes, asymptotes, etc.) and if X1
Argh, it purged my message

Hope it helps you some, probally not :]

Share this post


Link to post
Share on other sites
Ok here is a really simple explanation but youll have to figure out putting it in

BEGIN: CALC

Intermediate value theorem (?):

If F(x) is continuous (no holes, asymptotes, etc.) and if
X1 < c < X2
,where X1 and X2 are values for F(x), then a point must exist between X1 and X2 where F(x)==c.
Basically, if the beginning and end of the vector are not both larger/smaller than the respective values (X and Y, whichever you test first) of the plane.
So if the vector is pointing down, then check the beginning and end of it against the Y of the plane.
If the Y value falls in between the two points, then check your x also. If not, then you can just kick it out.
Be sure to check for == so as to deal with the vector being on plane.

I can''t put in less than signs? Whats going on here?
Argh, it purged my message

Hope it helps you some, probally not :]

Share this post


Link to post
Share on other sites
Let me restate my question with an example:

Given a vector pointing down toward some quad-generated terrain, let''s
say from your camera position which is travelling over it, and given that
you have pre-calculated the normals for all your planes, how would you
find what specific terrain quad (defined by 4 vertices) you happen to
be over at the moment?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Wayfarer, I do not know any 3D math, but as a general programming / problem solving rule I''d break your problem down like this:

1. Find the point at which the vector intersects the plane (paulcoz''s original problem - but you might be able to take advantage of the fact that you know for sure that an intersection occurs, and even a little about such an intersection due to the fact that your vector will always be pointing ''down'' at the terrain.)

2. Find out which terrain quad contains the intersection point. (this will use the same techniques used in just about any above-view, side-view, or isometric-view 2D game - depending on the nature of you terrain mapping it might be as simple as a few division operations).

Best of luck.

Share this post


Link to post
Share on other sites
Wayfarer, I do not know any 3D math, but as a general programming / problem solving rule I''d break your problem down like this:

1. Find the point at which the vector intersects the plane (paulcoz''s original problem - but you might be able to take advantage of the fact that you know for sure that an intersection occurs, and even a little about such an intersection due to the fact that your vector will always be pointing ''down'' at the terrain.)

2. Find out which terrain quad contains the intersection point. (this will use the same techniques used in just about any above-view, side-view, or isometric-view 2D game - depending on the nature of you terrain mapping it might be as simple as a few division operations).

Best of luck.

It seems to be thinking I''m an anonymous poster ... I am Xai if you have any further questions

Share this post


Link to post
Share on other sites
I can find the line-plane intersection condition easily enough as discussed
above. But, I also need to satisfy the condition that the point be bounded
within the 4 vertices of the quad as well.

I was thinking of a couple of possible solutions, but all untested. After
I got the point on the plane, I could find the min-max values of all 4 vertices
of the quad and test them against the point. But I really don''t know if this
is a good idea that works every time.

What I was really hoping for is a equation that I could plug my point values
in to test for this bounded condition.

Share this post


Link to post
Share on other sites
I found something even better. Solved everything.

http://www.flipcode.com/tpractice/issue02.shtml

Share this post


Link to post
Share on other sites