grains.cad.region_as_polygon¶
-
grains.cad.region_as_polygon(branches, orientation='ccw', close='False')[source]¶ Represents a region as a polygon.
Based on the combined topological-geometrical (intermediate) representation of the regions, (done by
skeleton2regions()), this function provides a fully geometrical description of a region.- Parameters
branches (list) – Each element of the list gives N>=2 points on the branch, ordered from one end point to the other. If N=2, the two end points are meant. The points are provided as an Nx2 ndarray, the first column giving the x, the second column giving the y coordinates of the points. The branches are not necessarily ordered.
orientation ({‘cw’, ‘ccw’}, optional) – Clockwise (‘cw’) or counterclockwise (‘ccw’) orientation of the polygons. The default is ‘ccw’.
close (bool, optional) – When True, one vertex in the polygons is repeated to indicate that the polygons are indeed closed. The default is False.
- Returns
polygon (ndarray) – The resulting polygon, given as an Mx2 ndarray, where M is the number of unique points on the polygon (i.e. only one end point is kept for two connecting branches).
See also