title: How to do Ray and Triangle Edge intersect?
body: <p>I'm facing problem intersecting ray with triangle edges. Actually, I'm trying to pick/intersect with triangle, vertex, edge of a mesh using Mouse. So I made ray from the Mouse current position and then I intersect it with the mesh elements like triangle/polygon, vertex, edge etc to work with it. Basically, 3d modeling stuffs. Intersecting with triangle was easy and fun. And the vertex part was tricky. </p>
  
  <p>But now, I don't know how to intersect/pick with triangle edges. I mean how I treat them when intersecting with the Mouse Ray? First I thought they can be treated like a 3D line. But eventually failed to do the Ray and the Line intersect. Searched on the Internet but not found any helpful info. Although I found some open source projects are using OpenGL built-in picking features to pick/intersect with Edge. But in my case, I can't use that. :(</p>
  
  <p>My current edge picking code structure looks like the following:</p>
  
  <pre><code>void pickEdge(Ray ray, Scene scene)
  {
      for each object in scene
      {
          mesh = getMesh(object)
          for each triangle in mesh
          {
              for each edge in triangle
              {
                  v1 = getV1(edge)
                  v2 = getV2(edge)
  
                  // Do intersect with 'ray' and 'v1', 'v2'. But how?
              }
          }
      }
  }
  </code></pre>
  
  <p>So I'm stuck here and really need some help. Any idea, algorithm or a small help is greatly appreciated. </p>