Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

2d-polygon-self-intersections

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

2d-polygon-self-intersections - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

11

intersections.js
var isect = require('exact-segment-intersect');
var float = require('robust-estimate-float');
var hasIsect = require('robust-segment-intersect');

@@ -35,2 +36,4 @@ module.exports = selfIntersections;

for (var p=0; p<l; p++) {
if (o === p) { continue; }
var s1 = poly[p]

@@ -45,2 +48,6 @@ var e1 = poly[(p+1) % l];

if (!hasIsect(oc, on, pc, pn)) {
continue;
}
var r = isect(oc, on, pc, pn);

@@ -59,2 +66,6 @@ // since these are homogeneous vectors, if the last component `w` is 0

if (cmp(r, oc) || cmp(r, on) || cmp(r, pc) || cmp(r, pn)) {
continue;
}
var key = r+'';

@@ -61,0 +72,0 @@ var unique = !seen[key];

5

package.json

@@ -8,7 +8,8 @@ {

"exact-segment-intersect": "^1.0.0",
"robust-estimate-float": "^1.0.0"
"robust-estimate-float": "^1.0.0",
"robust-segment-intersect": "^1.0.1"
},
"name": "2d-polygon-self-intersections",
"description": "This library may not be fast, but it is robust. Robust in the fact that it will find all of the self-intersections in a polygon - minus of course shared endpoints.",
"version": "1.2.1",
"version": "1.2.2",
"main": "intersections.js",

@@ -15,0 +16,0 @@ "scripts": {

@@ -80,1 +80,44 @@ var test = require('tape');

});
test('better deduping', function(t) {
var poly = [
[0, 0],
[20, 0],
[20, 5],
[20, 10],
];
var r = isects(poly);
t.equal(r.length, 0, 'no self-intersections');
t.end();
});
test('separated intersections', function(t) {
/*
o-----o
| |
o------x-----x------o
| | | |
| | | |
| | | |
o------o o------o
*/
var poly = [
[-10, 0],
[10, 0],
[10, 10],
[1, 10],
[1, -1],
[-1, -1],
[-1, 10],
[-10, 1]
];
var r = isects(poly);
t.equal(r.length, 2, 'two self-intersections');
t.end();
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc