diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 62378d4f..8b204440 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -32,9 +32,14 @@
-
+
-
+
+
+
+
+
+
@@ -127,7 +132,7 @@
-
+
project
@@ -167,7 +172,7 @@
-
+
project
$PROJECT_DIR$/node_modules/mocha
@@ -175,27 +180,26 @@
true
bdd
--require @babel/register
- TEST
- $PROJECT_DIR$/test/algorithms/boolean_op.js
+ SUITE
+ $PROJECT_DIR$/test/classes/polygon.js
-
-
-
+
-
+
project
$PROJECT_DIR$/node_modules/mocha
$PROJECT_DIR$
true
bdd
- --require @babel/register
- SUITE
- $PROJECT_DIR$/test/algorithms/relation.js
+
+ TEST
+ $PROJECT_DIR$/test/classes/polygon.js
-
+
+
@@ -214,19 +218,19 @@
-
-
+
+
+
-
-
-
+
+
@@ -383,11 +387,45 @@
-
-
-
-
-
+
+
+
+
+
+
+ 1578644089358
+
+
+
+ 1578644089358
+
+
+ 1578663619628
+
+
+
+ 1578663619628
+
+
+ 1578742345011
+
+
+
+ 1578742345011
+
+
+ 1578747826786
+
+
+
+ 1578747826786
+
+
+ 1578748480863
+
+
+
+ 1578748480863
1579030776012
@@ -697,42 +735,7 @@
1611863342220
-
- 1611923216426
-
-
-
- 1611923216426
-
-
- 1616766843746
-
-
-
- 1616766843746
-
-
- 1616766981145
-
-
-
- 1616766981145
-
-
- 1616911302053
-
-
-
- 1616911302054
-
-
- 1616924147009
-
-
-
- 1616924147009
-
-
+
@@ -751,6 +754,11 @@
+
+
+
+
+
@@ -771,12 +779,7 @@
-
-
-
-
-
-
+
@@ -793,12 +796,6 @@
356
-
- file://$PROJECT_DIR$/test/algorithms/boolean_op.js
- 620
-
-
-
diff --git a/dist/main.cjs.js b/dist/main.cjs.js
index 5a58b9f2..7e847f22 100644
--- a/dist/main.cjs.js
+++ b/dist/main.cjs.js
@@ -3354,7 +3354,7 @@ class IntervalTree {
/**
* Returns array of entry values which keys intersect with given interval
* If no values stored in the tree, returns array of keys which intersect given interval
- * @param {Interval} interval - search interval, or array [low, high]
+ * @param {Interval} interval - search interval, or tuple [low, high]
* @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
* @returns {Array}
*/
@@ -3365,6 +3365,17 @@ class IntervalTree {
return resp_nodes.map(node => outputMapperFn(node.item.value, node.item.key))
}
+ /**
+ * Returns true if intersection between given and any interval stored in the tree found
+ * @param {Interval} interval - search interval or tuple [low, high]
+ * @returns {boolean}
+ */
+ intersect_any(interval) {
+ let search_node = new Node(interval);
+ let found = this.tree_find_any_interval(this.root, search_node);
+ return found;
+ }
+
/**
* Tree visitor. For each node implement a callback function.
* Method calls a callback function with two parameters (key, value)
@@ -3634,6 +3645,25 @@ class IntervalTree {
}
}
+ tree_find_any_interval(node, search_node) {
+ let found = false;
+ if (node != null && node != this.nil_node) {
+ // if (node->left != this.nil_node && node->left->max >= low) {
+ if (node.left != this.nil_node && !node.not_intersect_left_subtree(search_node)) {
+ found = this.tree_find_any_interval(node.left, search_node);
+ }
+ // if (low <= node->high && node->low <= high) {
+ if (!found) {
+ found = node.intersect(search_node);
+ }
+ // if (node->right != this.nil_node && node->low <= high) {
+ if (!found && node.right != this.nil_node && !node.not_intersect_right_subtree(search_node)) {
+ found = this.tree_find_any_interval(node.right, search_node);
+ }
+ }
+ return found;
+ }
+
local_minimum(node) {
let node_min = node;
while (node_min.left != null && node_min.left != this.nil_node) {
@@ -5768,7 +5798,9 @@ class Arc {
/**
* Return new arc transformed using affine transformation matrix
- * Note, that non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result
+ * Note 1. Non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result because
+ * it should create elliptic arc but library does not support ellipses
+ * Note 2. Mirror transformation (matrix[0] * matrix[3] < 0) change direction of the arc to the opposite
* TODO: support non-equal scaling arc to ellipse or throw exception ?
* @param {Matrix} matrix - affine transformation matrix
* @returns {Arc}
@@ -5777,7 +5809,11 @@ class Arc {
let newStart = this.start.transform(matrix);
let newEnd = this.end.transform(matrix);
let newCenter = this.pc.transform(matrix);
- let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, this.counterClockwise);
+ let newDirection = this.counterClockwise;
+ if (matrix.a * matrix.d < 0) {
+ newDirection = !newDirection;
+ }
+ let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, newDirection);
return arc;
}
diff --git a/dist/main.esm.js b/dist/main.esm.js
index b4bb6b97..51796178 100644
--- a/dist/main.esm.js
+++ b/dist/main.esm.js
@@ -3350,7 +3350,7 @@ class IntervalTree {
/**
* Returns array of entry values which keys intersect with given interval
* If no values stored in the tree, returns array of keys which intersect given interval
- * @param {Interval} interval - search interval, or array [low, high]
+ * @param {Interval} interval - search interval, or tuple [low, high]
* @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
* @returns {Array}
*/
@@ -3361,6 +3361,17 @@ class IntervalTree {
return resp_nodes.map(node => outputMapperFn(node.item.value, node.item.key))
}
+ /**
+ * Returns true if intersection between given and any interval stored in the tree found
+ * @param {Interval} interval - search interval or tuple [low, high]
+ * @returns {boolean}
+ */
+ intersect_any(interval) {
+ let search_node = new Node(interval);
+ let found = this.tree_find_any_interval(this.root, search_node);
+ return found;
+ }
+
/**
* Tree visitor. For each node implement a callback function.
* Method calls a callback function with two parameters (key, value)
@@ -3630,6 +3641,25 @@ class IntervalTree {
}
}
+ tree_find_any_interval(node, search_node) {
+ let found = false;
+ if (node != null && node != this.nil_node) {
+ // if (node->left != this.nil_node && node->left->max >= low) {
+ if (node.left != this.nil_node && !node.not_intersect_left_subtree(search_node)) {
+ found = this.tree_find_any_interval(node.left, search_node);
+ }
+ // if (low <= node->high && node->low <= high) {
+ if (!found) {
+ found = node.intersect(search_node);
+ }
+ // if (node->right != this.nil_node && node->low <= high) {
+ if (!found && node.right != this.nil_node && !node.not_intersect_right_subtree(search_node)) {
+ found = this.tree_find_any_interval(node.right, search_node);
+ }
+ }
+ return found;
+ }
+
local_minimum(node) {
let node_min = node;
while (node_min.left != null && node_min.left != this.nil_node) {
@@ -5764,7 +5794,9 @@ class Arc {
/**
* Return new arc transformed using affine transformation matrix
- * Note, that non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result
+ * Note 1. Non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result because
+ * it should create elliptic arc but library does not support ellipses
+ * Note 2. Mirror transformation (matrix[0] * matrix[3] < 0) change direction of the arc to the opposite
* TODO: support non-equal scaling arc to ellipse or throw exception ?
* @param {Matrix} matrix - affine transformation matrix
* @returns {Arc}
@@ -5773,7 +5805,11 @@ class Arc {
let newStart = this.start.transform(matrix);
let newEnd = this.end.transform(matrix);
let newCenter = this.pc.transform(matrix);
- let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, this.counterClockwise);
+ let newDirection = this.counterClockwise;
+ if (matrix.a * matrix.d < 0) {
+ newDirection = !newDirection;
+ }
+ let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, newDirection);
return arc;
}
diff --git a/dist/main.umd.js b/dist/main.umd.js
index 1407c69c..52f80c94 100644
--- a/dist/main.umd.js
+++ b/dist/main.umd.js
@@ -3356,7 +3356,7 @@
/**
* Returns array of entry values which keys intersect with given interval
* If no values stored in the tree, returns array of keys which intersect given interval
- * @param {Interval} interval - search interval, or array [low, high]
+ * @param {Interval} interval - search interval, or tuple [low, high]
* @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output
* @returns {Array}
*/
@@ -3367,6 +3367,17 @@
return resp_nodes.map(node => outputMapperFn(node.item.value, node.item.key))
}
+ /**
+ * Returns true if intersection between given and any interval stored in the tree found
+ * @param {Interval} interval - search interval or tuple [low, high]
+ * @returns {boolean}
+ */
+ intersect_any(interval) {
+ let search_node = new Node(interval);
+ let found = this.tree_find_any_interval(this.root, search_node);
+ return found;
+ }
+
/**
* Tree visitor. For each node implement a callback function.
* Method calls a callback function with two parameters (key, value)
@@ -3636,6 +3647,25 @@
}
}
+ tree_find_any_interval(node, search_node) {
+ let found = false;
+ if (node != null && node != this.nil_node) {
+ // if (node->left != this.nil_node && node->left->max >= low) {
+ if (node.left != this.nil_node && !node.not_intersect_left_subtree(search_node)) {
+ found = this.tree_find_any_interval(node.left, search_node);
+ }
+ // if (low <= node->high && node->low <= high) {
+ if (!found) {
+ found = node.intersect(search_node);
+ }
+ // if (node->right != this.nil_node && node->low <= high) {
+ if (!found && node.right != this.nil_node && !node.not_intersect_right_subtree(search_node)) {
+ found = this.tree_find_any_interval(node.right, search_node);
+ }
+ }
+ return found;
+ }
+
local_minimum(node) {
let node_min = node;
while (node_min.left != null && node_min.left != this.nil_node) {
@@ -5770,7 +5800,9 @@
/**
* Return new arc transformed using affine transformation matrix
- * Note, that non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result
+ * Note 1. Non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result because
+ * it should create elliptic arc but library does not support ellipses
+ * Note 2. Mirror transformation (matrix[0] * matrix[3] < 0) change direction of the arc to the opposite
* TODO: support non-equal scaling arc to ellipse or throw exception ?
* @param {Matrix} matrix - affine transformation matrix
* @returns {Arc}
@@ -5779,7 +5811,11 @@
let newStart = this.start.transform(matrix);
let newEnd = this.end.transform(matrix);
let newCenter = this.pc.transform(matrix);
- let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, this.counterClockwise);
+ let newDirection = this.counterClockwise;
+ if (matrix.a * matrix.d < 0) {
+ newDirection = !newDirection;
+ }
+ let arc = Flatten.Arc.arcSE(newCenter, newStart, newEnd, newDirection);
return arc;
}
diff --git a/package-lock.json b/package-lock.json
index 7427d896..73c9bb40 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "@flatten-js/core",
- "version": "1.2.18",
+ "version": "1.2.22",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -1078,9 +1078,9 @@
}
},
"@flatten-js/interval-tree": {
- "version": "1.0.13",
- "resolved": "https://registry.npmjs.org/@flatten-js/interval-tree/-/interval-tree-1.0.13.tgz",
- "integrity": "sha512-5thHHdUZIRdPdEPx6G9tY6mHFMGoXsq9/ivemRszDcEkERXqlZAv+7NozaFbAUOvKXxyWoccSnLyjK0c5UWJeQ=="
+ "version": "1.0.14",
+ "resolved": "https://registry.npmjs.org/@flatten-js/interval-tree/-/interval-tree-1.0.14.tgz",
+ "integrity": "sha512-u7RFCMnrQb/fC6gIEXtfuqXFXN+yRDM+NSKZe0JECVyiDPTPqYDgkzvRHIX1NS1BxgK6BlZRLtPukAHoDJgGWg=="
},
"@istanbuljs/load-nyc-config": {
"version": "1.1.0",
@@ -4009,7 +4009,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
- "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
diff --git a/package.json b/package.json
index c18191ce..c8a86afd 100644
--- a/package.json
+++ b/package.json
@@ -70,6 +70,6 @@
"rollup-plugin-terser": "^5.1.3"
},
"dependencies": {
- "@flatten-js/interval-tree": "^1.0.13"
+ "@flatten-js/interval-tree": "^1.0.14"
}
}
diff --git a/src/classes/arc.js b/src/classes/arc.js
index 2831fc89..cf75cf61 100644
--- a/src/classes/arc.js
+++ b/src/classes/arc.js
@@ -405,7 +405,9 @@ export class Arc {
/**
* Return new arc transformed using affine transformation matrix
- * Note, that non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result
+ * Note 1. Non-equal scaling by x and y (matrix[0] != matrix[3]) produce illegal result because
+ * it should create elliptic arc but library does not support ellipses
+ * Note 2. Mirror transformation (matrix[0] * matrix[3] < 0) change direction of the arc to the opposite
* TODO: support non-equal scaling arc to ellipse or throw exception ?
* @param {Matrix} matrix - affine transformation matrix
* @returns {Arc}