-1

I'm looking for a method to determine whether a ray collides with triangle and distance to the collision point in 3D.

a method like the code below or something similar

float GetCollisionsoint(Vector3 RayPosition, Vector3 RayDirection, Vector3 a1, Vector3 a2, Vector3 a3)
    { 
    }

thanks in advance!

oh and if you now want to vote me down, please comment on why so I know what I'm doing wrong.

Johan Polson
  • 117
  • 3
  • 12

2 Answers2

0

There's a pretty good write-up on the subject at http://www.lighthouse3d.com/tutorials/maths/ray-triangle-intersection/, along with some example code.

levis501
  • 4,117
  • 23
  • 25
0

Dan Sunday presents an algorithm and a reference implementation. If the triangle's normal and u,v vectors are precomputed, the algorithm reduces to inner (dot) products. If the precomputed u,v,n are normalized, there are further optimizations: i.e., <u,u> = <v,v> = 1.

Brett Hale
  • 21,653
  • 2
  • 61
  • 90