Bug in triangulation pointLocation calculations?

1 visualizzazione (ultimi 30 giorni)
Wick
Wick il 9 Ago 2022
Commentato: nightflight il 12 Ott 2022
I have a snippet of code that is a simplifcation of a problem I've found using the pointLocation feature of MATLAB's triangulation. I believe this to be a numerical bug but am hesitant to submit it as such until I've verified its behavior across multiples platforms. I've reproduced errors with this script on the PC on versions 2018a & 2021b and a different error set on the Mac version 2022a.
Here's the example code, I'll explain what it is and what I would expect after.
clearvars
DemoXY = [0 0;1 0;0.7 -1; 0.6 1]; % Four XY points
DemoConn = [1 2 3; 1 2 4]; % Connectivitiy List
DemoTri = triangulation(DemoConn,DemoXY); % Define Triangulation
DemoIdx = DemoTri.pointLocation(0.5,0) % Find a point on the shared edge
TestXYGrid = [171.0 126.9; 170.7 127.0; 170.4 127.0; 170.3 127.2];
TestConn = [1 2 3; 2 3 4];
for Scale = [1 1+eps]
TestTri = triangulation(TestConn,Scale*TestXYGrid);
TestIdx = TestTri.pointLocation(170.42*Scale, 127*Scale)
end
I'm repeating the same process twice using variables starting with 'Demo' and 'Test.' In each case, I create a 4-point XY convex hull that I triangulate manually. This creates one shared edge between triangles.
I then use the pointLocation operation on the triangulation to determine which triangle contains a point along the shared edge. Either triangle ID would be valid. In the Demo portion of the code, a real value is returned for DemoIdx for all versions and platforms tested. This demonstrates that pointLocation is capable of assigning a point along a shared edge to one triangle within the triangulation.
For the Test portion, when Scale is 1, I get a NaN for TestIdx on all versions tested. The point is within the convex hull so one expects a real value.
On the PC versions 2018a & 2021b, when Scale is not equal to unity (as in the code when it's set to 1+eps) the operation returns a real number (but 2, 3 and 4 also fail, e.g.). On the Mac 2022a version, TestIdx continues to return NaN for values of Scale set to 1, 1+eps, and 10 even though the PC versions returned real values for the second and third.
As I don't have access to the PC version of 2022a I cannot extensively test this. So if someone can repeat my test and let me know if this is a numerical bug I can properly submit it as such.
  1 Commento
nightflight
nightflight il 12 Ott 2022
I get NaNs on both iterations of the loop on R2020b Update 3 on Windows. It's very frustrating.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Delaunay Triangulation in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by