Connecting points to polygon

6 vues (au cours des 30 derniers jours)
Debora Baumann
Debora Baumann le 13 Jan 2024
Commenté : Debora Baumann le 20 Jan 2024
Hi,
i'm currently struggling with following issue: I have a table geometry_points_outline which stores the outline of a geometry as point coordinates x and y. the geometry consists of three seperate polygons. I'm able to connect the points with the following code section:
for i = 1:height(geometry_points_outline)
nearestPoints = nearestIndices(i, :);
plot([geometry_points_outline.xCoordinates(i), geometry_points_outline.xCoordinates(nearestPoints(2))], ...
[geometry_points_outline.yCoordinates(i), geometry_points_outline.yCoordinates(nearestPoints(2))], 'k-', 'LineWidth', 2);
plot([geometry_points_outline.xCoordinates(i), geometry_points_outline.xCoordinates(nearestPoints(3))], ...
[geometry_points_outline.yCoordinates(i), geometry_points_outline.yCoordinates(nearestPoints(3))], 'k-', 'LineWidth', 2);
end
I have another table which stores regular space grid points. Now i want to do two things:
  1. filling the space between the lines so the geometry is represented clearly.
  2. Find the points of the grid which lie between these lines and and delete them from the grid table.
I tried various things, including drawing a polygon manually or selecting the points manually, but the have not been successful. Do you have any idea how to solve this issue?
I attached both tables as csv files.
Thanks for your help!

Réponse acceptée

Matt J
Matt J le 13 Jan 2024
Modifié(e) : Matt J le 13 Jan 2024
Your code can't be run because nearestIndices is not provided.
Regardless, I would recommend using polyshape to represent and plot the polygons. Likewise isinterior can be used to assess whether points lie inside the polygons.
  20 commentaires
Matt J
Matt J le 19 Jan 2024
Modifié(e) : Matt J le 19 Jan 2024
Here's an altenative implementation of mkpshape, which uses this FEX download,
It seems to work quite well.
function p=mkpshape(x,y,G)
%Trace the boundary of the given points and convert to polyshapes
x=x(G); y=y(G);
pth = tspsearch([x,y],5);
p=polyshape(x(pth),y(pth),'Simplify',0);
end
Also, you need to fix the computation of G3,
G3=XY1*L2 > 0;
Debora Baumann
Debora Baumann le 20 Jan 2024
Amazing, thanks for your effort!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by