On Sunday 08 July 2007 23:12, Scott Johnson wrote: > Hi Everyone! > > This may seem like a basic question, but in the interest of time, I am > going to ask it anyway rather than struggle with it. > > All of the sideness tests I have seen in 2D (i.e. the Area() function in > triangulate.cpp in libcrystalspace, which is essentially a copy of > AreaSide() in > http://orion.math.iastate.edu/burkardt/c_src/orourke/tri.c) uses a > matrix determinant to find whether a point is on one side or another of > a line, (essentially uses cross products). The problem I have is that > these are all assuming that the planes in which the vectors lie are > parallel to the XY plane. That is, the Z component can essentially be > disregarded. Of course, when I take cross products of 3D vectors, I > obtain another 3D vector. This happens in 2D of course, but there is a > matrix which can be used to obtain a determinant telling the side on > which a point lies, given a vector. > > Now, my question is this: Given two vectors (three points), we know they > are all coplanar, so is there a way to utilize a matrix determinant > trick similar to in 2D which will give us the side of the line the point > lies on (i.e. negative or positive - it doesn't really mean 'right' or > 'left', as these don't have meanings in arbitrary 3-dimesions). > > My initial intuition was to determine the angle the vector makes with > the XY plane, in X and Y dimensions, then rotate all points by this, to > ensure that we are parallel to the XY plane, then utilize the same > method. Would this be too much work? I am wondering if I am > overthinking the problem. > > Any suggestions would be helpful. Thanks!
I'm not aware of that determinant-trick of your's - AFAIK, the sign of the determinant tells you if the coordinate system orientation will stay the same when a matrix is applied on a vector. But I do know a trick where the sign of the scalar product of a point P with a normal of a plane is used. In two-D, a plane is a line. If a plane is given by two vectors O(rigin) and N(ormal), the sideness of a P(oint) is computed as this: h = scalar_product(P-O, N) if(h > 0) return 1 if(h < 0) return -1 return 0 This is the same for both 2D and 3D. Diez ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Crystal-main mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/crystal-main Unsubscribe: mailto:[EMAIL PROTECTED]
