# doc-cache created by Octave 5.1.0
# name: cache
# type: cell
# rows: 3
# columns: 84
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
Contents


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9500
 POLYGONS Manipulation of planar polygons and polylines
 Version 1.24 07-Jun-2018 .

   The 'polygons' module contains functions operating on shapes composed
   of a vertex list, like polygons or polylines.

   We call 'polyline' the curve defined by a series of vertices.
   A polyline can be either closed or open, depending on whether the last
   vertex is connected to the first one or not. This can be given as an
   option is some functions in the module.
   A 'polygon' is the planar domain delimited by a closed polyline. We
   sometimes want to consider 'complex polygons', whose boundary is
   composed of several disjoint domains. The domain defined by a single
   closed polyline is called 'simple polygon'.
   We call 'curve' a polyline with many vertices, such that the polyline
   can be considered as a discrete approximation of a "real" curve.

   A simple polygon or polyline is represented by a N-by-2 array, each row
   of the array representing the coordinates of a vertex. 
   Simple polygons are assumed to be closed, so there is no need to repeat
   the first vertex at the end. 
   As both polygons and polylines can be represented by a list of vertex
   coordinates, some functions also consider the vertex list itself. Such
   functions are prefixed by 'pointSet'. Also, many functions prefixed by
   'polygon' or 'polyline' works also on the other type of shape.

   For multiple-connected polygons, the different connected boundaries are
   separated by a row [NaN NaN].

   For some functions, the orientation of the polygon can be relevant: CCW
   stands for 'Conter-Clockwise' (positive orientation), CW stands for
   'Clockwise'.

   Polylines are parametrized in the following way:
   * the i-th vertex is located at position i-1
   * points of the i-th edge have positions ranging linearly from i-1 to i
   The parametrization domain for an open polyline is from 0 to Nv-1, and
   from 0 to Nv for a closed polyline (positions 0 and Nv correspond to
   the same point).

   Example:
   % Simple polygon:
   P1 = [1 1;2 1;2 2;1 2];
   drawPolygon(P1);
   axis([0 5 0 5]);
   % Multiple polygon:
   P2 = [10 10;40 10;40 40;10 40;NaN NaN;20 20;20 30;30 30;30 20];
   figure;drawPolygon(P2); axis([0 50 0 50]);


 Polylines
   polylinePoint             - Extract a point from a polyline.
   polylineLength            - Return length of a polyline given as a list of points.
   polylineCentroid          - Compute centroid of a curve defined by a series of points.
   polylineSubcurve          - Extract a portion of a polyline.
   resamplePolyline          - Distribute N points equally spaced on a polyline.
   resamplePolylineByLength  - Resample a polyline with a fixed sampling step.
   reversePolyline           - Reverse a polyline, by iterating vertices from the end.
   isPointOnPolyline         - Test if a point belongs to a polyline.
   projPointOnPolyline       - Compute position of a point projected on a polyline.
   distancePointPolyline     - Compute shortest distance between a point and a polyline.
   distancePolylines         - Compute the shortest distance between 2 polylines.
   intersectLinePolyline     - Intersection points between a line and a polyline.
   intersectPolylines        - Find the common points between 2 polylines.
   clipPolyline              - Clip an open polyline with a rectangular box.
   polylineSelfIntersections - Find self-intersection points of a polyline.
   simplifyPolyline          - Douglas-Peucker simplification of a polyline.
   smoothPolyline            - Smooth a polyline using local averaging.
   removeMultipleVertices    - Remove multiple vertices of a polygon or polyline.

 Polygon basic manipulation
   reversePolygon            - Reverse a polygon, by iterating vertices from the end.
   smoothPolygon             - Smooth a polygon using local averaging.
   simplifyPolygon           - Douglas-Peucker simplification of a polygon.
   projPointOnPolygon        - Compute position of a point projected on a polygon.
   splitPolygons             - Convert a NaN separated polygon list to a cell array of polygons.
   polygonLoops              - Divide a possibly self-intersecting polygon into a set of simple loops.
   polygonPoint              - Extract a point from a polygon.
   polygonSubcurve           - Extract a portion of a polygon.
   polygonEdges              - Return the edges of a simple or multiple polygon.
   polygonVertices           - Extract all vertices of a (multi-)polygon.

 Polygon clipping and intersections
   intersectLinePolygon      - Intersection points between a line and a polygon.
   intersectRayPolygon       - Intersection points between a ray and a polygon.
   intersectEdgePolygon      - Intersection point of an edge with a polygon.
   polygonSelfIntersections  - Find self-intersection points of a polygon.
   clipPolygon               - Clip a polygon with a rectangular box.
   clipPolygonHP             - Clip a polygon with a Half-plane defined by a directed line.

 Point Sets
   pointSetsAverage          - Compute the average of several point sets.
   minimumCaliperDiameter    - Minimum caliper diameter of a set of points.
   findPoint                 - Find index of a point in an set from its coordinates.
   convexHull                - Convex hull of a set of points.
   randomPointInPolygon      - Generate random point(s) in a polygon.

 Measures on Polygons
   isPointInPolygon          - Test if a point is located inside a polygon.
   polygonContains           - Test if a point is contained in a multiply connected polygon.
   polygonCentroid           - Compute the centroid (center of mass) of a polygon.
   polygonArea               - Compute the signed area of a polygon.
   polygonEquivalentEllipse  - Compute equivalent ellipse with same second order moments as polygon.
   polygonSecondAreaMoments  - Compute second-order area moments of a polygon.
   polygonLength             - Perimeter of a polygon.
   polygonNormalAngle        - Compute the normal angle at a vertex of the polygon.
   polygonBounds             - Compute the bounding box of a polygon.
   polygonOuterNormal        - Outer normal vector for a given vertex(ices).
   distancePointPolygon      - Shortest distance between a point and a polygon.
   distancePolygons          - Compute the shortest distance between 2 polygons.
   distancePolygonsNoCross   - Compute the shortest distance between 2 polygons.
   polygonSignature          - Polar signature of a polygon (polar distance to origin).
   signatureToPolygon        - Reconstruct a polygon from its polar signature.
   polygonCurvature          - Estimate curvature on polygon vertices using polynomial fit.

 More complex operations on polygons
   resamplePolygon           - Distribute N points equally spaced on a polygon.
   resamplePolygonByLength   - Resample a polygon with a fixed sampling step.
   densifyPolygon            - Add several points on each edge of the polygon.
   expandPolygon             - Expand a polygon by a given (signed) distance.
   triangulatePolygon        - Compute a triangulation of the polygon.
   polygonSymmetryAxis       - Try to identify symmetry axis of polygon.
   medialAxisConvex          - Compute medial axis of a convex polygon.

 Curves (polylines with lot of vertices)
   parametrize               - Parametrization of a polyline, based on edges lengths.
   curvature                 - Estimate curvature of a polyline defined by points.
   cart2geod                 - Convert cartesian coordinates to geodesic coord.
   geod2cart                 - Convert geodesic coordinates to cartesian coord.
   curveMoment               - Compute inertia moment of a 2D curve.
   curveCMoment              - Compute centered inertia moment of a 2D curve.
   curveCSMoment             - Compute centered scaled moment of a 2D curve.

 Functions from stochastic geometry
   steinerPoint              - Compute steiner point (weighted centroid) of a polygon.
   steinerPolygon            - Create a Steiner polygon from a set of vectors.
   supportFunction           - Compute support function of a polygon.
   convexification           - Compute the convexification of a polygon.

 Input, Output and conversions
   polygonToRow              - Convert polygon coordinates to a row vector.
   rowToPolygon              - Create a polygon from a row vector.
   contourMatrixToPolylines  - Converts a contour matrix array into a polyline set.
   readPolygonSet            - Read a set of simple polygons stored in a file.
   writePolygonSet           - Write a set of simple polygons into a file.

 Drawing functions
   drawPolyline              - Draw a polyline specified by a list of points.
   drawPolygon               - Draw a polygon specified by a list of points.
   fillPolygon               - Fill a polygon specified by a list of points.
   drawVertices              - Draw the vertices of a polygon or polyline.


   Credits:
   * function intersectPolylines uses the 'interX' contribution from "NS"
       (file exchange 22441, called 'curve-intersections')

 -----
 Author: David Legland
 e-mail: david.legland@inra.fr
 created the  07/11/2005.
 Project homepage: http://github.com/mattools/matGeom
 http://www.pfl-cepia.inra.fr/index.php?page=geom2d
 Copyright INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 POLYGONS Manipulation of planar polygons and polylines
 Version 1.24 07-Jun...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
cart2geod


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 672
CART2GEOD Convert cartesian coordinates to geodesic coord.

   PT2 = cart2geod(PT1, CURVE)
   PT1 is the point to transform, in Cartesian coordinates (same system
   used for the curve).
   CURVE is a N-by-2 array which represents coordinates of curve vertices.

   The function first compute the projection of PT1 on the curve. Then,
   the first geodesic coordinate is the length of the curve to the
   projected point, and the second geodesic coordinate is the 
   distance between PT1 and it projection.


   TODO : add processing of points not projected on the curve.
   -> use the closest end 

   See also
   polylines2d, geod2cart, curveLength




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
CART2GEOD Convert cartesian coordinates to geodesic coord.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
clipPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 390
CLIPPOLYGON Clip a polygon with a rectangular box.

   POLY2 = clipPolygon(POLY, BOX);
   POLY is N-by-2 array of points
   BOX has the form: [XMIN XMAX YMIN YMAX].
   Returns the polygon created by the intersection of the polygon POLY and
   the bounding box BOX.

   Note: Works only for convex polygons at the moment.

   See also:
     polygons2d, boxes2d, clipPolygonHP, clipPolyline




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 50
CLIPPOLYGON Clip a polygon with a rectangular box.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
clipPolygonHP


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 456
CLIPPOLYGONHP Clip a polygon with a Half-plane defined by a directed line.

   POLY2 = clipPolygonHP(POLY, LINE)
   POLY is a [Nx2] array of points, and LINE is given as [x0 y0 dx dy].
   The result POLY2 is also an array of points, sometimes smaller than
   poly, and that can be [0x2] (empty polygon).

   See also:
   polygons2d, clipPolygon

 ---------
 author : David Legland 
 created the 31/07/2005.
 Copyright 2010 INRA - Cepia Software Platform.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 74
CLIPPOLYGONHP Clip a polygon with a Half-plane defined by a directed line.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
clipPolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 744
CLIPPOLYLINE Clip an open polyline with a rectangular box.

   POLY2 = clipPolyline(POLY, BOX);
   POLY is N-by-2 array of vertex coordinates.
   BOX has the form: [XMIN XMAX YMIN YMAX].
   Returns the set of polylines created by the intersection of the
   polyline POLY and the bounding box BOX. The result is a cell array with
   as many cells as the number of curve clips.


   Example
     circle = [5 5 6];
     poly = circleToPolygon(circle, 200);
     box = [0 10 0 10];
     res = clipPolyline(poly, box);
     figure;
     hold on; axis equal; axis([-2 12 -2 12]);
     drawCircle(circle, 'b:')
     drawBox(box, 'k')
     drawPolyline(res, 'linewidth', 2, 'color', 'b')
 
   See also:
     polygons2d, boxes2d, clipPolygon, clipEdge




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
CLIPPOLYLINE Clip an open polyline with a rectangular box.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
contourMatrixToPolylines


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 493
CONTOURMATRIXTOPOLYLINES Converts a contour matrix array into a polyline set.

   POLYS = contourMatrixToPolylines(C)
   Converts the contour matrix array, as given as the result of the
   contourc function, into a set of polylines.

   Example
     img = imread('circles.png');
     C = contourc(img, 1);
     polys = contourMatrixToPolylines(C);
     imshow(img); hold on;
     drawPolyline(polys, 'Color', 'r', 'LineWidth', 2);

   See also
     polygons2d, contour, contourc



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 77
CONTOURMATRIXTOPOLYLINES Converts a contour matrix array into a polyline set.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
convexHull


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1156
CONVEXHULL Convex hull of a set of points.

   POLY = convexHull(POINTS)
   Computes the convex hull of the set of points POINTS. This function is
   mainly a wrapper to the convhull function, that format the result to a
   polygon.

   [POLY, INDS] = convexHull(POINTS)
   Also returns the indices of convex hull vertices within the original
   array of points.

   ... = convexHull(POINTS, 'simplify', BOOL)
   specifies the 'simplify' option use dfor calling convhull. By default,
   the convexHull functions uses simplify equals to TRUE (contrary to the
   convhull function), resulting in a more simple convex polygon.
   
   
   Example
     % Draws the convex hull of a set of random points
     pts = rand(30,2);
     drawPoint(pts, '.');
     hull = convexHull(pts);
     hold on; 
     drawPolygon(hull);

     % Draws the convex hull of a paper hen
     x = [0 10 20  0 -10 -20 -10 -10  0];
     y = [0  0 10 10  20  10  10  0 -10];
     poly = [x' y'];
     hull = convexHull(poly);
     figure; drawPolygon(poly);
     hold on; axis equal;
     drawPolygon(hull, 'm');

   See also
   polygons2d, convhull




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42
CONVEXHULL Convex hull of a set of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
convexification


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 725
CONVEXIFICATION Compute the convexification of a polygon.

   CO = convexification(H)
   Creates convexification from support function. Support function is
   supposed to be uniformly distributed over [0 2pi].

   CO = convexification(POLYGON)
   Computes support function of the polygon, then the corresponding
   convexification.

   CO = convexification(POLYGON, N)
   Uses N points for convexification computation. Note that the number of
   points of CO can be lower than N.
   
   CAUTION: The result will be valid only for convex polygons.

   See also
   polygons2d, supportFunction 

 ---------
 author: David Legland 
 created the 12/01/2005.
 Copyright 2010 INRA - Cepia Software Platform.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 57
CONVEXIFICATION Compute the convexification of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
curvature


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1043
CURVATURE Estimate curvature of a polyline defined by points.

   KAPPA = curvature(T, PX, PY, METHOD, DEGREE)
   First compute an approximation of the curve given by PX and PY, with
   the parametrization T. METHOD used for approximation can be only:
   'polynom', with specified degree
   Further methods will be provided in a future version.
   T, PX, and PY are N*1 array of the same length.
   Then compute the curvature of approximated curve for each point.

   For example:
   KAPPA = curvature(t, px, py, 'polynom', 6)

   KAPPA = curvature(T, POINTS, METHOD, DEGREE)
   specify curve as a suite of points. POINTS is size [N*2].

   KAPPA = curvature(PX, PY, METHOD, DEGREE)
   KAPPA = curvature(POINTS, METHOD, DEGREE)
   compute implicite normalization of the curve, based on euclidian
   distance between 2 consecutive points, and normalized between 0 and 1.


   See Also:
   polygons2d, parametrize

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 07/04/2003.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 61
CURVATURE Estimate curvature of a polyline defined by points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
curveCMoment


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 563
CURVECMOMENT  Compute centered inertia moment of a 2D curve.
   M = curveCMoment(CURVE, P, Q)

   Example
   curveCMoment

   See also
   polygons2d, curveMoment, curveCSMoment

   Reference
   Based on ideas and references in:
   "Affine curve moment invariants for shape recognition"
   Dongmin Zhao and Jie Chen
   Pattern Recognition, 1997, vol. 30, pp. 865-901


 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-03-25,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 60
CURVECMOMENT  Compute centered inertia moment of a 2D curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
curveCSMoment


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 562
CURVECSMOMENT  Compute centered scaled moment of a 2D curve.
   M = curveCSMoment(CURVE, P, Q)

   Example
   curveCSMoment

   See also
   polygons2d, curveMoment, curveCMoment

   Reference
   Based on ideas and references in:
   "Affine curve moment invariants for shape recognition"
   Dongmin Zhao and Jie Chen
   Pattern Recognition, 1997, vol. 30, pp. 865-901

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-03-25,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 60
CURVECSMOMENT  Compute centered scaled moment of a 2D curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
curveMoment


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 552
CURVEMOMENT  Compute inertia moment of a 2D curve.
   M = curveMoment(CURVE, P, Q)

   Example
   curveMoment

   See also
   polygons2d, curveCMoment, curveCSMoment

   Reference
   Based on ideas and references in:
   "Affine curve moment invariants for shape recognition"
   Dongmin Zhao and Jie Chen
   Pattern Recognition, 1997, vol. 30, pp. 865-901


 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-03-25,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 50
CURVEMOMENT  Compute inertia moment of a 2D curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
densifyPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 819
DENSIFYPOLYGON Add several points on each edge of the polygon.

   POLY2 = densifyPolygon(POLY, N)
   POLY is a NV-by-2 array containing polygon coordinates. The function
   iterates on polygon edges, divides it into N subedges (by inserting N-1
   new vertices on each edges), and return the resulting polygon.
   The new polygon POLY has therefore N*NV vertices.

   Example
     % Densifies a simple polygon
     poly = [0 0 ; 10 0;5 10;15 15;5 20;-5 10];
     poly2 = densifyPolygon(poly, 10);
     figure; drawPolygon(poly); axis equal
     hold on; drawPoint(poly2);

   See also
     drawPolygon, edgeToPolyline


 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2011-11-25,    using Matlab 7.9.0.529 (R2009b)
 Copyright 2011 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 62
DENSIFYPOLYGON Add several points on each edge of the polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
distancePointPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 692
DISTANCEPOINTPOLYGON Shortest distance between a point and a polygon.

   DIST = distancePointPolygon(POINT, POLYGON)
   Computes the shortest distance between the point POINT and the polygon
   given by POLYGON. POINT is a 1-by-2 row vector, and POLYGON is a N-by-2
   array containing vertex coordinates.
   The distance is computed as the minimal distance to the boundary edges.

   Example
     % Computes the distance between a point and a square
     square = [0 0; 10 0;10 10;0 10];
     p0 = [16 3];
     distancePointPolygon(p0, square)
     ans =
          6

   See also
   polygons2d, points2d, distancePointPolyline, distancePointEdge,
   projPointOnPolyline




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 69
DISTANCEPOINTPOLYGON Shortest distance between a point and a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
distancePointPolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1276
DISTANCEPOINTPOLYLINE  Compute shortest distance between a point and a polyline.

   DIST = distancePointPolyline(POINT, POLYLINE)
   Returns the shortest distance between a point given as a 1-by-2 row
   vector, and a polyline given as a NV-by-2 array of coordinates.

   If POINT is a NP-by-2 array, the result DIST is a NP-by-1 array,
   containig the distance of each point to the polyline.

   [DIST, POS] = distancePointPolyline(POINT, POLYLINE)
   Also returns the relative position of the point projected on the
   polyline, between 0 and NV, the number of polyline vertices.

   ... = distancePointPolyline(POINT, POLYLINE, CLOSED)
   Specifies if the polyline is closed or not. CLOSED can be one of:
   * 'closed' -> the polyline is closed
   * 'open' -> the polyline is open
     a column vector of logical with the same number of elements as the
       number of points -> specify individually if each polyline is
       closed (true=closed).


   Example:
       pt1 = [30 20];
       pt2 = [30 5];
       poly = [10 10;50 10;50 50;10 50];
       distancePointPolyline([pt1;pt2], poly)
       ans =
           10
            5

   See also
   polygons2d, points2d
   distancePointEdge, distancePointPolygon, projPointOnPolyline




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
DISTANCEPOINTPOLYLINE  Compute shortest distance between a point and a polyli...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
distancePolygons


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 761
DISTANCEPOLYGONS Compute the shortest distance between 2 polygons.

   DIST = distancePolygons(POLY1, POLY2)
   Computes the shortest distance between the boundaries of the two
   polygons. Each polygon is given by a N-by-2 array containing the vertex
   coordinates.

   In the case the two polygons are known not to intersect, the function
   'distancePolygonsNoCross' may be used more efficiently (no test for
   crossing is done).

   Example
     % Computes the distance between a square and a triangle
     poly1 = [10 10;20 10;20 20;10 20];
     poly2 = [30 20;50 20;40 45];
     distancePolygons(poly1, poly2)
     ans =
         10

   See also
   polygons2d, distancePolygonsNoCross, distancePolylines,
   distancePointPolygon 




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 66
DISTANCEPOLYGONS Compute the shortest distance between 2 polygons.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
distancePolygonsNoCross


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 779
DISTANCEPOLYGONSNOCROSS Compute the shortest distance between 2 polygons.

   DIST = distancePolygonsNoCross(POLY1, POLY2)
   Computes the shortest distance between the boundaries of the two
   polygons, assuming they do not cross. 
   Each polygon is given by a N-by-2 array containing the vertex
   coordinates.

   If the polygons may cross, it is necessary to use the
   'distancePolygons' function, that adds a potentially costly test on the
   intersection.

   Example
     % Computes the distance between a square and a triangle
     poly1 = [10 10;20 10;20 20;10 20];
     poly2 = [30 20;50 20;40 45];
     distancePolygons(poly1, poly2)
     ans =
         10

   See also
   polygons2d, distancePolygons, distancePolylines, distancePointPolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73
DISTANCEPOLYGONSNOCROSS Compute the shortest distance between 2 polygons.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
distancePolylines


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 276
DISTANCEPOLYLINES Compute the shortest distance between 2 polylines.

   DIST = distancePolylines(POLY1, POLY2)
   POLY1 and POLY2 should be two polylines represented by their list of
   vertices.


   See also
   polygons2d, distancePolygons, distancePointPolyline




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
DISTANCEPOLYLINES Compute the shortest distance between 2 polylines.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
drawPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1169
DRAWPOLYGON Draw a polygon specified by a list of points.

   drawPolygon(POLY);
   Packs coordinates in a single N-by-2 array, with N the vertex number.

   drawPolygon(PX, PY);
   Specifies coordinates in separate arrays. Both array must be N-by-1,
   with N the number of vertices.

   drawPolygon(POLYS)
   Packs coordinate of several polygons in a cell array. Each element of
   the array is a Ni-by-2 double array.

   drawPolygon(..., NAME, VALUE);
   Specifies drawing options by using one or several parameter name-value
   pairs, see the doc of plot function for details.

   drawPolygon(AX, ...)
   Specifies the axis to draw the polygon on.

   H = drawPolygon(...);
   Also return a handle to the list of line objects.

   Example
     % draw a red rectangle
     poly = [10 10;40 10;40 30;10 30];
     figure; drawPolygon(poly, 'r');
     axis equal; axis([0 50 0 50]); 

     % Draw two squares
     px = [10 20 20 10 NaN 30 40 40 30]';
     py = [10 10 20 20 NaN 10 10 20 20]';
     figure; 
     drawPolygon([px py], 'lineWidth', 2);
     axis equal; axis([0 50 0 50]); 
 
   See also:
   polygons2d, drawPolyline



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 57
DRAWPOLYGON Draw a polygon specified by a list of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
drawPolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1082
DRAWPOLYLINE Draw a polyline specified by a list of points.

   drawPolyline(COORD);
   packs coordinates in a single [N*2] array.

   drawPolyline(PX, PY);
   specifies coordinates in separate arrays. PX and PY must be column
   vectors with the same length.

   drawPolyline(..., TYPE);
   where TYPE is either 'closed' or 'open', specifies if last point must
   be connected to the first one ('closed') or not ('open').
   Default is 'open'.

   drawPolyline(..., PARAM, VALUE);
   specify plot options as described for plot command.

   H = drawPolyline(...) also return a handle to the list of line objects.

   Example:
   % Draw a curve representing an ellipse
   t = linspace(0, 2*pi, 100)';
   px = 10*cos(t); py = 5*sin(t);
   drawPolyline([px py], 'closed');
   axis equal;

   % The same, with different drawing options
   drawPolyline([px py], 'closed', 'lineWidth', 2, 'lineStyle', '--');

   See Also:
   polygons2d, drawPolygon

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 06/04/2004.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
DRAWPOLYLINE Draw a polyline specified by a list of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
drawVertices


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 604
DRAWVERTICES Draw the vertices of a polygon or polyline.

   drawVertices(POLY)
   Draws the vertices of the given polygon, using pre-defined style.
   Default is to draw vertices as squares, with the first vertex filled. 

   Example
     poly = circleToPolygon([20 30 40], 16);
     drawPolygon(poly); 
     hold on; axis equal;
     drawVertices(poly);

   See also
   drawPoint, drawPolygon, drawPolyline

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2011-12-11,    using Matlab 7.9.0.529 (R2009b)
 Copyright 2011 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 56
DRAWVERTICES Draw the vertices of a polygon or polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
expandPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1347
EXPANDPOLYGON Expand a polygon by a given (signed) distance.

   POLY2 = expandPolygon(POLY, DIST);
   Associates to each edge of the polygon POLY the parallel line located
   at distance DIST from the current edge, and compute intersections with
   neighbor parallel lines. The input polygon POLY must be oriented
   counter-clockwise. Otherwise, distance is computed inside the polygon.
   The resulting polygon is simplified to remove inner "loops", and can
   eventually be disconnected. 
   The result POLY2 is a cell array, each cell containing a simple linear
   ring. 
   
   This is a kind of dilation, but behaviour on corners is different.
   This function keeps angles of polygons, but there is no direct relation
   between the lengths of each polygon.

   It is also possible to specify negative distance, and get all points
   inside the polygon. If the polygon is convex, the result equals
   morphological erosion of polygon by a ball with radius equal to the
   given distance.

   Example:
   % Computes the negative offset of a non-convex polygon
     poly = [10 10;30 10;30 30;20 20;10 30];
     poly2 = expandPolygon(poly, -3);
     figure;
     drawPolygon(poly, 'linewidth', 2);
     hold on; drawPolygon(poly2, 'm')
     axis equal; axis([0 40 0 40]);

   See also:
   polygons2d, polygonLoops, polygonSelfIntersections 




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 60
EXPANDPOLYGON Expand a polygon by a given (signed) distance.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
fillPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 572
FILLPOLYGON Fill a polygon specified by a list of points.

   fillPolygon(POLY);
   Fills the interior of the polygon specified by POLY. The boundary of
   the polygon is not drawn, see 'drawPolygon' to do it.
   POLY is a single [N*2] array.
   If POLY contains NaN-couples, each portion between the [NaN;NaN] will
   be filled separately.

   fillPolygon(PX, PY);
   Specifies coordinates of the polygon in separate arrays.


   H = fillPolygon(...);
   Also returns a handle to the created patch


   See also:
     polygons2d, drawCurve, drawPolygon



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 57
FILLPOLYGON Fill a polygon specified by a list of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
findPoint


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 703
FINDPOINT Find index of a point in an set from its coordinates.
 
   IND = findPoint(POINT, ARRAY) 
   Returns the index of point whose coordinates match the 1-by-2 row array
   POINT in the N-by-2 array ARRAY. If the point is not found, returns 0.
   If several points are found, keep only the first one.

   If POINT is a M-by-2 array, the result is a M-by-1 array, containing
   the index in the array of each point given by COORD, or 0 if the point
   is not found.

   IND = findPoint(POINT, ARRAY, TOL) 
   use specified tolerance, to find point within a distance of TOL.
   Default tolerance is zero.

   See also
    points2d, minDistancePoints, distancePoints, findClosestPoint



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
FINDPOINT Find index of a point in an set from its coordinates.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
geod2cart


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 739
GEOD2CART Convert geodesic coordinates to cartesian coord.

   PT2 = geod2cart(PT1, CURVE, NORMAL)
   CURVE and NORMAL are both [N*2] array with the same length, and
   represent positions of the curve, and normal to each point.
   PT1 is the point to transform, in geodesic  coordinate (first coord is
   distance from the curve start, and second coord is distance between
   point and curve).

   The function return the coordinate of PT1 in the same coordinate system
   than for the curve.

   TODO : add processing of points not projected on the curve.
   -> use the closest end 

   See also
   polylines2d, cart2geod, curveLength

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 08/04/2004.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
GEOD2CART Convert geodesic coordinates to cartesian coord.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
intersectEdgePolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 833
INTERSECTEDGEPOLYGON  Intersection point of an edge with a polygon.

   INTER = intersectEdgePolygon(EDGE, POLY)
   Computes intersection(s) point(s) between the edge EDGE and the polygon
   POLY. EDGE is given by [x1 y1 x2 y2]. POLY is a N-by-2 array of vertex
   coordinates.
   INTER is a M-by-2 array containing coordinates of intersection(s). It
   can be empty if no intersection is found.

   [INTER, INDS] = intersectEdgePolygon(EDGE, POLY)
   Also returns index/indices of edge(s) involved in intersections.

   Example
   % Intersection of an edge with a square
     poly = [0 0;10 0;10 10;0 10];
     edge = [9 2 9+3*1 2+3*2];
     exp = [10 4];
     inter = intersectEdgePolygon(edge, poly)
     ans =
         10   4

   See also
   edges2d, polygons2d, intersectLinePolygon, intersectRayPolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 67
INTERSECTEDGEPOLYGON  Intersection point of an edge with a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
intersectLinePolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1872
INTERSECTLINEPOLYGON Intersection points between a line and a polygon.

   P = intersectLinePolygon(LINE, POLY)
   Returns the intersection points of the lines LINE with polygon POLY. 
   LINE is a 1-by-4 row vector containing parametric representation of the
   line (in the format [x0 y0 dx dy], see the function 'createLine' for
   details). 
   POLY is a NV-by-2 array containing coordinates of the polygon vertices
   P is a K-by-2 array containing the coordinates of the K intersection
   points.

   P = intersectLinePolygon(LINE, POLY, TOL)
   Specifies the tolerance for geometric tests. Default is 1e-14.

   [P, INDS] = intersectLinePolygon(...)
   Also returns the indices of edges involved in intersections. INDS is a
   K-by-1 column vector, such that P(i,:) corresponds to intersection of
   the line with the i-th edge of the polygon. If the intersection occurs
   at a polygon vertex, the index of only one of the two neighbor edges is
   returned. 
   Note that due to numerical approximations, the use of function
   'isPointOnEdge' may give results not consistent with this function.


   Examples
   % compute intersections between a square and an horizontal line
     poly = [0 0;10 0;10 10;0 10];
     line = [5 5 1 0];
     intersectLinePolygon(line, poly)
     ans =
           10     5
            0     5
     % also return indices of edges
     [inters, inds] = intersectLinePolygon(line, poly)
     inters =
           10     5
            0     5
     inds =
           4
           2
      
   % compute intersections between a square and a diagonal line
     poly = [0 0;10 0;10 10;0 10];
     line = [5 5 1 1];
     intersectLinePolygon(line, poly)
     ans =
            0     0
           10    10

   See Also
   lines2d, polygons2d, intersectLines, intersectRayPolygon, polygonEdges




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
INTERSECTLINEPOLYGON Intersection points between a line and a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
intersectLinePolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1814
INTERSECTLINEPOLYLINE Intersection points between a line and a polyline.

   P = intersectLinePolyline(LINE, POLY)
   Returns the intersection points of the lines LINE with polyline POLY. 
   LINE is a 1-by-4 row vector containing parametric representation of the
   line (in the format [x0 y0 dx dy], see the function 'createLine' for
   details). 
   POLY is a NV-by-2 array containing coordinates of the polyline vertices
   P is a K-by-2 array containing the coordinates of the K intersection
   points.

   P = intersectLinePolyline(LINE, POLY, TOL)
   Specifies the tolerance for geometric tests. Default is 1e-14.

   [P INDS] = intersectLinePolyline(...)
   Also returns the indices of edges involved in intersections. INDS is a
   K-by-1 column vector, such that P(i,:) corresponds to intersection of
   the line with the i-th edge of the polyline. If the intersection occurs
   at a polyline vertex, the index of only one of the two neighbor edges
   is returned. 
   Note that due to numerical approximations, the use of function
   'isPointOnEdge' may give results not consistent with this function.


   Examples
   % compute intersections between a square and an horizontal line
     poly = [0 0;10 0;10 10;0 10];
     line = [5 5 1 0];
     intersectLinePolyline(line, poly)
     ans =
           10     5
     % also return indices of edges
     [inters inds] = intersectLinePolyline(line, poly)
     inters =
           10     5
     inds =
           2
      
   % compute intersections between a square and a diagonal line
     poly = [0 0;10 0;10 10;0 10];
     line = [5 5 1 1];
     intersectLinePolyline(line, poly)
     ans =
            0     0
           10    10

   See Also
   lines2d, polylines2d, intersectLines, intersectLinePolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 72
INTERSECTLINEPOLYLINE Intersection points between a line and a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
intersectPolylines


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1090
INTERSECTPOLYLINES Find the common points between 2 polylines.

   INTERS = intersectPolylines(POLY1, POLY2)
   Returns the intersection points between two polylines. Each polyline is
   defined by a N-by-2 array representing coordinates of its vertices: 
   [X1 Y1 ; X2 Y2 ; ... ; XN YN]
   INTERS is a NP-by-2 array containing coordinates of intersection
   points.

   INTERS = intersectPolylines(POLY1)
   Compute self-intersections of the polyline.

   Example
   % Compute intersection points between 2 simple polylines
     poly1 = [20 10 ; 20 50 ; 60 50 ; 60 10];
     poly2 = [10 40 ; 30 40 ; 30 60 ; 50 60 ; 50 40 ; 70 40];
     pts = intersectPolylines(poly1, poly2);
     figure; hold on; 
     drawPolyline(poly1, 'b');
     drawPolyline(poly2, 'm');
     drawPoint(pts);
     axis([0 80 0 80]);

   This function is largely based on the 'interX' function, found on the
   FileExchange:
   https://fr.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections
   
   See also
   polygons2d, polylineSelfIntersections, intersectLinePolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 62
INTERSECTPOLYLINES Find the common points between 2 polylines.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
intersectRayPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 695
INTERSECTRAYPOLYGON Intersection points between a ray and a polygon.

   P = intersectRayPolygon(RAY, POLY)
   Returns the intersection points of the ray RAY with polygon POLY. 
   RAY is a 1x4 array containing parametric representation of the ray
   (in the form [x0 y0 dx dy], see createRay for details). 
   POLY is a Nx2 array containing coordinate of polygon vertices
   
   P = intersectRayPolygon(RAY, POLY, TOL)
   Specifies the tolerance for geometric tests. Default is 1e-14.

   [P IND] = intersectRayPolygon(...)
   Also returns index of polygon intersected edge(s). See
   intersectLinePolygon for details.

   See also
   rays2d, polygons2d, intersectLinePolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
INTERSECTRAYPOLYGON Intersection points between a ray and a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
isPointInPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 705
ISPOINTINPOLYGON Test if a point is located inside a polygon.

   B = isPointInPolygon(POINT, POLYGON)
   Returns true if the point is located within the given polygon.

   This function is simply a wrapper for the function inpolygon, to avoid
   decomposition of point and polygon coordinates.

   Example
     pt1 = [30 20];
     pt2 = [30 5];
     poly = [10 10;50 10;50 50;10 50];
     isPointInPolygon([pt1;pt2], poly)
     ans =
          1
          0

     poly = [0 0; 10 0;10 10;0 10;NaN NaN;3 3;3 7;7 7;7 3];
     pts = [5 1;5 4];
     isPointInPolygon(pts, poly);
     ans =
          1
          0


   See also
   points2d, polygons2d, inpolygon, isPointInTriangle



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 61
ISPOINTINPOLYGON Test if a point is located inside a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 17
isPointOnPolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 756
ISPOINTONPOLYLINE Test if a point belongs to a polyline.

   B = isPointOnPolyline(POINT, POLY)
   Returns TRUE of the point POINT belong to the polyline defined by the
   set of points in POLY.

   B = isPointOnPolyline(POINT, POLY, TOL)
   Specify the absolute tolerance for testing the distance between the
   point and the polyline.

   Example
       pt1 = [30 20];
       pt2 = [30 10];
       poly = [10 10;50 10;50 50;10 50];
       isPointOnPolyline([pt1;pt2], poly)
       ans =
            0
            1

   See also
   points2d, polygons2d

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-06-19,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 56
ISPOINTONPOLYLINE Test if a point belongs to a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
medialAxisConvex


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 972
MEDIALAXISCONVEX Compute medial axis of a convex polygon.

   [N, E] = medialAxisConvex(POLYGON);
   where POLYGON is given as a set of points [x1 y1;x2 y2 ...], returns
   the medial axis of the polygon as a graph.
   N is a set of nodes. The first elements of N are the vertices of the
   original polygon.
   E is a set of edges, containing indices of source and target nodes.
   Edges are sorted according to order of creation. Index of first vertex
   is lower than index of last vertex, i.e. edges always point to newly
   created nodes.

   Notes:
   - Is not fully implemented, need more development (usually crashes for
       polygons with more than 6-7 points...)
   - Works only for convex polygons.
   - Complexity is not optimal: this algorithm is O(n*log n), but linear
   algorithms exist.

   See also:
   polygons2d, bisector

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 07/07/2005.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 57
MEDIALAXISCONVEX Compute medial axis of a convex polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
minimumCaliperDiameter


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1105
MINIMUMCALIPERDIAMETER Minimum caliper diameter of a set of points.

   WIDTH = minimumCaliperDiameter(POINTS)
   Computes the minimum width of a set of points. As polygons and
   polylines are represented as point lists, this function works also for
   polygons and polylines.

   [WIDTH THETA] = minimumCaliperDiameter(POINTS)
   Also returns the direction of minimum width. The direction corresponds
   to the horizontal angle of the edge that minimizes the width. THETA is
   given in radians, between 0 and PI.


   Example
   % Compute minimal caliper diameter, and check coords of rotated points
   % have expected extent
     points = randn(30, 2);
     [width theta] = minimumCaliperDiameter(points);
     points2 = transformPoint(points, createRotation(-theta));
     diff = max(points2) - min(points2);
     abs(width - diff(2)) < 1e-10
     ans =
         1

   References
   Algorithms use rotating caliper. Implementation was based on that of
   Wikipedia:
   http://en.wikipedia.org/wiki/Rotating_calipers

   See also
   polygons2d, convexHull, orientedBox




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 67
MINIMUMCALIPERDIAMETER Minimum caliper diameter of a set of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
parametrize


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1005
PARAMETRIZE Parametrization of a polyline, based on edges lengths.

   PAR = parametrize(POLY);
   Returns a parametrization of the curve defined by the serie of points,
   based on euclidean distance between two consecutive points. 
   POLY is a N-by-2 array, representing coordinates of vertices. The
   result PAR is N-by-1, and contains the cumulative length of edges until
   corresponding vertex.

   PAR = parametrize(PX, PY);
   is the same, but specify points coordinates in separate column vectors.

   PAR = parametrize(..., 'normalize', 1);
   PAR = parametrize(..., 'normalize', true);
   Rescales the result such that the last element of PAR is 1.
 
   Example
     % Parametrize a circle approximation
     poly = circleToPolygon([0 0 1], 200);
     p = parametrize(poly);
     p(end)
     ans = 
         6.2829

   See also:
   polygons2d, polylineLength

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 06/04/2003.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 66
PARAMETRIZE Parametrization of a polyline, based on edges lengths.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
pointSetsAverage


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 553
POINTSETSAVERAGE Compute the average of several point sets.

   AVERAGESET = pointSetsAverage(POINTSETS)
   POINTSETS is a cell array containing several liste of points with the
   same number of points. The function compute the average coordinate of
   each vertex, and return the resulting average point set.

   Example
   pointSetsAverage

   See also
   

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2011-04-01,    using Matlab 7.9.0.529 (R2009b)
 Copyright 2011 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
POINTSETSAVERAGE Compute the average of several point sets.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
polygonArea


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1327
POLYGONAREA Compute the signed area of a polygon.

   A = polygonArea(POINTS);
   Compute area of a polygon defined by POINTS. POINTS is a N-by-2 array
   of double containing coordinates of vertices.
   
   Vertices of the polygon are supposed to be oriented Counter-Clockwise
   (CCW). In this case, the signed area is positive.
   If vertices are oriented Clockwise (CW), the signed area is negative.

   If polygon is self-crossing, the result is undefined.

   Examples
     % compute area of a simple shape
     poly = [10 10;30 10;30 20;10 20];
     area = polygonArea(poly)
     area = 
         200

     % compute area of CW polygon
     area2 = polygonArea(poly(end:-1:1, :))
     area2 = 
         -200

     % Computes area of a paper hen
     x = [0 10 20  0 -10 -20 -10 -10  0];
     y = [0  0 10 10  20  10  10  0 -10];
     poly = [x' y'];
     area = polygonArea(poly)
     area =
        400

     % Area of unit square with 25% hole
     pccw = [0 0; 1 0; 1 1; 0 1];
     pcw = pccw([1 4 3 2], :) * .5 + .25;
     polygonArea ([pccw; nan(1,2); pcw])
     ans =
        0.75

   References
   algo adapted from P. Bourke web page
   http://paulbourke.net/geometry/polygonmesh/

   See also:
   polygons2d, polygonCentroid, polygonSecondAreaMoments, triangleArea




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 49
POLYGONAREA Compute the signed area of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
polygonBounds


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 517
POLYGONBOUNDS Compute the bounding box of a polygon.

   BOX = polygonBounds(POLY);
   Returns the bounding box of the polygon. 
   BOX has the format: [XMIN XMAX YMIN YMAX].

   Input polygon POLY is as a N-by-2 array containing coordinates of each
   vertex. 
   Multiple polygons can be specified either by inserting NaN rows between
   vertex coordinates, or by using a cell array, each cell containing the
   vertex coordinates of a polygon loop. 

   See also
   polygons2d, boxes2d, boundingBox




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 52
POLYGONBOUNDS Compute the bounding box of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
polygonCentroid


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 806
POLYGONCENTROID Compute the centroid (center of mass) of a polygon.

   CENTROID = polygonCentroid(POLY)
   CENTROID = polygonCentroid(PTX, PTY)
   Computes center of mass of a polygon defined by POLY. POLY is a N-by-2
   array of double containing coordinates of vertices.

   [CENTROID AREA] = polygonCentroid(POLY)
   Also returns the (signed) area of the polygon. 

   Example
     % Draws the centroid of a paper hen
     x = [0 10 20  0 -10 -20 -10 -10  0];
     y = [0  0 10 10  20  10  10  0 -10];
     poly = [x' y'];
     centro = polygonCentroid(poly);
     drawPolygon(poly);
     hold on; axis equal;
     drawPoint(centro, 'bo');
 
   References
   algo adapted from P. Bourke web page

   See also:
   polygons2d, polygonArea, polygonSecondAreaMoments, drawPolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 67
POLYGONCENTROID Compute the centroid (center of mass) of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
polygonContains


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 544
POLYGONCONTAINS Test if a point is contained in a multiply connected polygon.

   B = polygonContains(POLYGON, POINT);
   Returns TRUE if the (possibly multi-connected) polygon POLYGON contains
   the point(s) given by POINT.
   This is an extension of the Matlab function inpolygon for the case of
   polygons with holes.

   Example
   POLY = [0 0; 10 0;10 10;0 10;NaN NaN;3 3;3 7;7 7;7 3];
   PT = [5 1;5 4];
   polygonContains(POLY, PT);
   ans =
        1
        0

   See also
   polygons2d, inpolygon, isPointInPolygon



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 77
POLYGONCONTAINS Test if a point is contained in a multiply connected polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
polygonCurvature


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 942
POLYGONCURVATURE Estimate curvature on polygon vertices using polynomial fit.

   CURV = polygonCurvature(POLY, M)
   Estimate the curvature for each vertex of a polygon, using polynomial
   fit from the M verties located around current vertex. M is usually an
   odd value, resulting in a symmetric neighborhood.

   Polynomial fitting is of degree 2 by default.
   

   Example
     img = imread('circles.png');
     img = imfill(img, 'holes');
     imgf = imfilter(double(img), fspecial('gaussian', 7, 2));
     figure(1), imshow(imgf);
     contours = imContours(imgf, .5); poly = contours{1};
     poly2 = smoothPolygon(poly, 7);
     hold on; drawPolygon(poly2);
     curv = polygonCurvature(poly2, 11);
     figure; plot(curv);
     minima = bwlabel(imextendedmin(curv, .05));
     centroids = imCentroid(minima);
     inds = round(centroids(:,2));
     figure(1); hold on; drawPoint(poly2(inds, :), 'g*')

   See also
     polygons2d



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 77
POLYGONCURVATURE Estimate curvature on polygon vertices using polynomial fit.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
polygonEdges


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 602
POLYGONEDGES Return the edges of a simple or multiple polygon.

   EDGES = polygonEdges(POLY)
   Return the set of edges of the polygon specified by POLY. POLY may be
   either a simple polygon given as a N-by-2 array of vertices, or a
   multiple polygon given by a cell array of linear rings, each ring being
   given as N-by-2 array of vertices.


   Example
     poly = [50 10;60 10;60 20;50 20];
     polygonEdges(poly)
     ans =
         50    10    60    10
         60    10    60    20
         60    20    50    20
         50    20    50    10

   See also
     polygons2d, polygonVertices



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 62
POLYGONEDGES Return the edges of a simple or multiple polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
polygonEquivalentEllipse


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 867
 Compute equivalent ellipse with same second order moments as polygon.

   ELLI = polygonEquivalentEllipse(POLY)

   Example
     % convert an ellipse to polygon, and check that it equivalent ellipse
     is close to original ellipse
     elli = [50 50 50 30 20];
     poly = ellipseToPolygon(elli, 1000);
     polygonEquivalentEllipse(poly)
     ans =
        50.0000   50.0000   49.9998   29.9999   20.0000

     % compute equivalent ellipse of more complex figure
     img = imread('circles.png');
     img = imfill(img, 'holes');
     figure; imshow(img); hold on;
     B = bwboundaries(img);
     poly = B{1}(:,[2 1]);
     drawPolygon(poly, 'r');
     elli = polygonEquivalentEllipse(poly);
     drawEllipse(elli, 'color', 'g', 'linewidth', 2);


   See also
     polygons2d, polygonSecondAreaMoments, polygonCentroid,
     equivalentEllipse, ellipseToPolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
 Compute equivalent ellipse with same second order moments as polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
polygonInertiaEllipse


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 852
POLYGONINERTIAELLIPSE Compute ellipse with same inertia moments as polygon.

   ELLI = polygonInertiaEllipse(POLY)

   Example
     % convert an ellipse to polygon, and check that inertia ellipse is
     % close to original ellipse
     elli = [50 50 50 30 20];
     poly = ellipseToPolygon(elli, 1000);
     polygonInertiaEllipse(poly)
     ans =
        50.0000   50.0000   49.9998   29.9999   20.0000

     % compute inertia ellipse of more complex figure
     img = imread('circles.png');
     img = imfill(img, 'holes');
     figure; imshow(img); hold on;
     B = bwboundaries(img);
     poly = B{1}(:,[2 1]);
     drawPolygon(poly, 'r');
     elli = polygonInertiaEllipse(poly);
     drawEllipse(elli, 'color', 'g', 'linewidth', 2);


   See also
     polygons2d, polygonSecondAreaMoments, polygonCentroid, inertiaEllipse
     ellipseToPolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 75
POLYGONINERTIAELLIPSE Compute ellipse with same inertia moments as polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
polygonLength


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 421
POLYGONLENGTH Perimeter of a polygon.

   L = polygonLength(POLYGON);
   Computes the boundary length of a polygon. POLYGON is given by a N-by-2
   array of vertices. 

   Example
     % Perimeter of a circle approximation
     poly = circleToPolygon([0 0 1], 200);
     polygonLength(poly)
     ans =
         6.2829

   See also:
   polygons2d, polygonCentroid, polygonArea, drawPolygon, polylineLength




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 37
POLYGONLENGTH Perimeter of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
polygonLoops


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 597
POLYGONLOOPS Divide a possibly self-intersecting polygon into a set of simple loops.

   LOOPS = polygonLoops(POLYGON);
   POLYGON is a polygone defined by a series of vertices,
   LOOPS is a cell array of polygons, containing the same vertices of the
   original polygon, but no loop self-intersect, and no couple of loops
   intersect each other.

   Example:
       poly = [0 0;0 10;20 10;20 20;10 20;10 0];
       loops = polygonLoops(poly);
       figure(1); hold on;
       drawPolygon(loops);
       polygonArea(loops)

   See also
   polygons2d, polygonSelfIntersections




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
POLYGONLOOPS Divide a possibly self-intersecting polygon into a set of simple...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
polygonNormalAngle


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 748
POLYGONNORMALANGLE Compute the normal angle at a vertex of the polygon.

   THETA = polygonNormalAngle(POLYGON, IND);
   where POLYGON is a set of points, and IND is index of a point in
   polygon. The function compute the angle of the normal cone localized at
   this vertex.
   If IND is a vector of indices, normal angle is computed for each vertex
   specified by IND.

   Example
   % creates a simple polygon
   poly = [0 0;0 1;-1 1;0 -1;1 0];
   % compute normal angle at each vertex
   theta = polygonNormalAngle(poly, 1:size(poly, 1));
   % sum of all normal angle of a non-intersecting polygon equals 2xpi
   % (can be -2xpi if polygon is oriented clockwise)
   sum(theta)

   See also:
   polygons2d, polygonOuterNormal, normalizeAngle




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 71
POLYGONNORMALANGLE Compute the normal angle at a vertex of the polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
polygonOuterNormal


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 626
POLYGONOUTERNORMAL  Outer normal vector for a given vertex(ices).

   VECT = polygonOuterNormal(POLY, VIND)
   Where POLY is a polygon and VIND is index of a vertex, returns the
   outer normal as a vector.
   
   Example
     % compute outer normals to an ellipse
     elli = [50 50 40 20 30];
     poly = ellipseToPolygon(elli, 200);
     figure; hold on;
     drawPolygon(poly, 'b'); axis equal; axis([0 100 10 90]);
     inds = 1:10:200; pts = poly(inds, :); drawPoint(pts, 'bo')
     vect = polygonOuterNormal(poly, inds);
     drawVector(pts, vect*10, 'b');

   See also
   polygons2d, polygonPoint, polygonNormalAngle




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 65
POLYGONOUTERNORMAL  Outer normal vector for a given vertex(ices).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
polygonPoint


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 169
POLYGONPOINT Extract a point from a polygon.

   POINT = polygonPoint(POLYGON, POS)
   

   Example
   polygonPoint

   See also
   polygons2d, polylinePoint




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 44
POLYGONPOINT Extract a point from a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
polygonSecondAreaMoments


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 500
POLYGONSECONDAREAMOMENTS Compute second-order area moments of a polygon.

   [IXX, IYY, IXY] = polygonSecondAreaMoments(POLY)
   Compute the second-order inertia moments of a polygon. The polygon is
   specified by the N-by-2 list of vertex coordinates.

   Example
   polygonSecondAreaMoments

   References
   * http://paulbourke.net/geometry/polygonmesh/
   * https://en.wikipedia.org/wiki/Second_moment_of_area

   See also
     polygons2d, polygonEquivalentEllipse, polygonArea, polygonCentroid



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 72
POLYGONSECONDAREAMOMENTS Compute second-order area moments of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
polygonSelfIntersections


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 843
POLYGONSELFINTERSECTIONS Find self-intersection points of a polygon.

   PTS = polygonSelfIntersections(POLY)
   Return the position of self intersection points

   [PTS, POS1, POS2] = polygonSelfIntersections(POLY)
   Also return the 2 positions of each intersection point (the position
   when meeting point for first time, then position when meeting point
   for the second time).

   [...] = polygonSelfIntersections(POLY, 'tolerance', TOL)
   Specifies an additional parameter to decide whether two intersection
   points should be considered the same, based on their euclidean
   distance.  


   Example
       % use a '8'-shaped polygon
       poly = [10 0;0 0;0 10;20 10;20 20;10 20];
       polygonSelfIntersections(poly)
       ans = 
           10 10

   See also
   polygons2d, polylineSelfIntersections




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
POLYGONSELFINTERSECTIONS Find self-intersection points of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
polygonSignature


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 671
POLYGONSIGNATURE Polar signature of a polygon (polar distance to origin).

   DISTS = polygonSignature(POLY, THETALIST)
   Computes the polar signature of a polygon, for a set of angles in
   degrees. If a ray at a given angle does not intersect the polygon, the
   corresponding distance value is set to NaN.

   DISTS = polygonSignature(POLY, N)
   When N is a scalar, uses N angles equally distributed between 0 and 360
   degrees.
   
   [DISTS, THETA] = polygonSignature(...)
   Also returns the angle set for which the signature was computed.

   Example
   polygonSignature

   See also
     polygons2d, signatureToPolygon, intersectRayPolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73
POLYGONSIGNATURE Polar signature of a polygon (polar distance to origin).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
polygonSubcurve


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 655
POLYGONSUBCURVE Extract a portion of a polygon.

   POLY2 = polygonSubcurve(POLYGON, POS0, POS1)
   Create a new polyline, by keeping vertices located between positions
   POS0 and POS1, and adding points corresponding to positions POS0 and
   POS1 if they are not already vertices.

   Example
   Nv = 100;
   poly = circleAsPolygon([10 20 30], Nv);
   poly2 = polygonSubcurve(poly, 15, 65);
   drawCurve(poly2);

   See also
   polygons2d, polylineSubcurve

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-04-30,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 47
POLYGONSUBCURVE Extract a portion of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
polygonSymmetryAxis


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 686
POLYGONSYMMETRYAXIS Try to identify symmetry axis of polygon.

   LINE = polygonSymmetryAxis(POLY)
   Returns a line that minimize difference between the polygon POLY and
   its reflection with the line.
   The difference metric between the two polygons is the sum of distances
   between each vertex of original polygon to the reflected polygon.

   Example
     % identify symmetry axis of an ellipse
     elli = [50 50 40 20 30];
     poly = ellipseToPolygon(elli, 100);
     line = polygonSymmetryAxis(poly);
     figure; hold on;
     drawEllipse(elli);
     axis equal; axis ([0 100 0 100]);
     drawLine(line);

   See also
   transforms2d, transformPoint, distancePointPolygon



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 61
POLYGONSYMMETRYAXIS Try to identify symmetry axis of polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
polygonToRow


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 997
POLYGONTOROW Convert polygon coordinates to a row vector.

   ROW = polygonToRow(POLY);
   where POLY is a N-by-2 array of points representing vertices of the
   polygon, converts the vertex coordinates into a linear array:
   ROW = [X1 Y1 X2 Y2 .... XN YN]

   ROW = polygonToRow(POLY, TYPE);
   Can coose another format for converting polygon. Possibilities are:
   'interlaced' (default}, as described above
   'packed': ROW has format [X1 X2 ... XN Y1 Y2 ... YN].

   Example
   square = [10 10 ; 20 10 ; 20 20 ; 10 20];
   row = polygonToRow(square)
   row = 
       10   10   20   10   20   20   10   20 

   % the same with different ordering
   row = polygonToRow(square, 'packed')
   row = 
       10   20   20   10   10   10   20   20 


   See also
   polygons2d, rowToPolygon


 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2010-07-23,    using Matlab 7.9.0.529 (R2009b)
 Copyright 2010 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 57
POLYGONTOROW Convert polygon coordinates to a row vector.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
polygonVertices


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1310
POLYGONVERTICES Extract all vertices of a (multi-)polygon.

   VERTS = polygonVertices(POLY)
   Returns the set of verttices from the polygon POLY. POLY can be either:
   * a N-by-2 array of vertices. In that case, POLY and VERTS are the
       same.
   * a N-by-2 array of vertices with pairs of NaN values separating two
       rings of the polygon. In that case, the array VERTS corresponds to
       the vertices of the polygon, without copying the NaN values.
   * a cell array of loops. In that case, the functions recursively
       process the polygons and populated the vertex array.


   Example
     % create a polygon with a hole, using NaN for separating rings
     ring1 = [0 0 ; 50 0;50 50;0 50];
     ring2 = [20 20;20 30;30 30;30 20];
     poly = [ring1 ; NaN NaN ; ring2];
     figure; drawPolygon(poly, 'b'); 
     axis([-10 60 -10 60]); axis equal; hold on;
     verts = polygonVertices(poly);
     drawPoint(verts, 'bo');

     % create a polygon with a hole, storing rings in cell array
     ring1 = [0 0 ; 50 0;50 50;0 50];
     ring2 = [20 20;20 30;30 30;30 20];
     poly = {ring1, ring2};
     figure; drawPolygon(poly, 'b'); 
     axis([-10 60 -10 60]); axis equal; hold on;
     verts = polygonVertices(poly);
     drawPoint(verts, 'bo');

   See also
     polygons2d, polygonEdges



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
POLYGONVERTICES Extract all vertices of a (multi-)polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
polylineCentroid


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 833
POLYLINECENTROID Compute centroid of a curve defined by a series of points.

   PT = polylineCentroid(POINTS);
   Computes center of mass of a polyline defined by POINTS. POINTS is a
   [NxD] array of double, representing a set of N points in a
   D-dimensional space.

   PT = polylineCentroid(PTX, PTY);
   PT = polylineCentroid(PTX, PTY, PTZ);
   Specifies points as separate column vectors

   PT = polylineCentroid(..., TYPE);
   Specifies if the last point is connected to the first one. TYPE can be
   either 'closed' or 'open'.

   Example
   poly = [0 0;10 0;10 10;20 10];
   polylineCentroid(poly)
   ans = 
       [10 5]

   See also:
   polygons2d, centroid, polygonCentroid, polylineLength

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 22/05/2006.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 75
POLYLINECENTROID Compute centroid of a curve defined by a series of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
polylineLength


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 973
POLYLINELENGTH Return length of a polyline given as a list of points.

   L = polylineLength(POLY);
   POLY should be a N-by-D array, where N is the number of points and D is
   the dimension of the points.

   L = polylineLength(..., TYPE);
   Specifies if the last point is connected to the first one. TYPE can be
   either 'closed' or 'open'.

   L = polylineLength(POLY, POS);
   Compute the length of the polyline between its origin and the position
   given by POS. POS should be between 0 and N-1, where N is the number of
   points of the polyline.


   Example:
   % Compute the perimeter of a circle with radius 1
   polylineLength(circleAsPolygon([0 0 1], 500), 'closed')
   ans = 
       6.2831

   See also:
   polygons2d, polylineCentroid, polygonLength

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-04-30,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 69
POLYLINELENGTH Return length of a polyline given as a list of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
polylinePoint


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 663
POLYLINEPOINT Extract a point from a polyline.

   POINT = polylinePoint(POLYLINE, POS)
   POLYLINE is a N*2 array containing coordinate of polyline vertices
   POS is comprised between 0 (first point of polyline) and Nv-1 (last
   point of the polyline).
   

   Example
   poly = [10 10;20 10;20 20;30 30];
   polylinePoint(poly, 0)
       [10 10]
   polylinePoint(poly, 3)
       [30 30]
   polylinePoint(poly, 1.4)
       [20 14]


   See also
   polygons2d

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-04-30,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 46
POLYLINEPOINT Extract a point from a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
polylineSelfIntersections


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1658
POLYLINESELFINTERSECTIONS Find self-intersection points of a polyline.

   Computes self-intersections of a polyline, eventually specifying if
   polyline is closed or open, and eventually returning position of
   intersection points on polyline.
   For common use cases, the intersectPolylines function may return the
   desired result in a faster way.


   PTS = polylineSelfIntersections(POLY);
   Returns the position of self intersections of the given polyline.

   PTS = polylineSelfIntersections(POLY, CLOSED);
   Adds an options to specify if the polyline is closed (i.e., is a
   polygon), or open (the default). CLOSED can be a boolean, or one of
   'closed' or 'open'.

   [PTS, POS1, POS2] = polylineSelfIntersections(POLY);
   Also return the 2 positions of each intersection point (the position
   when meeting point for first time, then position when meeting point
   for the second time).

   [...] = polylineSelfIntersections(POLY, 'tolerance', TOL)
   Specifies an additional parameter to decide whether two intersection
   points should be considered the same, based on their Euclidean
   distance.  


   Example
       % use a gamma-shaped polyline
       poly = [0 0;0 10;20 10;20 20;10 20;10 0];
       polylineSelfIntersections(poly)
       ans = 
           10 10

       % use a 'S'-shaped polyline
       poly = [10 0;0 0;0 10;20 10;20 20;10 20];
       polylineSelfIntersections(poly)
       ans =
           Empty matrix: 0-by-2
       polylineSelfIntersections(poly, 'closed')
       ans = 
           10 10

   See also
   polygons2d, intersectPolylines, polygonSelfIntersections




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
POLYLINESELFINTERSECTIONS Find self-intersection points of a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
polylineSubcurve


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 659
POLYLINESUBCURVE Extract a portion of a polyline.

   POLY2 = polylineSubcurve(POLYLINE, POS0, POS1)
   Create a new polyline, by keeping vertices located between positions
   POS0 and POS1, and adding points corresponding to positions POS0 and
   POS1 if they are not already vertices.

   Example
   Nv = 100;
   poly = circleAsPolygon([10 20 30], Nv);
   poly2 = polylineSubcurve(poly, 15, 65);
   drawCurve(poly2);

   See also
   polygons2d, polygonSubCurve

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-04-30,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 49
POLYLINESUBCURVE Extract a portion of a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
projPointOnPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 919
PROJPOINTONPOLYGON  Compute position of a point projected on a polygon.

   POS = projPointOnPolygon(POINT, POLYGON)
   Compute the position of the orthogonal projection of a point on a
   polygon.
   POINT is a 1-by-2 row vector containing point coordinates
   POLYGON is a N-by-2 array containing coordinates of polygon vertices

   When POINT is an array of points, returns a column vector with as many
   rows as the number of points. 

   [POS, DIST] = projPointOnPolygon(...)
   Also returns the distance between POINT and POLYGON. The distance is
   negative if the point is located inside of the polygon.

   Example
     poly = [10 10; 20 10;20 20;10 20];
     projPointOnPolygon([15 0], poly)
     ans =
         0.5000
     projPointOnPolygon([0 16], poly)
     ans =
         3.4000

   See also
   points2d, polygons2d, polygonPoint, projPointOnPolyline
   distancePointpolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 71
PROJPOINTONPOLYGON  Compute position of a point projected on a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
projPointOnPolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1607
PROJPOINTONPOLYLINE Compute position of a point projected on a polyline.

   POS = projPointOnPolyline(POINT, POLYLINE)
   Compute the position of the orthogonal projection of a point on a
   polyline.
   POINT is a 1-by-2 row vector containing point coordinates
   POLYLINE is a N-by-2 array containing coordinates of polyline vertices
   POS is the position of the point on the polyline, between 0 and the
   number of vertices of the polyline. POS can be a non-integer value, in
   this case, the integer part corresponds to the polyline edge index
   (between 0 and Nv-1), and the floating-point part corresponds to the
   relative position on i-th edge (between 0 and 1, 0: edge start, 1: edge
   end).

   When POINT is an array of points, returns a column vector with as many
   rows as the number of points.

   POS = projPointOnPolyline(POINT, POLYLINE, CLOSED)
   Specifies if the polyline is closed or not. CLOSED can be one of:
     'closed' -> the polyline is closed
     'open' -> the polyline is open
     a column vector of logical with the same number of elements as the
       number of points -> specify individually if each polyline is
       closed (true=closed).

   [POS, DIST] = projPointOnPolyline(...)
   Also returns the distance between POINT and POLYLINE.

   Example
     poly = [10 10; 20 10;20 20;10 20];
     projPointOnPolyline([15 0], poly)
     ans =
         0.5000
     projPointOnPolyline([0 16], poly)
     ans =
         3.0000

   See also
   points2d, polygons2d, polylinePoint, projPointOnPolygon
   distancePointPolyline




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 72
PROJPOINTONPOLYLINE Compute position of a point projected on a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
randomPointInPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1105
RANDOMPOINTINPOLYGON Generate random point(s) in a polygon.

   POINT = randomPointInPolygon(POLY)
   POINTS = randomPointInPolygon(POLY, NPTS)
   Generate random point(s) within the specified polygon. If the number of
   points is not specified, only one point is generated.
   
   POINT = randomPointInPolygon(POLY, NPTS, QRS)
   Specifies a Quasi-random number generator QRS used to generate point.
   coordinates (requires the statistics toolbox).

   Example
     % generate an ellipse-like polygon, and fill it with points
     elli = [50 50 50 30 30];
     poly = ellipseToPolygon(elli, 200);
     pts = randomPointInPolygon(poly, 500);
     figure; hold on;
     drawPolygon(poly, 'k');
     drawPoint(pts, 'b.');
     axis equal; axis([0 100 0 100]);

     % use halton sequence to distribute points within the polygon
     qrs = haltonset(2, 'Skip', 1e3, 'Leap', 1e2);
     pts = randomPointInPolygon(poly, 500, qrs);
     figure; hold on;
     drawPolygon(poly, 'k');
     drawPoint(pts, 'b.');
     axis equal; axis([0 100 0 100]);

   See also
     polygons2d, randomPointInBox, drawPolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
RANDOMPOINTINPOLYGON Generate random point(s) in a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
readPolygonSet


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 710
READPOLYGONSET Read a set of simple polygons stored in a file.
   
   POLY = readPolygonSet(FILENAME);
   Returns the polygon stored in the file FILENAME.
   Polygons are assumed to be stored in text files, without headers, with
   x and y coordinates packed in two separate lines:
     X11 X12 X13 ... X1N
     Y11 Y12 Y13 ... Y1N
     X21 X22 X23 ... X2N
     Y21 Y22 Y23 ... Y2N

   Each polygon may have a different number of vertices. The result is a
   cell array of polygon, each cell containing a N-by-2 array representing
   the vertex coordinates.

   See also:
   polygons2d

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 11/04/2004.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 62
READPOLYGONSET Read a set of simple polygons stored in a file.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 22
removeMultipleVertices


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 629
REMOVEMULTIPLEVERTICES Remove multiple vertices of a polygon or polyline.

   POLY2 = removeMultipleVertices(POLY, EPS)
   Remove adjacent vertices that are closer than the distance EPS to each
   other and merge them to a unique vertex.

   POLY2 = removeMultipleVertices(POLY, EPS, CLOSED)
   If CLOSED is true, also check if first and last vertices need to be
   merged. If not specified, CLOSED is false.

   Example
     poly = [10 10; 20 10;20 10;20 20;10 20; 10 10];
     poly2 = removeMultipleVertices(poly, true);
     size(poly2, 1)
     ans = 
         4

   See also
   polygons2d, mergeClosePoints



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73
REMOVEMULTIPLEVERTICES Remove multiple vertices of a polygon or polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
resamplePolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 775
RESAMPLEPOLYGON  Distribute N points equally spaced on a polygon.

   POLY2 = resamplePolygon(POLY, N)
   Resample the input polygon POLY such that the resulting polygon POLY2
   has N vertices. All points of POLY2 belong to the initial polygon, but
   are not necessarily vertices of the original polygon.


   Example
     % creates a polygon from an ellipse
     elli = [20 30 40 20 30];
     poly = ellipseToPolygon(elli, 500);
     figure; drawPolygon(poly, 'b');
     % resample the polygon with a fixed number of vertices
     poly2 = resamplePolygon(poly, 20);
     drawPolygon(poly2, 'm');
     drawPoint(poly2, 'mo');
     axis equal; axis([-20 60 0 60]);

   See also
     polygons2d, resamplePolygonByLength, smoothPolygon, resamplePolyline




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 65
RESAMPLEPOLYGON  Distribute N points equally spaced on a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
resamplePolygonByLength


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 794
RESAMPLEPOLYGONBYLENGTH  Resample a polygon with a fixed sampling step.

   RES = resamplePolygon(POLY, STEP)
   Resample the input polygon POLY by distributing new vertices on the
   original polygon such that the (curvilinear) distance between the new
   vertices is approximately equal to STEP. 

   Example
     % creates a polygon from an ellipse
     elli = [20 30 40 20 30];
     poly = ellipseToPolygon(elli, 500);
     figure; drawPolygon(poly, 'b');
     poly2 = resamplePolygonByLength(poly, 10);
     hold on; 
     drawPolygon(poly2, 'm');
     drawPoint(poly2, 'mo');
     axis equal; axis([-20 60 0 60]);
     legend('Original polygon', 'Resampled polygon', 'Location', 'NorthWest');

   See also
     polygons2d, simplifyPolygon, resamplePolygon,
     resamplePolylineByLength




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 71
RESAMPLEPOLYGONBYLENGTH  Resample a polygon with a fixed sampling step.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
resamplePolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 591
RESAMPLEPOLYLINE Distribute N points equally spaced on a polyline.

   RES = resamplePolyline(POLY, N)
   Resample the input polyline POLY such that the resulting polyline RES
   has N points. All points of RES belong to the initial polyline, but are
   not necessarily vertices.

   Example
     poly = [0 10;0 0;20 0];
     figure; drawPolyline(poly, 'b');
     poly2 = resamplePolyline(poly, 10);
     hold on; 
     drawPolyline(poly2, 'bo');
     axis equal; axis([-10 30 -10 20]);

   See also
     polygons2d, drawPolyline, resamplePolygon, resamplePolylineByLength




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 66
RESAMPLEPOLYLINE Distribute N points equally spaced on a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
resamplePolylineByLength


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 681
RESAMPLEPOLYLINEBYLENGTH Resample a polyline with a fixed sampling step.

   RES = resamplePolyline(POLY, STEP)
   Resample the input polyline POLY by distributing new vertices on the
   original polyline such that the (curvilinear) distance between the new
   vertices is approximately equal to STEP. 

   Example
     poly = [0 10;0 0;10 0; 10 10; 20 10;20 0];
     figure; drawPolyline(poly, 'k');
     poly2 = resamplePolylineByLength(poly, 4);
     hold on; 
     drawPolyline(poly2, 'm');
     drawPoint(poly2, 'mo');
     axis equal; axis([-10 30 -10 20]);
     legend('Original polyline', 'Resampled polyline');

   See also
     polygons2d, drawPolyline, resamplePolygon




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 72
RESAMPLEPOLYLINEBYLENGTH Resample a polyline with a fixed sampling step.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
reversePolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 483
REVERSEPOLYGON Reverse a polygon, by iterating vertices from the end.

   POLY2 = reversePolygon(POLY)
   POLY2 has same vertices as POLY, but in different order. The first
   vertex of the polygon is still the same.

   Example
   reversePolygon

   See also
   polygons2d, reversePolyline

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-06-30,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 69
REVERSEPOLYGON Reverse a polygon, by iterating vertices from the end.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
reversePolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 458
REVERSEPOLYLINE Reverse a polyline, by iterating vertices from the end.

   POLY2 = reversePolyline(POLY)
   POLY2 has same vertices as POLY, but POLY2(i,:) is the same as
   POLY(END-i+1,:).

   Example
   reversePolyline

   See also
   polygons2d, reversePolygon

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2009-06-30,    using Matlab 7.7.0.471 (R2008b)
 Copyright 2009 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 71
REVERSEPOLYLINE Reverse a polyline, by iterating vertices from the end.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
rowToPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1010
ROWTOPOLYGON  Create a polygon from a row vector.

   POLY = rowToPolygon(ROW)
   Convert a 1-by-2*N row vector that concatenates all polygon vertex
   coordinates into a N-by-2 array of coordinates.
   Default ordering of coordinates in ROW is:
   [X1 Y1 X2 Y2 X3 Y3 .... XN YN].

   POLY = rowToPolygon(ROW, METHOD)
   Specifies the method for concatenating coordinates. METHOS is one of:
   'interlaced': default method, described above.
   'packed': the vector ROW has format:
   [X1 X2 X3 ... XN Y1 Y2 Y3 ... YN].

   POLYS = rowToPolygon(ROWS, ...)
   When ROWS is a NP-by-NV array containing the vertex coordinates of NP
   polygons, returns a 1-by-NP cell array containing in each cell the
   coordinates of the polygon.


   Example
   % Concatenate coordinates of a circle and draw it as a polygon
     t = linspace (0, 2*pi, 200);
     row = [cos(t) sin(t)];
     poly = rowToPolygon(row, 'packed');
     figure;drawPolygon(poly)

   See also
   polygons2d, polygonToRow



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 49
ROWTOPOLYGON  Create a polygon from a row vector.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
signatureToPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 225
SIGNATURETOPOLYGON Reconstruct a polygon from its polar signature.

   POLY = signatureToPolygon(SIGNATURE)
   POLY = signatureToPolygon(SIGNATURE, ANGLES)

   Example
   signatureToPolygon

   See also
     polygonSignature



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 66
SIGNATURETOPOLYGON Reconstruct a polygon from its polar signature.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
simplifyPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 573
SIMPLIFYPOLYGON  Douglas-Peucker simplification of a polygon.

   POLY2 = simplifyPolygon(POLY, TOL)
   Simplifies the input polygon using the Douglas-Peucker algorithm. 

   Example
     elli = [20 30 40 20 30];
     poly = ellipseToPolygon(elli, 500);
     poly2 = simplifyPolygon(poly, 1); % use a tolerance equal to 1.
     figure; hold on;
     drawEllipse(elli);
     drawPoint(poly2, 'mo');

   See also
   polygons2d, smoothPolygon, simplifyPolyline, resamplePolygon

   References
   http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 61
SIMPLIFYPOLYGON  Douglas-Peucker simplification of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 16
simplifyPolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 577
SIMPLIFYPOLYLINE Douglas-Peucker simplification of a polyline.

   POLY2 = simplifyPolyline(POLY, TOL)
   Simplifies the input polyline using the Douglas-Peucker algorithm. 

   Example
     elli = [20 30 40 20 30];
     poly = ellipseToPolygon(elli, 500);
     poly2 = simplifyPolyline(poly, 1); % use a tolerance equal to 1
     figure; hold on;
     drawEllipse(elli);
     drawPoint(poly2, 'mo');

   See also
   polygons2d, simplifyPolygon, resamplePolyline, smoothPolyline

   References
   http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 62
SIMPLIFYPOLYLINE Douglas-Peucker simplification of a polyline.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
smoothPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 580
SMOOTHPOLYGON Smooth a polygon using local averaging.

   RES = smoothPolygon(POLY, M)
   POLY contains the polygon vertices, and M is the size of smoothing
   (given as the length of the convolution window).


   Example
     img = imread('circles.png');
     img = imfill(img, 'holes');
     contours = bwboundaries(img');
     contour = contours{1};
     imshow(img); hold on; drawPolygon(contour, 'b');
     contourf = smoothPolygon(contour, 11);
     drawPolygon(contourf, 'm');

   See also
     polygons2d, smoothPolyline, simplifyPolygon, resamplePolygon



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 53
SMOOTHPOLYGON Smooth a polygon using local averaging.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
smoothPolyline


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 760
SMOOTHPOLYLINE Smooth a polyline using local averaging.

   RES = smoothPolygon(POLY, M)
   POLY contains the polyline vertices, and M is the size of smoothing
   (given as the length of the convolution window).
   Extremities of the polyline are smoothed with reduced window (last and
   first vertices are kept identical, second and penultimate vertices are
   smoothed with 3 values, etc.).

   Example
     img = imread('circles.png');
     img = imfill(img, 'holes');
     contours = bwboundaries(img');
     poly = contours{1}(201:500,:);
     figure; drawPolyline(poly, 'b'); hold on;
     poly2 = smoothPolyline(poly, 21);
     drawPolygon(poly2, 'm');

   See also
     polygons2d, smoothPolygon, simplifyPolyline, resamplePolyline



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 55
SMOOTHPOLYLINE Smooth a polyline using local averaging.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 13
splitPolygons


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 340
SPLITPOLYGONS Convert a NaN separated polygon list to a cell array of polygons.

   POLYGONS = splitPolygons(POLYGON);
   POLYGON is a N-by-2 array of points, possibly with pairs of NaN values.
   The functions separates each component separated by NaN values, and
   returns a cell array of polygons.

   See also:
   polygons2d




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 79
SPLITPOLYGONS Convert a NaN separated polygon list to a cell array of polygons.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
steinerPoint


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 562
STEINERPOINT Compute steiner point (weighted centroid) of a polygon.

   PT = steinerPoint(POINTS);
   PT = steinerPoint(PTX, PTY);
   Computes steiner point of a polygon defined by POINTS. POINTS is a
   [N*2] array of double.

   The steiner point is computed the same way as the polygon centroid,
   except that a weight depending on the angle is given to each vertex.

   See also:
   polygons2d, polygonArea, polygonCentroid, drawPolygon

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 11/11/2004.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
STEINERPOINT Compute steiner point (weighted centroid) of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 14
steinerPolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 464
STEINERPOLYGON Create a Steiner polygon from a set of vectors.

   NODES = steinerPolygon(VECTORS);
   Builds the (convex) polygon which contains an edge for each one of the
   vectors given by VECTORS.

   Example
   n = steinerPolygon([1 0;0 1;1 1]);
   drawPolygon(n);

   See also
   polygons2d, drawPolygon

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2006-04-28
 Copyright 2006 INRA - CEPIA Nantes - MIAJ (Jouy-en-Josas).



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 62
STEINERPOLYGON Create a Steiner polygon from a set of vectors.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
supportFunction


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 499
SUPPORTFUNCTION Compute support function of a polygon.
 
   H = supportFunction(POLYGON, N)
   uses N points for suport function approximation

   H = supportFunction(POLYGON)
   assume 24 points for approximation

   H = supportFunction(POLYGON, V)
   where V is a vector, uses vector V of angles to compute support
   function.
   
   See also:
   polygons2d, convexification

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 20/12/2004.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 54
SUPPORTFUNCTION Compute support function of a polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
triangulatePolygon


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1041
TRIANGULATEPOLYGON Compute a triangulation of the polygon.

   TRI = triangulatePolygon(POLY)
   Computes a triangulation TRI of the polygon defined by POLY
   POLY contains the polygon vertices, as a Nv-by-2 array of double. 
   TRI is a Nt-by-3 array containing indices of vertices forming the
   triangles. 

   Example
     % creates a simple polygon and computes its Delaunay triangulation
     poly = [0 0 ; 10 0;5 10;15 15;5 20;-5 10];
     figure;drawPolygon(poly); axis equal
     tri = triangulatePolygon(poly);
     figure;
     % patch('Faces', tri, 'Vertices', poly, 'facecolor', 'c');
     drawMesh(poly, tri, 'facecolor', 'c');
     axis equal

     % Another example for which constrains were necessary
     poly2 = [10 10;80 10; 140 20;30 20; 80 30; 140 30; 120 40;10 40];
     tri2 = triangulatePolygon(poly2);
     figure; drawMesh(poly2, tri2);
     hold on, drawPolygon(poly2, 'linewidth', 2);
     axis equal
     axis([0 150 0 50])

   See also
     delaunayTriangulation, drawMesh, patch




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
TRIANGULATEPOLYGON Compute a triangulation of the polygon.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 15
writePolygonSet


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 504
WRITEPOLYGONSET Write a set of simple polygons into a file.
   
   writePolygonSet(POLYS, FILENAME);
   Writes the set of polygons in the file FILENAME.
   Following format is used:
     X11 X12 X13 ... X1N
     Y11 Y12 Y13 ... Y1N
     X21 X22 X23 ... X2N
     Y21 Y22 Y23 ... Y2N
   Each polygon may have a different number of vertices. 

   See also:
   polygons2d, readPolygonSet

   ---------
   author : David Legland 
   INRA - TPV URPOI - BIA IMASTE
   created the 14/01/2013.




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 59
WRITEPOLYGONSET Write a set of simple polygons into a file.





