title: Find whether two triangles intersect or not
body: <p>Given 2 set of points </p>
  
  <p>((x1,y1,z1),(x2,y2,z2),(x3,y3,z3))      and </p>
  
  <p>((p1,q1,r1),(p2,q2,r2),(p3,q3,r3)) each forming a triangle in 3D space.</p>
  
  <p>How will you find out whether these triangles intersect or not?</p>
  
  <p>One obvious solution to this problem is to find the equation of the plane formed by each triangle. If the planes are parallel, then they don't intersect.</p>
  
  <p>Else, find out the equation of line formed by the intersection of these planes using the normal vectors of these planes.</p>
  
  <p>Now, if this line lies in both of the triangular regions, then these two triangles intersect, otherwise not.</p>
  
  <pre><code>trianglesIntersect(Triangle T1, Triangle T2)
  {
     if(trianglesOnParallelPlanes(T1, T2))
     {
        return false
     }
     Line L1 = lineFromPlanes(planeFromTriangle(T1), planeFromTriangle(T2))
     if(lineOnTriangle(T1, L1) AND lineOnTriangle(T2, L1))
     {
        return true
     }
     return false
  }
  </code></pre>
  
  <p>Given that I know how to write the above functions, what other implementations of trianglesIntersect should I consider?</p>
  
  <p>Are there faster algorithms that solve this problem?</p>