Skip to content

polylineCentroid

David Legland edited this page Feb 28, 2022 · 1 revision

Computes the centroid of a curve defined by a series of points.

Usage

PT = polylineCentroid(POINTS);

Computes center of mass of a polyline defined by POINTS. POINTS is a N-by-D 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)

Result:

ans = 
    [10 5]

See also:

polygons2d, centroid, polygonCentroid, polylineLength

Clone this wiki locally