Write an algorithm (Java-like pseudocode) that will calculate the point of
intersection of a ray (semi segment) and a triangle. The method should return
the status of the intersection (intersect or not, and, if not, why not ). If
it intersects, then the method should also return the coordinates of the intersection.
Use comments in your code to explain the algorithm.
The ray is defined by the origin point O and the direction vector V.
The triangle is defined by the 3 vertices P0, P1, P2.
Tip : if vertices A, B, C and D are on the same plane and if D = A + sAB +
tAC then D is inside triangle ABC if and only if s>=0, t>=0 and s+t <=
First compute the intersection point M between the ray and the plane of
Then compute s and t such as M = P0 + sP0P1 + tP0P2
Considering that M is inside the triangle if and only if s
>= 0, t >= 0 and s+t <= 1 draw your conclusion