Based on my understanding you want to discretize the boundary of a polygon into equally spaced points.
To achieve this, you can refer to the following steps:
1. After defining the polygon, extract its vertices and calculate the Euclidean distances between consecutive vertices.You can use the function 'cumsum' to get the cumulative distances along the boundary.
xb = (pgon1.Vertices(:,1))';
yb = (pgon1.Vertices(:,2))';
distances = [0; cumsum(sqrt(diff(xb).^2 + diff(yb).^2))];
2. Choose the number of equally spaced points and use `linspace` to generate target distances along the perimeter.
equalSpacedDistances = linspace(0, distances(end), numPoints);
3. Then apply `interp1` to interpolate the x and y coordinates at these distances, yielding points uniformly distributed along the boundary.
xEqualSpaced = interp1(distances, xb, equalSpacedDistances);
yEqualSpaced = interp1(distances, yb, equalSpacedDistances);
You can refer to the attached output for a better understanding:
To learn more about 'cumsum' and 'interp1' functions in MATLAB, please refer to the following links:
Happy Coding!