[Math] Find where 2 triangles intersect in 3d

geometry

I need to know when two triangles intersect in a 3D environment, given the 3 points. Any help appreciate have been stuck on this for a long time, ive been told
"Step one. Get the equations of the planes containing the triangles.
Step two. Compute the line of intersection of these planes.
Step three. Find the points of intersection of this line with each of these triangles. If either miss you are done, since the triangles can't overlap.
Step four. These intersection points define a pair of intervals (one for each triangle). If the intervals overlap, the triangles overlap along this overlap interval. Otherwise they do not overlap."

I can do step one, and half of step two and three, I took the cross product of the normals to get the direction of line of intersection but don't know how to find another point on it.

Best Answer

If you have the equations of the planes in Cartesian form, to find the line of intersection you have to solve them simultaneously. First eliminate any one of the letters $x$, $y$ or $z$. Then, from the single equation that remains, separate the letters on opposite sides of the equation and make both sides equal to a parameter, $\lambda$, say. Now all you need to do is get each of $x$, $y$ and $z$ in terms of $\lambda$, whereupon you have the equation of the line of intersection of the planes.