area

Area of a polyshape or a 2-D alpha shape (a 3-D alpha shape has volume instead).

Category: Mathematics > Computational Geometry

Syntax

A = area(pshape)

Area of the polygon, with holes subtracted.

A = area(pshape, I)

Area of only the boundaries or regions selected by the index I.

A = area(shp)

Area enclosed by a 2-D alphaShape.

Description

The area is computed from the polygon's boundaries: outer boundaries add and hole boundaries subtract, so a square with a square hole reports the difference. The sign of the vertex order does not matter.

The name area is also used for filled area plots; called with plain numeric vectors it draws one. With a polyshape or alphaShape argument it is a geometric measurement.

Input arguments

pshape
A polyshape object.
shp
A 2-D alphaShape. For a 3-D one area raises an error and volume should be used.

Output arguments

A
Scalar area, in squared units of the coordinates. An empty polyshape has area 0.

Example

Rectangle with a square 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);
area(P)
area(D)
Output
ans = 12
ans = 11

See also

perimeter polyarea centroid polyshape volume