Converting TriRep to DelaunayTri while using pointLocation?
2 views (last 30 days)
Show older comments
hi, I have a TriRep object with triangulations and I want to use pointLocation on the object to find whether the points are inside the triangles. But the pointLocation is a method defined for DelaunayTri class which is a subclass of TriRep. So I would like to ask if TriRep object can be converted to DelaunayTri to be used in pointLocation?
0 Comments
Answers (1)
Divyam
on 8 Oct 2024
The "DelaunayTri " object can be created using the extracted points from the "TriRep" object. As of MATLAB R2024b, "DelaunayTri " class is not recommended for usage and it's preferable to use the "delaunayTriangulation" class instead.
% Assume T is your TriRep object
T = TriRep([1, 2, 3; 1, 3, 4], [0, 0; 1, 0; 0, 1; 1, 1]);
% Extract the points
points = T.X;
% Create a DelaunayTri object
delaunayTriObj = DelaunayTri(points);
% Define points to check
P = [0.5, 0.5; 0.75, 0.75; 0.25, 0.25];
% Use pointLocation to find the triangles containing the points
triangleIndices = pointLocation(delaunayTriObj, P);
% Display the results
fprintf('Triangle indices for the query points: [%s]\n', join(string(triangleIndices),','));
For more information regarding the "delaunayTriangulation" class, refer to the following documentation: https://www.mathworks.com/help/matlab/ref/delaunaytriangulation.html
0 Comments
See Also
Categories
Find more on Industrial Statistics 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!