# How do I compute the point of a triangle-ray intersection?

I have a line (the direction vector of the player) and a triangle representing the face of a model (so composed of 3 points).

I can't find the mathematical operation to check if that vector is intersecting with this triangle, and how far from the player...

• Have you Googled "ray triangle intersection"? Ray will likely get more hits than vector, and there are lots of articles and sample code out there.
– Will
Jan 21, 2014 at 14:37
• realtimerendering.com/intersections.html has a bunch of intersection tests. Jan 27, 2014 at 9:13

In general, lines are a poor approximation of a user's movement because they don't account for the size of the player.

You want "sweep sphere triangle intersection", also called "capsule triangle intersection". http://xania.org/Games has a good overview of this.

• "lines are a poor approximation of a user's movement" -- unless the player is well-approximated by a point. (While this is helpful, it doesn't answer the question.)
– Anko
Jan 21, 2014 at 15:06
• @Anko kind of true, but on the other hand, cameras are not well approximated by a point if you want to avoid front plane clipping glitches; if you're doing true 3D movement in a 3D world, you end up having to do approximate something bigger than a point eventually.
– Will
Jan 21, 2014 at 19:02
• Good point -- I was neglecting the third dimension.
– Anko
Jan 23, 2014 at 4:01