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

@flatten-js/core

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flatten-js/core - npm Package Compare versions

Comparing version 1.3.9 to 1.3.10

2

index.d.ts

@@ -389,2 +389,3 @@ // Type definitions for flatten-js library

class PlanarSet extends Set {
// @ts-ignore (Set)
constructor(shapes?: IndexableElement[] | Set<IndexableElement>);

@@ -506,2 +507,3 @@

addVertex(pt: Point, edge: PolygonEdge): PolygonEdge;
removeEndVertex(edge: Edge): void;
cut(multiline: Multiline): Polygon[];

@@ -508,0 +510,0 @@ cutFace(pt1: Point, pt2: Point): [Polygon, Polygon];

2

package.json
{
"name": "@flatten-js/core",
"version": "1.3.9",
"version": "1.3.10",
"description": "Javascript library for 2d geometry",

@@ -5,0 +5,0 @@ "main": "dist/main.cjs.js",

@@ -9,2 +9,3 @@ /**

import CircularLinkedList from '../data_structures/circular_linked_list';
import {CCW, ORIENTATION} from '../utils/constants';

@@ -48,3 +49,3 @@ /**

if (args.length == 0) {
if (args.length === 0) {
return;

@@ -57,7 +58,7 @@ }

*/
if (args.length == 1) {
if (args.length === 1) {
if (args[0] instanceof Array) {
// let argsArray = args[0];
let shapes = args[0]; // argsArray[0];
if (shapes.length == 0)
if (shapes.length === 0)
return;

@@ -110,3 +111,3 @@

else if (args[0] instanceof Flatten.Circle) {
this.shapes2face(polygon.edges, [args[0].toArc(Flatten.CCW)]);
this.shapes2face(polygon.edges, [args[0].toArc(CCW)]);
}

@@ -127,3 +128,3 @@ /* Instantiate face from a box in CCW orientation */

/* Assume that edges already copied to polygon.edges set in the clip algorithm !!! */
if (args.length == 2 && args[0] instanceof Flatten.Edge && args[1] instanceof Flatten.Edge) {
if (args.length === 2 && args[0] instanceof Flatten.Edge && args[1] instanceof Flatten.Edge) {
this.first = args[0]; // first edge in face or undefined

@@ -261,5 +262,19 @@ this.last = args[1]; // last edge in face or undefined

/**
* Merge current edge with the next edge. Given edge will be extended,
* next edge after it will be removed. The distortion of the polygon
* is on the responsibility of the user of this method
* @param {Edge} edge - edge to be extended
* @returns {Face}
*/
merge_with_next_edge(edge) {
edge.shape.end.x = edge.next.shape.end.x
edge.shape.end.y = edge.next.shape.end.y
this.remove(edge.next)
return this;
}
/**
* Reverse orientation of the face: first edge become last and vice a verse,
* all edges starts and ends swapped, direction of arcs inverted. If face was oriented
* clockwise, it becomes counter clockwise and vice versa
* clockwise, it becomes counterclockwise and vice versa
*/

@@ -359,3 +374,3 @@ reverse() {

* and the sign of the integral will be defined by the direction of the curve.
* When the integral ("signed area") will be negative, direction is counter clockwise,
* When the integral ("signed area") will be negative, direction is counterclockwise,
* when positive - clockwise and when it is zero, polygon is not orientable.

@@ -369,7 +384,7 @@ * See {@link https://mathinsight.org/greens_theorem_find_area}

if (Flatten.Utils.EQ_0(area)) {
this._orientation = Flatten.ORIENTATION.NOT_ORIENTABLE;
this._orientation = ORIENTATION.NOT_ORIENTABLE;
} else if (Flatten.Utils.LT(area, 0)) {
this._orientation = Flatten.ORIENTATION.CCW;
this._orientation = ORIENTATION.CCW;
} else {
this._orientation = Flatten.ORIENTATION.CW;
this._orientation = ORIENTATION.CW;
}

@@ -384,3 +399,3 @@ }

* Self intersection test should check if polygon change orientation in the test point.
* @param {Edges} edges - reference to polygon.edges to provide search index
* @param {PlanarSet} edges - reference to polygon edges to provide search index
* @returns {boolean}

@@ -390,3 +405,3 @@ */

let ip = Face.getSelfIntersections(this, edges, true);
return ip.length == 0;
return ip.length === 0;
}

@@ -489,4 +504,4 @@

};
}
Flatten.Face = Face;

@@ -282,2 +282,13 @@ /**

/**
* Merge given edge with next edge and remove vertex between them
* @param {Edge} edge
*/
removeEndVertex(edge) {
const edge_next = edge.next
if (edge_next === edge) return
edge.face.merge_with_next_edge(edge)
this.edges.delete(edge_next)
}
/**
* Cut polygon with multiline and return array of new polygons

@@ -284,0 +295,0 @@ * Multiline should be constructed from a line with intersection point, see notebook:

/**
* Global constant CCW defines counter clockwise direction of arc
* Global constant CCW defines counterclockwise direction of arc
* @type {boolean}

@@ -4,0 +4,0 @@ */

@@ -11,2 +11,4 @@ /**

import {intersectLine2Polygon} from "../../src/algorithms/intersection";
import * as BooleanOperations from "../../src/algorithms/boolean_op";
let {unify} = BooleanOperations;

@@ -796,2 +798,16 @@ describe('#Flatten.Polygon', function() {

});
it('Can merge two edges into one', function() {
const a = new Polygon(box(0, 0, 100, 50).toPoints());
const b = new Polygon(box(0, 50, 100, 100).toPoints());
const union = unify(a, b);
expect(union.faces.size).to.equal(1);
const face = [...union.faces][0]
union.removeEndVertex(face.last)
expect(union.faces.size).to.equal(1);
union.removeEndVertex(face.first.next)
expect(union.faces.size).to.equal(1);
});
describe('#Flatten.Polygon.cut(multiline) methods', function() {

@@ -798,0 +814,0 @@ it('Can cut polygon with line. Case of non-intersection', function() {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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