Skip to content

foo123/area-polygon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Area Polygon Build Status

Calculate the area of a simple 2D polygon given its vertices.

API

var area = require('area-polygon')

area(points, signed)

points must consistent of points that are either of the form:

{
  x: Integer,
  y: Integer
}

or

[x, y]

The points must also trace the edge of the polygon. The last point should return to the origin.

signed is true or false(default). If true fucntion returns the signed area of the polygon. It is helpful to determine the orientation of points in polygon. Area is positive if orientation is counter-clockwise and negative for clockwise.

Example

Calculate the area of a 4x4 square whose bottom left corner sits at the origin of the grid ([0, 0]):

area([
 [0, 0],
 [0, 4],
 [4, 4],
 [4, 0]
]) === 16

About

Calculate the area of a simple polygon

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%