Socket
Socket
Sign inDemoInstall

area-polygon

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    area-polygon

Calculate the area of a simple polygon


Version published
Weekly downloads
884
decreased by-12.39%
Maintainers
1
Install size
4.10 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 09 Dec 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc