Line intersecting a face

Started by
1 comment, last by NDIR 11 years, 9 months ago
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.
Advertisement
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).
Do a simple ray-plane intersection test. Then in case of intersection, test if that point lies within your polygon.

This topic is closed to new replies.

Advertisement