.. highlightlang:: us .. _poly_poly_clip: poly_poly_clip ============== .. index:: poly_poly_clip .. us.tag poly_poly_clip NOTREADYENGLISH base_graph New363 :ref:`poly_poly_clip` calculates the intersections between a polygon (open polygon) and a data hull (closed polygon). .. function:: = poly_poly_clip(nOpt, clip, poly) .. us.return **Return Value** *rmXY*, *idx*: *rmXY* is a matrix with two columns. The first column contains the x-coordinates and the second column the y-coordinates of the result polygon. *idx* is an index vector with the end points of the polygons (see example). .. us.params **Parameters** .. uparam:: nOpt *nOpt* specifies what result should be computed. *nOpt* can be one of the following values: .. list-table:: :header-rows: 1 * - Value - Meaning * - 0 - union (hull containing both polygons). * - 1 - difference (part of the subject polygon that is inside the clip hull). * - 2 - difference (part of the subject polygon that is inside the clip hull). * - 3 - hull without subject polygon. .. uparam:: clip *clip* are the x/y-coordinates of the clip polygon. The coordinates must be given as a complex vector (x + 1i*y) (see example). .. uparam:: poly *poly* are the x/y-coordinates of the subject polygon. The coordinates must be given as a complex vector (x + 1i*y) (see example). .. us.example **Example** .. image:: S:/uniplot-obj/images/poly_poly_clip.* :: def test(option) { xhull = [1, 1, 2, 2, 1]; yhull = [1, 2, 2, 1, 1]; nh = len(xhull) h = plot(xhull,yhull) xp = [1.3, 1.3, 1.6, 1.6, 1.3]; yp = [0.3, 2.6, 2.6, 0.3, 0.3]; = poly_poly_clip(option, xhull[1:nh] + 1i * yhull[1:nh], xp + 1i*yp); if (len(idx) == 1 && idx[1] == 0) { return TRUE; } nPoly = len(idx); if (len(xy) > 1) { idx = [0;idx]; for (i in 2:nPoly+1) { h = plot(xy[idx[i-1]+1:idx[i]; 1], xy[idx[i-1]+1:idx[i];2], h[2]); } } return xy; } .. seealso:: :ref:`poly_line_clip`, :ref:`poly_hull` :sub:`id-1848134`