Draw polygon around grid points
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michiel Smit
el 6 de Abr. de 2022
Comentada: Michiel Smit
el 8 de Abr. de 2022
Dear reader,
I want to draw polygon around a set of grid points. For clarity I have added a figure below
I need to draw a polygon around the edges of the smaller red dots in such a way that the larger orange dots are within the polygon. Preferably, all angles of the polygon are 90 degrees. So basically the polygon with the minimum surface area to include all orange points, if that makes sense
My question is whether this is possible, and if so, how to do this?
Many thanks in advance!
2 comentarios
Respuesta aceptada
Matt J
el 7 de Abr. de 2022
Editada: Matt J
el 7 de Abr. de 2022
small_dots = [2.1250 52.6250
2.1250 52.8750
2.1250 53.1250
2.3750 52.3750
2.3750 52.6250
2.3750 52.8750
2.3750 53.1250
2.6250 52.3750
2.6250 52.6250
2.6250 52.8750
2.6250 53.1250
2.6250 53.3750
2.8750 52.3750
2.8750 52.6250
2.8750 52.8750
2.8750 53.1250
2.8750 53.3750
3.1250 52.3750
3.1250 52.6250
3.1250 52.8750
3.1250 53.1250
3.3750 52.3750
3.3750 52.6250
3.3750 52.8750
3.3750 53.1250
3.6250 52.3750
3.6250 52.6250
3.6250 52.8750
3.8750 52.3750
3.8750 52.6250
3.8750 52.8750
4.1250 52.3750
4.1250 52.6250
4.1250 52.8750];
large_dots = [2.2500 53.0000
2.2500 52.7500
2.5000 53.0000
2.5000 52.7500
2.5000 52.5000
2.7500 53.2500
2.7500 53.0000
2.7500 52.7500
3.0000 53.0000
3.0000 52.7500
3.0000 52.5000
3.2500 53.0000
3.2500 52.7500
3.2500 52.5000
3.5000 52.7500
3.5000 52.5000
3.7500 52.7500
3.7500 52.5000
4.0000 52.7500
4.0000 52.5000];
alldots= [small_dots;large_dots];
shp=alphaShape(alldots,0.13);
[~,V]=boundaryFacets(shp);
shp=polyshape(V,'Simplify',false);
plot(alldots(:,1),alldots(:,2),'o');
hold on; shp.plot; hold off; axis equal
Más respuestas (0)
Ver también
Categorías
Más información sobre Elementary Polygons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!