This function performs boolean operations between two polygons using the Greiner-Hormann algorithm (http://davis.wpi.edu/~matt/courses/clipping/).
sub is a two column matrix containing the X and Y coordinates of the vertices for the subject polygon (it must be unique, although self-intersections are permitted).
clip is a two column matrix containing the X and Y coordinates of the vertices for the clipper polygon(it must be unique, although self-intersections are permitted).
op is a text string containing the operation to perform between sub and clip. Possible values are:
hor is an identifier for performing (value 1) or not (value 0) the searching for holes in the result of the operation OR. When OR is applied with non convex entities some of the resulting polygons can be actually holes. Activating this argument the possible holes are identified. If the operation is other than OR the value of this argument is irrelevant
For the matrices sub and clip, the first point is not needed to be repeated at the end (but is permitted). Pairs of (NaN,NaN) coordinates in sub and/or clip are omitted, so they are treated as if each one stored a single polygon, i.e., this function does not admit boolean operations between multiple polygons of between polygons with holes, although polygons containing self-intersections are permitted
The output arguments are:
p is a two column matrix containing the X and Y coordinates of the vertices of the resultant polygon(s). If the result consist of multiple polygons they are separated by rows os (NaN,NaN) values.
pp is a three-column matrix with a number of rows equal to the number of polygons stored in the matrix p. The first column stores the row of p where the corresponding polygon starts, the second column the row of p where the polygon end, and the third colum is a mark identifying if the polygon is a hole (value 0) or not (value 1). The values of the third column are relevant only in the case of the OR operation
ni is the number of intersections between sub and clip.
np is the number of perturbed points of the clip polygon if any particular case (points in the border of the other polygon) occurs see http://davis.wpi.edu/~matt/courses/clipping/ for details.
This function do not check if the dimensions of sub and clip are correct.
Package: octclip