Calculate if two 3D triangles are on the same plane

一世执手 提交于 2019-12-05 17:37:06

Why do you want to do that? What is the number of triangle you expect to test? It seems a little bit complex for a real time rendering algorithm!

Anyway:

Compute the normal n of the triangle. Then compute the plane equation: a.x + b.y + c.z + d = 0 with (a,b,c) being your triangle normal and d = - dot(n,P) (P is one of your triangle vertex). Do the same for the second triangle.

The two planes are the same if the four valuesabcd are equals or opposite (all together).

What you are asking is impossible numerically. Roundoff errors will make such a test completely irrelevant.

However, you may want to test "if two triangles are on the same plane, within some tolerance". This is very difficult to do, and here too, roundoff errors will likely mess up any method possible. Indeed, whenever the triangles are thin, there is a great incertitude about the plane on which they live.

I could point you to some litterature if you really want (your best bet would be to look at the CGAL library and see if they implemented something relevant to your problem). Anything will likely involves arbitrary precision floating points, clever reordering of operations, and will anyway lead to unprecise results.

I thus strongly suggest you find another approach for your actual problem.

Roundoff errors are a (huge) problem if you try to compute the equation of the plane passing through three points and then testing the three other ones. There is another solution.

You may want to compute the inertia matrix of your six points, diagonalize it and see if its smallest eigenvalue is within some tiny value of the two other ones. This will imply that your six points actually lie on the same plane, within a tolerance.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!