Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@math.gl/polygon
Advanced tools
@math.gl/polygon is a JavaScript library for performing geometric operations on polygons. It is part of the math.gl suite, which provides high-precision mathematical operations for geospatial applications. This package is particularly useful for tasks such as polygon clipping, triangulation, and point-in-polygon tests.
Polygon Clipping
This feature allows you to clip one polygon with another, effectively finding the intersection area between the two polygons.
const {clipPolygon} = require('@math.gl/polygon');
const subjectPolygon = [[0, 0], [10, 0], [10, 10], [0, 10]];
const clipPolygon = [[5, 5], [15, 5], [15, 15], [5, 15]];
const result = clipPolygon(subjectPolygon, clipPolygon);
console.log(result);
Triangulation
This feature breaks down a polygon into a set of triangles, which can be useful for rendering or computational geometry tasks.
const {triangulate} = require('@math.gl/polygon');
const polygon = [[0, 0], [10, 0], [10, 10], [0, 10]];
const triangles = triangulate(polygon);
console.log(triangles);
Point-in-Polygon Test
This feature checks whether a given point lies inside a polygon, which is useful for hit-testing and spatial queries.
const {isPointInPolygon} = require('@math.gl/polygon');
const polygon = [[0, 0], [10, 0], [10, 10], [0, 10]];
const point = [5, 5];
const isInside = isPointInPolygon(point, polygon);
console.log(isInside);
Turf is a comprehensive geospatial analysis library for JavaScript. It offers a wide range of functionalities including polygon operations, distance calculations, and spatial analysis. Compared to @math.gl/polygon, Turf provides a broader set of geospatial tools but may be more complex to use for simple polygon operations.
Polygon Clipping is a library focused specifically on polygon clipping operations. It is highly optimized for performance and can handle complex polygon intersections. While it offers similar clipping functionalities as @math.gl/polygon, it does not provide other features like triangulation or point-in-polygon tests.
Earcut is a fast and robust library for polygon triangulation. It is widely used in graphics applications for breaking down complex polygons into triangles. Compared to @math.gl/polygon, Earcut is specialized in triangulation and does not offer other polygon operations.
math.gl is a suite of math modules for 3D applications.
This module contains utilities that work with polylines and polygons.
For documentation please visit the website.
v4.1.0
FAQs
Polygon/polyline processing utilities
The npm package @math.gl/polygon receives a total of 151,935 weekly downloads. As such, @math.gl/polygon popularity was classified as popular.
We found that @math.gl/polygon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.