In the engine, Ray and quad are used to calculate the intersection, but the algorithm is not detailed, but there are quadratic equations to be solved.
Ray used a 97-year-old classical algorithm to work with triangle. After reading the paper carefully, I would like to thank Xiao Wu for his guidance and use the kramo rule to solve the linear equations.
I want to imitate this method, do the intersection of Ray and quad, and find that the equation contains not only U and V, but also UV, and cannot be transformed into the form of linear equations.
I thought that the four vertices in the quad engine could not be collocated and the interfaces were viewed. Otherwise, "the correct results are not guaranteed for non-Collocated and degraded polygon".
Then there are two other problems: first, is it faster to contact a quad with two triangles? Second, if the answer to the preceding question is no, that is, the two triangles are faster, why don't we use two triangles instead of one quad for intersection.
The first problem is that after rough calculation, quad is no longer faster than the two triangles (in the engine)
The second problem is that quad has an advantage in storage. First, the index value is stored. One quad is smaller than two triangles. Secondly, in mesh, one quad has four facevarying variables, there are six triangles.
For more information, see http://www.realtimerendering.com/intersections.html.
The Link contains plane, but not detailed enough.
Compared with quad, a direct method is to first obtain the intersection with the surface, and 6 times of multiplication to N and 6 times of multiplication to obtain the parameter T. Then, obtain the intersection P (three multiplications) and determine whether P is inside quad. The initial use is linear. Then we can find the UV value that requires intersection, inverse bilinear interpolation (the keyword that Xiao Wu thinks), and find the method Merge (similar to the engine described above ), however, there are currently no two solutions. (Number of multiplication times to be counted)
Finally, we will consider the UV value of the triangle above. barycentric coordinates is given in this paper, in the past, we came to the conclusion that the UV value of a triangle is essentially the UV value of a degraded Quadrilateral (a side of V from 0 to 1 degrades to a vertex). Can barycentric coordinates be converted to it?
After verification and reading the analysis code, it is found that the triangle intersection algorithm converts barycentric coordinates into a degraded quadrilateral UV value. Conversion Method: U = u + V, V = u/(U + V ).