Please confirm if the "polyshape" function is used in the default way or not.
If it is used in a default way, it tries to detect and fix intersections, remove collinear points, remove overlapping points, etc.
After the release of MATLAB R2018b, there is a new name/value pair for polyshape(), "KeepCollinearPoints"=true/false, for the keeping the collinear points purpose. By default 'KeepCollinearPoints' is set to false.
If you want to keep the collinear points then you can set 'KeepCollinearPoints' to true.
As of MATLAB R2018a, the reason for the "polyshape" function to delete half the total number of vertices in the input when there are no duplicate points or intersections is most likely as the input vertices contain collinear points.
Regarding the other query, if there is a way to set an absolute threshold distance so that the function can treat the close points as duplicates, currently, there is no such threshold value.
However, as a workaround, you can call the "polyshape" function with a name/value pair, as follows:
>> p2 = polyshape(points(path,1), points(path,2), 'simplify', false);
This will keep all the input points without simplifying it, as follows:
p2 =
polyshape with properties:
Vertices: [142×2 double]
NumRegions: 1
NumHoles: 0
You can use the "simplify" function, "p3 = simplify(p2)", later if you need to simplify the input data. Please note that "p3" will be the same as polygon in the script.
Best Answer