Input multiple region for polyshape

Hi community,
I want to read XYZ coordinates from a txt file that contains points that represent the bounday of more that one polygon and make it available as an input for the polyshape function.
In other words I want to detect how many closed polygons are inside that txt file and add a NaN line when a polygon is closed. In that case I will have the coordinates of the regions delimited by a NaN row that is suitable to input for polyshape function.
Can please anyone help me?

Answers (1)

Matt J
Matt J on 12 Dec 2023
Edited: Matt J on 12 Dec 2023
There is no unique way to divide a series of points into closed polygons. If you haven't inserted the NaNs already, the intended result is ambiguous.

1 Comment

To illustrate Matt J's point, consider the following five points.
x = [-1 0 1 1 -1];
y = [-1 0 -1 1 1];
plot(x, y, 'o')
axis square
axis([-1.5 1.5 -1.5 1.5])
Should that region be split into four triangles, a kind of claw shape and a triangle (and if so, which three of the four triangles should be used to draw the claw?), or two hourglasses?

Sign in to comment.

Categories

Tags

Asked:

on 12 Dec 2023

Commented:

on 12 Dec 2023

Community Treasure Hunt

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

Start Hunting!