Skip to main content
GameDev.net gamedev.net
🔒 Locked

Line intersecting a face

Started by Mariusz Pilipczuk Jun 28, 2012 at 5:31 PM 1 replies 2.6k views
Original Post
Mariusz Pilipczuk
Mariusz Pilipczuk
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.
RubyNL
RubyNL
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).
NDIR
NDIR
Do a simple ray-plane intersection test. Then in case of intersection, test if that point lies within your polygon.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.