
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
polygon-generator
Advanced tools
polygon = require('polygon-generator');
Calculate coordinates of an equilateral polygon. The returned object is an array of the following structure:
[{x: 0, y: 0}, {x: 1, y: 0}, {x: 0.5, y: 0.866}]
The vectors form an anti-clockwise path with the last vector connecting back to the first one. All coordinates will be in the first quadrant of a cartesian coordinate system meaning there will be no negative numbers. This method takes three parameters:
sides = 3;
sideLength = 1;
startingAngle = 10;
vertices = polygon.coordinates(sides, sideLength, startingAngle);
The polygon object provides translation, rotation and scaling methods for polygons. To create one simply pass in an array of vectors representing the vertices.
poly = polygon.polygon([{x: 0, y: 0}, {x: 1, y: 0}, {x: 0.5, y: 0.866}]);
You can also directly pass in the results of the coordinates method.
poly = polygon.polygon(polygon.coordinates(5,2,20));
poly.translate(vector);
Translate shifts a polygon along a vector. The vector needs to be an object with a field x
and y
, which should both be numbers.
poly.rotate(angle, point);
Rotate a polygon anti-clockwise around a given point {x: ?, y: ?}
by the specified angle. If no point is specified then the centroid of the polygon will be used.
poly.rotate(factor, point);
Scale a polygon by a certain factor with regard to a given point. If no point is specified then the centroid of the polygon will be used.
poly.area();
Returns the area of the polygon.
poly.centroid();
Returns the coordinates of the centroid {x: Cx, y: Cy}
.
FAQs
A utility to generate coordinates of an equilateral polygon.
The npm package polygon-generator receives a total of 87 weekly downloads. As such, polygon-generator popularity was classified as not popular.
We found that polygon-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.