numsides

Total number of sides (vertices) of a polyshape.

Category: Mathematics > Computational Geometry

Syntax

n = numsides(pshape)

Counts the sides over all boundaries.

n = numsides(pshape, I)

Counts only the sides of boundary I.

Description

Sides are counted for outer boundaries and holes alike. A polyshape with a four-sided outline and a four-sided hole has eight sides. An empty polyshape has zero.

Input arguments

pshape
A polyshape object.

Output arguments

n
Non-negative integer. A closed polygon has as many sides as vertices.

Example

Sides of a shape with a hole

P = polyshape([0 4 4 0], [0 0 3 3]);
H = polyshape([1 2 2 1], [1 1 2 2]);
D = subtract(P, H);
numsides(P)
numsides(D)
Output
ans = 4
ans = 8

See also

numboundaries polyshape nsidedpoly rmslivers