The Möller-Trumbore algorithm
With a working solver for validation, we can move on to more advanced algorithms. The Möller-Trumbore algorithm was introduced in a 2005-paper titled "Fast, minimum storage ray/triangle intersection" [1], and is based on transforming the problem into barycentric coordinates. As previously discussed, the interserction point in barycentric coordinates is, when fully expanded
From the relation in Eq.(7) we see that this can be rewritten
which can be reorganized into
If we now insert the explicit expression for the ray, we find
which may be rearranged into
where \(u_1\), \(u_2\) and \(a_*\) are unknown, forming a system of coupled equations:
Since the elements in the first row-vector on the left are vectors, this is a \(3 \times 3\) matrix. Realizing this, we may simplify once more to a matrix-vector product
which can be solved using any standard solver (preferably not by inversion) to find:
In their original paper [1], Möller and Trumbore solve this system using Cramers rule [2]. We have followed the same procedure, i.e. by defining \(\mathbf{v}_{ij} = (\mathbf{x}_{i}-\mathbf{x}_{j})\), whereby we finally compute
As the note in the paper [1], it is possible to define intermediates in the above to speed up the calculation.
Sources
[1] Möller, T., & Trumbore, B. (2005). Fast, minimum storage ray/triangle intersection. In ACM SIGGRAPH 2005 Courses (pp. 7-es).
[2] https://en.wikipedia.org/wiki/Cramer%27s_rule