Skip to content

@technobuddha > library > Geometry > Polygon

Function: perimeter()

ts
function perimeter(polygon: Polygon): number;

Defined in: perimeter.ts:23

Calculates the perimeter of a polygon.

Parameters

ParameterTypeDescription
polygonPolygonThe polygon.

Returns

number

The total perimeter length of the polygon.

Example

typescript
const polygon: Polygon = [
  { x: 0, y: 0 },
  { x: 10, y: 0 },
  { x: 10, y: 10 },
  { x: 0, y: 10 }
];
const result = perimeter(polygon);
// result: 40