Re: [Algorithms] decompose onto non-orthogonal vectors
Brought to you by:
vexxed72
From: <ro...@do...> - 2000-07-15 19:12:19
|
Reprise: In the 3D case: If you are certain that p lies in the plane spanned by a and b, then Peter Dimov's solution is the best. (assuming you understand dot products and 2x2 linear systems). And, in fact, that is exactly what I use in my code to find the intersection of a ray with a triangle with given vertices V0, V1, V2: First find the intersection P of the ray with the plane of the triangle. Refer everything, i.e. the intersection point and two of the vertices, to any one vertex V0, so that, to cast it into Ben's notation, p = P - V0, a=V1-V0 and b=V2-V0, and we are certain that p lies in the plane through V0 spanned by a and b. Form the dot products as Peter indicates, and solve the resulting 2x2 system for u and v. The result V0 + ua + vb will lie in the triangle if and only if 0<=u, 0<=v and u+v<=1. But if you do not know a priori that p is a linear combination of a and b, then the only way to determine that (finding u and v in the process) is by Gaussian elimination on the underdetermined system as I described. Of course, you can organize the Gaussian elimination efficiently by thinking of it as row operations on the matrix of the system, rather than elementary operations on the equations. The matrix approach is simply a tabular organization of the manipulation of the equations themselves. |