I want to find opposing triangle pairs in triangulated objects like shown in the example picture. The example data is attached with variables F and V for faces and vertices.
The interesting areas are marked in the pictures.
The requirements for a match of my choice would be:
- distance of triangles lower than threshold, e.g. 3mm
- triangles should be close to parallel. This could be set by a threshold of the "degree of parallelism". However a good measurement could be defined.
- "correct" spatial orientation would be great, but is a bonus.
How I started:
- calculate center of gravity of all triagles
- calculate each of the distances (pdist2)
- remove triangle pairs with too high distances
- calculate normal vectors of remaining triangles
- check "parallelism" of triangles by dot product of normal vectors (dot product >0.9)
- remove adjacent triangle pairs that are "parallel" according to above definition
This is not very robust and leads to following issue:
- second neighbors are still found (neighbors of the adjacent triangles)
Is there a smart way to remove 2nd or 3rd neighbors or neighbors in general (neighborhood matrix/tree?!?)
Is there in general a smarter and more robust way to do that? It seems I ran into a direction where I have to exclude a lot of undesired cases....
Any help is welcome :-)