
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
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 17 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
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.