selecting a triangle in an array of delaunay points
2 views (last 30 days)
The code explains it all.
Try to run it, it might give you a good result, but that would be random.
This code is supposed to display a point, and color the nearest triangle green. It does not do this, and gives "nan" errors on seemingly random iterations of the loop.
I would appreciate some help :)
P = [ 2.5 8.0
%abs vals x
%abs vals y
random_x=a + (b-a).*rand(1);
random_y=c + (d-c).*rand(1);
triangleId=pointLocation(dt, random_x,random_y) %select the triangle ID of the triangle closest to the point generated by the random generator
scatter(random_x,random_y) %display the points
%%now... the part that does not work
%%selecting the right triangle and turning it a different color
tri = dt(triangleId, [1:end 1]);
patch(P(tri,1), P(tri,2), 'r', 'LineWidth',1, 'FaceColor','g')