From: Daniel J S. <dan...@ie...> - 2010-12-12 18:11:31
|
Alexandre Felipe wrote: > "I had reached the conclusion that implementing the rendering by determining > intersections of surfaces pretty much as defined might be the best place to > put effort." - Daniel J Sebald > > > Find all the triangle pairs for wich the nearest vertex of firstis nearer > than the farthest of the vertexes of the second triangle, and the farthest > vertex of first is farther than the nearest of the vertexes of the second > triangle. > > these are the ones who may need to be splited. > > then take the planes containing the two triangles, intersect them, it can > result an line (say Li), or a null intersection, in case of being a line, > find all the intersections of Li with the triangles edges. > it must be in the following sequence > > enter triangle 1, exit triangle 1 > enter triangle 2, exit triangle 2 > > in all other cases, the triangles are splited in the line Li > > After proceeding in this way you can use any criteria to sort the triangles, > i think this is the minimal algorithm, it takes about 1 days to be coded ant > two or three to get working :D Yes, that is the main idea. But this is a two week project, I believe. The number of cases balloons when going from 2D to 3D. First, one has to represent the triangles as planes (a hyperplane is always convenient). There is some linear algebra associated with computing that. Those would have to be saved with the triangle representations. Then there is determining the line of interestection (probably an easy matrix inversion). But there is the possibility of a singular matrix, which probably corresponds to the two planes being parallel. So, one computes the line of intersection of the plane, then there is still the issue determining exactly where the intersection is in terms of the original triangles. There is complete coverage, partial coverage, triangle broken into two pieces, etc. And when the split occurs, a four sided polygon could result, which means that four sided polygon would have to be represented as two triangles. It's easy envisioning how it would work, but doing it nicely is another issue. Not something to embark on without a good plan and mathematical representation of the problem. > I have a C++ 3D geometry class. but it uses overloaded operators > (everywhere), with this class I am able to implement, i think, what i > described above. if one want to translate the C++ to C and compile it i can > spend some time for writing it, and send yet this week. It would need proper licensing if it is a completed work. Theory of operation is just as good. Dan |