Tracing back centroids to the triangle (incenter)

조회 수: 8(최근 30일)
Pelajar UM
Pelajar UM 2022년 4월 23일
편집: Pelajar UM 2022년 4월 23일
Let's say we have a triangular mesh defined as
TR = triangulation (F,P);
where F is Nx3 and represents the faces while P is Nx3 and represents 3D coordinates.
We then use the following line to get the centroid of each triangle:
centroid = incenter(TR);
Next we find the nearest pairs of centroids:
[Idx] =knnsearch (centroid,centroid,'K',2, 'Distance',"euclidean");
And get the coordinates of the second nearest centroid (first one is the original centroid itself):
centroid2 = centroid(Idx (:,2),:);
Now I want to go back and check which triangles, centroid and centroid2 correspond to in TR.
Why do I need this? Because I want to:
1) Check if the two triangles are parallel but not in the same plane
2) If not, search for K=3 and so on
3) If yes, project the centroid onto the parallel triangle and see if it is within that triangle
4) If not, go back to step 2
5) If yes, return the distance,



Find more on Triangulation Representation in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by