Skip to content

Commit

Permalink
- Commit pull request #88 Reverse arc direction when reflecting over …
Browse files Browse the repository at this point in the history
…a single axis, publish compiled package
  • Loading branch information
alexbol99 committed May 15, 2021
1 parent 878f75c commit bf7a901
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 88 deletions.
141 changes: 69 additions & 72 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 39 additions & 3 deletions dist/main.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3354,7 +3354,7 @@ class IntervalTree {
/**
* Returns array of entry values which keys intersect with given interval <br/>
* 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}
*/
Expand All @@ -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. <br/>
* Method calls a callback function with two parameters (key, value)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -5768,7 +5798,9 @@ class Arc {

/**
* Return new arc transformed using affine transformation matrix <br/>
* 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}
Expand All @@ -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;
}

Expand Down
Loading

0 comments on commit bf7a901

Please sign in to comment.