• Create Account

## Line intersecting a face

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

174
Like
0Likes
Like

Posted 28 June 2012 - 11:31 AM

Hello.

I am creating a game and I am currently working on collision detection. My problem is the following:

If I have a 2D face (in 3D space) with num_vertices vertices, and an array of vertices named "vertices", how would I check if a line crosses through this face?

All help appreciated.

Edited by Madd, 28 June 2012 - 11:31 AM.

### #2RubyNL  Members

154
Like
0Likes
Like

Posted 28 June 2012 - 12:32 PM

Hmm, good question. This is the easiest to do with triangles, I think.
I done a little raytracing a long while ago, and this question came up when I was trying to build a little engine. I've forgot the specifics of the implementation, but don't worry, there is plenty of information out there. For example here and here.

If you want to do this for arbitrary polygons you may want to triangulate them first, but again, I forgot the specifics, so I'll leave it up to you to do some research. A little linear algebra skills may come in handy if you want to understand what's going on (or even try to find a way yourself).

### #3NDIR  Members

179
Like
1Likes
Like

Posted 28 June 2012 - 01:01 PM

Do a simple ray-plane intersection test. Then in case of intersection, test if that point lies within your polygon.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.